Add ability to silence IRC relay of region joins and quits from certain users
This is useful for admins who wish to remain hidden, or service bots.
Thanks RemedyTomm
arthursv
Justin Clark-Casey (justincc) 2009-08-17 19:48:32 +01:00
parent 95bb22f883
commit eb78ac343e
3 changed files with 32 additions and 13 deletions

View File

@ -83,6 +83,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
internal string _accessPassword = String.Empty; internal string _accessPassword = String.Empty;
internal Regex AccessPasswordRegex = null; internal Regex AccessPasswordRegex = null;
internal List<string> ExcludeList = new List<string>();
internal string AccessPassword internal string AccessPassword
{ {
get { return _accessPassword; } get { return _accessPassword; }
@ -210,7 +211,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
m_log.DebugFormat("[IRC-Channel-{0}] PingDelay : <{1}>", cs.idn, cs.PingDelay); m_log.DebugFormat("[IRC-Channel-{0}] PingDelay : <{1}>", cs.idn, cs.PingDelay);
cs.AccessPassword = Substitute(rs, config.GetString("access_password", cs.AccessPassword)); cs.AccessPassword = Substitute(rs, config.GetString("access_password", cs.AccessPassword));
m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword); m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword);
string[] excludes = config.GetString("exclude_list", "").Trim().Split(new Char[] { ',' });
cs.ExcludeList = new List<string>(excludes.Length);
foreach(string name in excludes)
{
cs.ExcludeList.Add(name.Trim().ToLower());
}
// Fail if fundamental information is still missing // Fail if fundamental information is still missing

View File

@ -145,8 +145,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
if (enabled && (cs.irc.Enabled) && (cs.irc.Connected) && (cs.ClientReporting)) if (enabled && (cs.irc.Enabled) && (cs.irc.Connected) && (cs.ClientReporting))
{ {
m_log.InfoFormat("[IRC-Region {0}]: {1} has left", Region, client.Name); m_log.InfoFormat("[IRC-Region {0}]: {1} has left", Region, client.Name);
//Check if this person is excluded from IRC
if (!cs.ExcludeList.Contains(client.Name.ToLower()))
{
cs.irc.PrivMsg(cs.NoticeMessageFormat, cs.irc.Nick, Region, String.Format("{0} has left", client.Name)); cs.irc.PrivMsg(cs.NoticeMessageFormat, cs.irc.Nick, Region, String.Format("{0} has left", client.Name));
} }
}
client.OnLogout -= OnClientLoggedOut; client.OnLogout -= OnClientLoggedOut;
client.OnConnectionClosed -= OnClientLoggedOut; client.OnConnectionClosed -= OnClientLoggedOut;
clients.Remove(client); clients.Remove(client);
@ -209,10 +213,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
{ {
string clientName = String.Format("{0} {1}", presence.Firstname, presence.Lastname); string clientName = String.Format("{0} {1}", presence.Firstname, presence.Lastname);
m_log.DebugFormat("[IRC-Region {0}] {1} has arrived", Region, clientName); m_log.DebugFormat("[IRC-Region {0}] {1} has arrived", Region, clientName);
//Check if this person is excluded from IRC
if (!cs.ExcludeList.Contains(clientName.ToLower()))
{
cs.irc.PrivMsg(cs.NoticeMessageFormat, cs.irc.Nick, Region, String.Format("{0} has arrived", clientName)); cs.irc.PrivMsg(cs.NoticeMessageFormat, cs.irc.Nick, Region, String.Format("{0} has arrived", clientName));
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
m_log.ErrorFormat("[IRC-Region {0}]: MakeRootAgent exception: {1}", Region, ex.Message); m_log.ErrorFormat("[IRC-Region {0}]: MakeRootAgent exception: {1}", Region, ex.Message);

View File

@ -679,15 +679,20 @@
;relay_chat = true ;relay_chat = true
;access_password = foobar ;access_password = foobar
;fallback_region = name of "default" region ;;fallback_region = name of "default" region
;MSGformat fields : 0=botnick, 1=user, 2=region, 3=message ;;MSGformat fields : 0=botnick, 1=user, 2=region, 3=message
; must start with "PRIVMSG {0} : " or irc server will get upset ;; must start with "PRIVMSG {0} : " or irc server will get upset
;for <bot>:<user in region> :<message> ;;for <bot>:<user in region> :<message>
;msgformat = "PRIVMSG {0} :<{1} in {2}>: {3}" ;;msgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"
;for <bot>:<message> - <user of region> : ;;for <bot>:<message> - <user of region> :
msgformat = "PRIVMSG {0} : {3} - {1} of {2}" ;msgformat = "PRIVMSG {0} : {3} - {1} of {2}"
;for <bot>:<message> - from <user> : ;;for <bot>:<message> - from <user> :
;msgformat = "PRIVMSG {0} : {3} - from {1}" ;;msgformat = "PRIVMSG {0} : {3} - from {1}"
;; exclude_list allows you to stop the IRC connector from announcing the
;;arrival and departure of certain users. For example: admins, bots.
;exclude_list=User 1,User 2,User 3
;[CMS] ;[CMS]