From 115e1c2abb7755eb7b5ffeafbc0aecd255ccfc4e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 Jan 2013 23:22:02 +0000 Subject: Add "debug set set animations true|false" region console command. Setting this logs extra information about animation add/remove, such as uuid and animation name Unfortunately cannot be done per client yet --- .../Avatar/Animations/AnimationsCommandModule.cs | 23 ++++------------------ 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar') diff --git a/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs index e951d9e..84211a9 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs @@ -161,12 +161,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations UUID defaultAnimId = anims.DefaultAnimation.AnimID; cdl.AddRow( "Default anim", - string.Format("{0}, {1}", defaultAnimId, GetAnimName(sp.Scene.AssetService, defaultAnimId))); + string.Format("{0}, {1}", defaultAnimId, sp.Animator.GetAnimName(defaultAnimId))); UUID implicitDefaultAnimId = anims.ImplicitDefaultAnimation.AnimID; cdl.AddRow( "Implicit default anim", - string.Format("{0}, {1}", implicitDefaultAnimId, GetAnimName(sp.Scene.AssetService, implicitDefaultAnimId))); + string.Format("{0}, {1}", + implicitDefaultAnimId, sp.Animator.GetAnimName(implicitDefaultAnimId))); cdl.AddToStringBuilder(sb); @@ -185,7 +186,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations for (int i = 0; i < animIds.Length; i++) { UUID animId = animIds[i]; - string animName = GetAnimName(sp.Scene.AssetService, animId); + string animName = sp.Animator.GetAnimName(animId); int seq = sequenceNumbers[i]; UUID objectId = objectIds[i]; @@ -195,21 +196,5 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations cdt.AddToStringBuilder(sb); sb.Append("\n"); } - - private string GetAnimName(IAssetService assetService, UUID animId) - { - string animName; - - if (!DefaultAvatarAnimations.AnimsNames.TryGetValue(animId, out animName)) - { - AssetMetadata amd = assetService.GetMetadata(animId.ToString()); - if (amd != null) - animName = amd.Name; - else - animName = "Unknown"; - } - - return animName; - } } } \ No newline at end of file -- cgit v1.1 From 9c590e51b6a1457ccb9eaee525d1e5a244b50274 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Sun, 13 Jan 2013 20:18:40 +0100 Subject: IRCBridgeModule: optional agent-alertbox for IRC enabled Regions look in OpenSimDefaults.ini / section [IRC] http://opensimulator.org/mantis/view.php?id=6470 idea: https://github.com/ssm2017/IrcBridgeAlert --- .../OptionalModules/Avatar/Chat/ChannelState.cs | 158 ++++++------ .../OptionalModules/Avatar/Chat/IRCBridgeModule.cs | 41 +-- .../OptionalModules/Avatar/Chat/IRCConnector.cs | 283 +++++++++++---------- .../OptionalModules/Avatar/Chat/RegionState.cs | 96 ++++--- 4 files changed, 305 insertions(+), 273 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Avatar') diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs index 66265d8..5a37fad 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs @@ -55,42 +55,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // These are the IRC Connector configurable parameters with hard-wired // default values (retained for compatability). - internal string Server = null; - internal string Password = null; - internal string IrcChannel = null; - internal string BaseNickname = "OSimBot"; - internal uint Port = 6667; - internal string User = null; - - internal bool ClientReporting = true; - internal bool RelayChat = true; - internal bool RelayPrivateChannels = false; - internal int RelayChannel = 1; + internal string Server = null; + internal string Password = null; + internal string IrcChannel = null; + internal string BaseNickname = "OSimBot"; + internal uint Port = 6667; + internal string User = null; + + internal bool ClientReporting = true; + internal bool RelayChat = true; + internal bool RelayPrivateChannels = false; + internal int RelayChannel = 1; internal List ValidInWorldChannels = new List(); // Connector agnostic parameters. These values are NOT shared with the // connector and do not differentiate at an IRC level internal string PrivateMessageFormat = "PRIVMSG {0} :<{2}> {1} {3}"; - internal string NoticeMessageFormat = "PRIVMSG {0} :<{2}> {3}"; - internal int RelayChannelOut = -1; - internal bool RandomizeNickname = true; - internal bool CommandsEnabled = false; - internal int CommandChannel = -1; - internal int ConnectDelay = 10; - internal int PingDelay = 15; - internal string DefaultZone = "Sim"; - - internal string _accessPassword = String.Empty; - internal Regex AccessPasswordRegex = null; - internal List ExcludeList = new List(); + internal string NoticeMessageFormat = "PRIVMSG {0} :<{2}> {3}"; + internal int RelayChannelOut = -1; + internal bool RandomizeNickname = true; + internal bool CommandsEnabled = false; + internal int CommandChannel = -1; + internal int ConnectDelay = 10; + internal int PingDelay = 15; + internal string DefaultZone = "Sim"; + + internal string _accessPassword = String.Empty; + internal Regex AccessPasswordRegex = null; + internal List ExcludeList = new List(); internal string AccessPassword { get { return _accessPassword; } - set + set { _accessPassword = value; - AccessPasswordRegex = new Regex(String.Format(@"^{0},\s*(?[^,]+),\s*(?.+)$", _accessPassword), + AccessPasswordRegex = new Regex(String.Format(@"^{0},\s*(?[^,]+),\s*(?.+)$", _accessPassword), RegexOptions.Compiled); } } @@ -99,9 +99,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // IRC connector reference - internal IRCConnector irc = null; + internal IRCConnector irc = null; - internal int idn = _idk_++; + internal int idn = _idk_++; // List of regions dependent upon this connection @@ -119,29 +119,29 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat internal ChannelState(ChannelState model) { - Server = model.Server; - Password = model.Password; - IrcChannel = model.IrcChannel; - Port = model.Port; - BaseNickname = model.BaseNickname; - RandomizeNickname = model.RandomizeNickname; - User = model.User; - CommandsEnabled = model.CommandsEnabled; - CommandChannel = model.CommandChannel; - RelayChat = model.RelayChat; + Server = model.Server; + Password = model.Password; + IrcChannel = model.IrcChannel; + Port = model.Port; + BaseNickname = model.BaseNickname; + RandomizeNickname = model.RandomizeNickname; + User = model.User; + CommandsEnabled = model.CommandsEnabled; + CommandChannel = model.CommandChannel; + RelayChat = model.RelayChat; RelayPrivateChannels = model.RelayPrivateChannels; - RelayChannelOut = model.RelayChannelOut; - RelayChannel = model.RelayChannel; + RelayChannelOut = model.RelayChannelOut; + RelayChannel = model.RelayChannel; ValidInWorldChannels = model.ValidInWorldChannels; PrivateMessageFormat = model.PrivateMessageFormat; - NoticeMessageFormat = model.NoticeMessageFormat; - ClientReporting = model.ClientReporting; - AccessPassword = model.AccessPassword; - DefaultZone = model.DefaultZone; - ConnectDelay = model.ConnectDelay; - PingDelay = model.PingDelay; + NoticeMessageFormat = model.NoticeMessageFormat; + ClientReporting = model.ClientReporting; + AccessPassword = model.AccessPassword; + DefaultZone = model.DefaultZone; + ConnectDelay = model.ConnectDelay; + PingDelay = model.PingDelay; } - + // Read the configuration file, performing variable substitution and any // necessary aliasing. See accompanying documentation for how this works. // If you don't need variables, then this works exactly as before. @@ -160,54 +160,54 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.DebugFormat("[IRC-Channel-{0}] Initial request by Region {1} to connect to IRC", cs.idn, rs.Region); - cs.Server = Substitute(rs, config.GetString("server", null)); + cs.Server = Substitute(rs, config.GetString("server", null)); m_log.DebugFormat("[IRC-Channel-{0}] Server : <{1}>", cs.idn, cs.Server); - cs.Password = Substitute(rs, config.GetString("password", null)); + cs.Password = Substitute(rs, config.GetString("password", null)); // probably not a good idea to put a password in the log file - cs.User = Substitute(rs, config.GetString("user", null)); - cs.IrcChannel = Substitute(rs, config.GetString("channel", null)); + cs.User = Substitute(rs, config.GetString("user", null)); + cs.IrcChannel = Substitute(rs, config.GetString("channel", null)); m_log.DebugFormat("[IRC-Channel-{0}] IrcChannel : <{1}>", cs.idn, cs.IrcChannel); - cs.Port = Convert.ToUInt32(Substitute(rs, config.GetString("port", Convert.ToString(cs.Port)))); + cs.Port = Convert.ToUInt32(Substitute(rs, config.GetString("port", Convert.ToString(cs.Port)))); m_log.DebugFormat("[IRC-Channel-{0}] Port : <{1}>", cs.idn, cs.Port); - cs.BaseNickname = Substitute(rs, config.GetString("nick", cs.BaseNickname)); + cs.BaseNickname = Substitute(rs, config.GetString("nick", cs.BaseNickname)); m_log.DebugFormat("[IRC-Channel-{0}] BaseNickname : <{1}>", cs.idn, cs.BaseNickname); - cs.RandomizeNickname = Convert.ToBoolean(Substitute(rs, config.GetString("randomize_nick", Convert.ToString(cs.RandomizeNickname)))); + cs.RandomizeNickname = Convert.ToBoolean(Substitute(rs, config.GetString("randomize_nick", Convert.ToString(cs.RandomizeNickname)))); m_log.DebugFormat("[IRC-Channel-{0}] RandomizeNickname : <{1}>", cs.idn, cs.RandomizeNickname); - cs.RandomizeNickname = Convert.ToBoolean(Substitute(rs, config.GetString("nicknum", Convert.ToString(cs.RandomizeNickname)))); + cs.RandomizeNickname = Convert.ToBoolean(Substitute(rs, config.GetString("nicknum", Convert.ToString(cs.RandomizeNickname)))); m_log.DebugFormat("[IRC-Channel-{0}] RandomizeNickname : <{1}>", cs.idn, cs.RandomizeNickname); - cs.User = Substitute(rs, config.GetString("username", cs.User)); + cs.User = Substitute(rs, config.GetString("username", cs.User)); m_log.DebugFormat("[IRC-Channel-{0}] User : <{1}>", cs.idn, cs.User); - cs.CommandsEnabled = Convert.ToBoolean(Substitute(rs, config.GetString("commands_enabled", Convert.ToString(cs.CommandsEnabled)))); + cs.CommandsEnabled = Convert.ToBoolean(Substitute(rs, config.GetString("commands_enabled", Convert.ToString(cs.CommandsEnabled)))); m_log.DebugFormat("[IRC-Channel-{0}] CommandsEnabled : <{1}>", cs.idn, cs.CommandsEnabled); - cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("commandchannel", Convert.ToString(cs.CommandChannel)))); + cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("commandchannel", Convert.ToString(cs.CommandChannel)))); m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); - cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("command_channel", Convert.ToString(cs.CommandChannel)))); + cs.CommandChannel = Convert.ToInt32(Substitute(rs, config.GetString("command_channel", Convert.ToString(cs.CommandChannel)))); m_log.DebugFormat("[IRC-Channel-{0}] CommandChannel : <{1}>", cs.idn, cs.CommandChannel); - cs.RelayChat = Convert.ToBoolean(Substitute(rs, config.GetString("relay_chat", Convert.ToString(cs.RelayChat)))); + cs.RelayChat = Convert.ToBoolean(Substitute(rs, config.GetString("relay_chat", Convert.ToString(cs.RelayChat)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayChat : <{1}>", cs.idn, cs.RelayChat); cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("relay_private_channels", Convert.ToString(cs.RelayPrivateChannels)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayPrivateChannels : <{1}>", cs.idn, cs.RelayPrivateChannels); cs.RelayPrivateChannels = Convert.ToBoolean(Substitute(rs, config.GetString("useworldcomm", Convert.ToString(cs.RelayPrivateChannels)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayPrivateChannels : <{1}>", cs.idn, cs.RelayPrivateChannels); - cs.RelayChannelOut = Convert.ToInt32(Substitute(rs, config.GetString("relay_private_channel_out", Convert.ToString(cs.RelayChannelOut)))); + cs.RelayChannelOut = Convert.ToInt32(Substitute(rs, config.GetString("relay_private_channel_out", Convert.ToString(cs.RelayChannelOut)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayChannelOut : <{1}>", cs.idn, cs.RelayChannelOut); - cs.RelayChannel = Convert.ToInt32(Substitute(rs, config.GetString("relay_private_channel_in", Convert.ToString(cs.RelayChannel)))); + cs.RelayChannel = Convert.ToInt32(Substitute(rs, config.GetString("relay_private_channel_in", Convert.ToString(cs.RelayChannel)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayChannel : <{1}>", cs.idn, cs.RelayChannel); - cs.RelayChannel = Convert.ToInt32(Substitute(rs, config.GetString("inchannel", Convert.ToString(cs.RelayChannel)))); + cs.RelayChannel = Convert.ToInt32(Substitute(rs, config.GetString("inchannel", Convert.ToString(cs.RelayChannel)))); m_log.DebugFormat("[IRC-Channel-{0}] RelayChannel : <{1}>", cs.idn, cs.RelayChannel); cs.PrivateMessageFormat = Substitute(rs, config.GetString("msgformat", cs.PrivateMessageFormat)); m_log.DebugFormat("[IRC-Channel-{0}] PrivateMessageFormat : <{1}>", cs.idn, cs.PrivateMessageFormat); cs.NoticeMessageFormat = Substitute(rs, config.GetString("noticeformat", cs.NoticeMessageFormat)); m_log.DebugFormat("[IRC-Channel-{0}] NoticeMessageFormat : <{1}>", cs.idn, cs.NoticeMessageFormat); - cs.ClientReporting = Convert.ToInt32(Substitute(rs, config.GetString("verbosity", cs.ClientReporting?"1":"0"))) > 0; + cs.ClientReporting = Convert.ToInt32(Substitute(rs, config.GetString("verbosity", cs.ClientReporting ? "1" : "0"))) > 0; m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); - cs.ClientReporting = Convert.ToBoolean(Substitute(rs, config.GetString("report_clients", Convert.ToString(cs.ClientReporting)))); + cs.ClientReporting = Convert.ToBoolean(Substitute(rs, config.GetString("report_clients", Convert.ToString(cs.ClientReporting)))); m_log.DebugFormat("[IRC-Channel-{0}] ClientReporting : <{1}>", cs.idn, cs.ClientReporting); - cs.DefaultZone = Substitute(rs, config.GetString("fallback_region", cs.DefaultZone)); + cs.DefaultZone = Substitute(rs, config.GetString("fallback_region", cs.DefaultZone)); m_log.DebugFormat("[IRC-Channel-{0}] DefaultZone : <{1}>", cs.idn, cs.DefaultZone); - cs.ConnectDelay = Convert.ToInt32(Substitute(rs, config.GetString("connect_delay", Convert.ToString(cs.ConnectDelay)))); + cs.ConnectDelay = Convert.ToInt32(Substitute(rs, config.GetString("connect_delay", Convert.ToString(cs.ConnectDelay)))); m_log.DebugFormat("[IRC-Channel-{0}] ConnectDelay : <{1}>", cs.idn, cs.ConnectDelay); - cs.PingDelay = Convert.ToInt32(Substitute(rs, config.GetString("ping_delay", Convert.ToString(cs.PingDelay)))); + cs.PingDelay = Convert.ToInt32(Substitute(rs, config.GetString("ping_delay", Convert.ToString(cs.PingDelay)))); m_log.DebugFormat("[IRC-Channel-{0}] PingDelay : <{1}>", cs.idn, cs.PingDelay); cs.AccessPassword = Substitute(rs, config.GetString("access_password", cs.AccessPassword)); m_log.DebugFormat("[IRC-Channel-{0}] AccessPassword : <{1}>", cs.idn, cs.AccessPassword); @@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { cs.ExcludeList.Add(name.Trim().ToLower()); } - + // Fail if fundamental information is still missing if (cs.Server == null) @@ -306,8 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat IRCBridgeModule.m_channels.Add(cs); - m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}", - cs.idn, rs.Region, cs.DefaultZone, + m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}", + cs.idn, rs.Region, cs.DefaultZone, cs.CommandsEnabled ? "enabled" : "not enabled", cs.RelayPrivateChannels ? "relayed" : "not relayed"); } @@ -417,7 +417,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat private bool IsAConnectionMatchFor(ChannelState cs) { return ( - Server == cs.Server && + Server == cs.Server && IrcChannel == cs.IrcChannel && Port == cs.Port && BaseNickname == cs.BaseNickname && @@ -473,27 +473,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { string vvar = arg.Match(result).ToString(); - string var = vvar.Substring(1,vvar.Length-2).Trim(); + string var = vvar.Substring(1, vvar.Length - 2).Trim(); switch (var.ToLower()) { - case "%region" : + case "%region": result = result.Replace(vvar, rs.Region); break; - case "%host" : + case "%host": result = result.Replace(vvar, rs.Host); break; - case "%locx" : + case "%locx": result = result.Replace(vvar, rs.LocX); break; - case "%locy" : + case "%locy": result = result.Replace(vvar, rs.LocY); break; - case "%k" : + case "%k": result = result.Replace(vvar, rs.IDK); break; - default : - result = result.Replace(vvar, rs.config.GetString(var,var)); + default: + result = result.Replace(vvar, rs.config.GetString(var, var)); break; } // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result); diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs index 2e1d03d..351dbfe 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs @@ -46,18 +46,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - internal static bool m_pluginEnabled = false; + internal static bool Enabled = false; internal static IConfig m_config = null; internal static List m_channels = new List(); - internal static List m_regions = new List(); + internal static List m_regions = new List(); internal static string m_password = String.Empty; internal RegionState m_region = null; #region INonSharedRegionModule Members - public Type ReplaceableInterface + public Type ReplaceableInterface { get { return null; } } @@ -72,13 +72,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_config = config.Configs["IRC"]; if (m_config == null) { -// m_log.InfoFormat("[IRC-Bridge] module not configured"); + // m_log.InfoFormat("[IRC-Bridge] module not configured"); return; } if (!m_config.GetBoolean("enabled", false)) { -// m_log.InfoFormat("[IRC-Bridge] module disabled in configuration"); + // m_log.InfoFormat("[IRC-Bridge] module disabled in configuration"); return; } @@ -87,19 +87,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_password = config.Configs["RemoteAdmin"].GetString("access_password", m_password); } - m_pluginEnabled = true; - m_log.InfoFormat("[IRC-Bridge]: Module enabled"); + Enabled = true; + + m_log.InfoFormat("[IRC-Bridge]: Module is enabled"); } public void AddRegion(Scene scene) { - if (m_pluginEnabled) + if (Enabled) { try { m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName); + if (!String.IsNullOrEmpty(m_password)) MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false); + m_region = new RegionState(scene, m_config); lock (m_regions) m_regions.Add(m_region); m_region.Open(); @@ -123,7 +126,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void RemoveRegion(Scene scene) { - if (!m_pluginEnabled) + if (!Enabled) return; if (m_region == null) @@ -150,12 +153,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.Debug("[IRC-Bridge]: XML RPC Admin Entry"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable responseData = new Hashtable(); + Hashtable responseData = new Hashtable(); try { Hashtable requestData = (Hashtable)request.Params[0]; - bool found = false; + bool found = false; string region = String.Empty; if (m_password != String.Empty) @@ -169,18 +172,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat if (!requestData.ContainsKey("region")) throw new Exception("No region name specified"); region = (string)requestData["region"]; - + foreach (RegionState rs in m_regions) { if (rs.Region == region) { - responseData["server"] = rs.cs.Server; - responseData["port"] = (int)rs.cs.Port; - responseData["user"] = rs.cs.User; - responseData["channel"] = rs.cs.IrcChannel; - responseData["enabled"] = rs.cs.irc.Enabled; + responseData["server"] = rs.cs.Server; + responseData["port"] = (int)rs.cs.Port; + responseData["user"] = rs.cs.User; + responseData["channel"] = rs.cs.IrcChannel; + responseData["enabled"] = rs.cs.irc.Enabled; responseData["connected"] = rs.cs.irc.Connected; - responseData["nickname"] = rs.cs.irc.Nick; + responseData["nickname"] = rs.cs.irc.Nick; found = true; break; } @@ -195,7 +198,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.ErrorFormat("[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message); responseData["success"] = "false"; - responseData["error"] = e.Message; + responseData["error"] = e.Message; } finally { diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs index a014798..c5cba8e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs @@ -53,16 +53,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // Local constants private static readonly Vector3 CenterOfRegion = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); - private static readonly char[] CS_SPACE = { ' ' }; + private static readonly char[] CS_SPACE = { ' ' }; - private const int WD_INTERVAL = 1000; // base watchdog interval - private static int PING_PERIOD = 15; // WD intervals per PING - private static int ICCD_PERIOD = 10; // WD intervals between Connects - private static int L_TIMEOUT = 25; // Login time out interval + private const int WD_INTERVAL = 1000; // base watchdog interval + private static int PING_PERIOD = 15; // WD intervals per PING + private static int ICCD_PERIOD = 10; // WD intervals between Connects + private static int L_TIMEOUT = 25; // Login time out interval - private static int _idk_ = 0; // core connector identifier - private static int _pdk_ = 0; // ping interval counter - private static int _icc_ = ICCD_PERIOD; // IRC connect counter + private static int _idk_ = 0; // core connector identifier + private static int _pdk_ = 0; // ping interval counter + private static int _icc_ = ICCD_PERIOD; // IRC connect counter // List of configured connectors @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat private Object msyncConnect = new Object(); - internal bool m_randomizeNick = true; // add random suffix + internal bool m_randomizeNick = true; // add random suffix internal string m_baseNick = null; // base name for randomizing internal string m_nick = null; // effective nickname @@ -122,7 +122,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat get { return m_nick; } set { m_nick = value; } } - + private bool m_enabled = false; // connector enablement public bool Enabled { @@ -130,8 +130,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat } private bool m_connected = false; // connection status - private bool m_pending = false; // login disposition - private int m_timeout = L_TIMEOUT; // login timeout counter + private bool m_pending = false; // login disposition + private int m_timeout = L_TIMEOUT; // login timeout counter public bool Connected { get { return m_connected; } @@ -143,9 +143,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat get { return m_ircChannel; } set { m_ircChannel = value; } } - + private uint m_port = 6667; // session port - public uint Port + public uint Port { get { return m_port; } set { m_port = value; } @@ -172,10 +172,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // Network interface - private TcpClient m_tcp; + private TcpClient m_tcp; private NetworkStream m_stream = null; - private StreamReader m_reader; - private StreamWriter m_writer; + private StreamReader m_reader; + private StreamWriter m_writer; // Channel characteristic info (if available) @@ -193,26 +193,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // Prepare network interface - m_tcp = null; + m_tcp = null; m_writer = null; m_reader = null; // Setup IRC session parameters - m_server = cs.Server; - m_password = cs.Password; - m_baseNick = cs.BaseNickname; + m_server = cs.Server; + m_password = cs.Password; + m_baseNick = cs.BaseNickname; m_randomizeNick = cs.RandomizeNickname; - m_ircChannel = cs.IrcChannel; - m_port = cs.Port; - m_user = cs.User; + m_ircChannel = cs.IrcChannel; + m_port = cs.Port; + m_user = cs.User; if (m_watchdog == null) { // Non-differentiating - ICCD_PERIOD = cs.ConnectDelay; - PING_PERIOD = cs.PingDelay; + ICCD_PERIOD = cs.ConnectDelay; + PING_PERIOD = cs.PingDelay; // Smaller values are not reasonable @@ -235,7 +235,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat if (m_randomizeNick) m_nick = m_baseNick + Util.RandomClass.Next(1, 99); - else + else m_nick = m_baseNick; m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); @@ -295,18 +295,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_nick, m_ircChannel, m_server)); m_writer.Flush(); } - catch (Exception) {} - + catch (Exception) { } + m_connected = false; - try { m_writer.Close(); } catch (Exception) {} - try { m_reader.Close(); } catch (Exception) {} - try { m_stream.Close(); } catch (Exception) {} - try { m_tcp.Close(); } catch (Exception) {} + try { m_writer.Close(); } + catch (Exception) { } + try { m_reader.Close(); } + catch (Exception) { } + try { m_stream.Close(); } + catch (Exception) { } + try { m_tcp.Close(); } + catch (Exception) { } } - + lock (m_connectors) m_connectors.Remove(this); @@ -347,15 +351,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat if (m_connected) return; m_connected = true; - m_pending = true; - m_timeout = L_TIMEOUT; + m_pending = true; + m_timeout = L_TIMEOUT; - m_tcp = new TcpClient(m_server, (int)m_port); + m_tcp = new TcpClient(m_server, (int)m_port); m_stream = m_tcp.GetStream(); m_reader = new StreamReader(m_stream); m_writer = new StreamWriter(m_stream); - m_log.InfoFormat("[IRC-Connector-{0}]: Connected to {1}:{2}", idn, m_server, m_port); + m_log.InfoFormat("[IRC-Connector-{0}]: Connected to {1}:{2}", idn, m_server, m_port); m_listener = new Thread(new ThreadStart(ListenerRun)); m_listener.Name = "IRCConnectorListenerThread"; @@ -418,12 +422,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // the socket and it will disappear of its own accord, once this // processing is completed. - try { m_writer.Close(); } catch (Exception) {} - try { m_reader.Close(); } catch (Exception) {} - try { m_tcp.Close(); } catch (Exception) {} + try { m_writer.Close(); } + catch (Exception) { } + try { m_reader.Close(); } + catch (Exception) { } + try { m_tcp.Close(); } + catch (Exception) { } m_connected = false; - m_pending = false; + m_pending = false; m_resetk++; } @@ -495,7 +502,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { string inputLine; - int resetk = m_resetk; + int resetk = m_resetk; try { @@ -555,7 +562,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat Reconnect(); } - private Regex RE = new Regex(@":(?[\w-]*)!(?\S*) PRIVMSG (?\S+) :(?.*)", + private Regex RE = new Regex(@":(?[\w-]*)!(?\S*) PRIVMSG (?\S+) :(?.*)", RegexOptions.Multiline); private Dictionary ExtractMsg(string input) @@ -617,8 +624,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat string[] commArgs; string c_server = m_server; - string pfx = String.Empty; - string cmd = String.Empty; + string pfx = String.Empty; + string cmd = String.Empty; string parms = String.Empty; // ":" indicates that a prefix is present @@ -627,15 +634,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // ":" indicates that the remainder of the // line is a single parameter value. - commArgs = command.Split(CS_SPACE,2); + commArgs = command.Split(CS_SPACE, 2); if (commArgs[0].StartsWith(":")) { pfx = commArgs[0].Substring(1); - commArgs = commArgs[1].Split(CS_SPACE,2); + commArgs = commArgs[1].Split(CS_SPACE, 2); } - cmd = commArgs[0]; + cmd = commArgs[0]; parms = commArgs[1]; // m_log.DebugFormat("[IRC-Connector-{0}] prefix = <{1}> cmd = <{2}>", idn, pfx, cmd); @@ -646,44 +653,44 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // Messages 001-004 are always sent // following signon. - case "001" : // Welcome ... - case "002" : // Server information - case "003" : // Welcome ... + case "001": // Welcome ... + case "002": // Server information + case "003": // Welcome ... break; - case "004" : // Server information + case "004": // Server information m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); commArgs = parms.Split(CS_SPACE); c_server = commArgs[1]; m_server = c_server; - version = commArgs[2]; - usermod = commArgs[3]; - chanmod = commArgs[4]; + version = commArgs[2]; + usermod = commArgs[3]; + chanmod = commArgs[4]; break; - case "005" : // Server information + case "005": // Server information break; - case "042" : - case "250" : - case "251" : - case "252" : - case "254" : - case "255" : - case "265" : - case "266" : - case "332" : // Subject - case "333" : // Subject owner (?) - case "353" : // Name list - case "366" : // End-of-Name list marker - case "372" : // MOTD body - case "375" : // MOTD start + case "042": + case "250": + case "251": + case "252": + case "254": + case "255": + case "265": + case "266": + case "332": // Subject + case "333": // Subject owner (?) + case "353": // Name list + case "366": // End-of-Name list marker + case "372": // MOTD body + case "375": // MOTD start // m_log.InfoFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]); break; - case "376" : // MOTD end + case "376": // MOTD end // m_log.InfoFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]); motd = true; break; - case "451" : // Not registered + case "451": // Not registered break; - case "433" : // Nickname in use + case "433": // Nickname in use // Gen a new name m_nick = m_baseNick + Util.RandomClass.Next(1, 99); m_log.ErrorFormat("[IRC-Connector-{0}]: [{1}] IRC SERVER reports NicknameInUse, trying {2}", idn, cmd, m_nick); @@ -695,29 +702,29 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel)); m_writer.Flush(); break; - case "479" : // Bad channel name, etc. This will never work, so disable the connection - m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]); + case "479": // Bad channel name, etc. This will never work, so disable the connection + m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE, 2)[1]); m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] Connector disabled", idn, cmd); - m_enabled = false; + m_enabled = false; m_connected = false; - m_pending = false; + m_pending = false; break; - case "NOTICE" : + case "NOTICE": // m_log.WarnFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]); break; - case "ERROR" : - m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]); + case "ERROR": + m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE, 2)[1]); if (parms.Contains("reconnect too fast")) ICCD_PERIOD++; - m_pending = false; + m_pending = false; Reconnect(); break; - case "PING" : + case "PING": m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); m_writer.WriteLine(String.Format("PONG {0}", parms)); m_writer.Flush(); break; - case "PONG" : + case "PONG": break; case "JOIN": if (m_pending) @@ -748,19 +755,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); eventIrcQuit(pfx, cmd, parms); break; - default : + default: m_log.DebugFormat("[IRC-Connector-{0}] Command '{1}' ignored, parms = {2}", idn, cmd, parms); break; } // m_log.DebugFormat("[IRC-Connector-{0}] prefix = <{1}> cmd = <{2}> complete", idn, pfx, cmd); - + } public void eventIrcJoin(string prefix, string command, string parms) { - string[] args = parms.Split(CS_SPACE,2); - string IrcUser = prefix.Split('!')[0]; + string[] args = parms.Split(CS_SPACE, 2); + string IrcUser = prefix.Split('!')[0]; string IrcChannel = args[0]; if (IrcChannel.StartsWith(":")) @@ -772,8 +779,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void eventIrcPart(string prefix, string command, string parms) { - string[] args = parms.Split(CS_SPACE,2); - string IrcUser = prefix.Split('!')[0]; + string[] args = parms.Split(CS_SPACE, 2); + string IrcUser = prefix.Split('!')[0]; string IrcChannel = args[0]; m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCPart {1}:{2}", idn, m_server, m_ircChannel); @@ -782,7 +789,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void eventIrcMode(string prefix, string command, string parms) { - string[] args = parms.Split(CS_SPACE,2); + string[] args = parms.Split(CS_SPACE, 2); string UserMode = args[1]; m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCMode {1}:{2}", idn, m_server, m_ircChannel); @@ -794,7 +801,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void eventIrcNickChange(string prefix, string command, string parms) { - string[] args = parms.Split(CS_SPACE,2); + string[] args = parms.Split(CS_SPACE, 2); string UserOldNick = prefix.Split('!')[0]; string UserNewNick = args[0].Remove(0, 1); @@ -804,11 +811,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void eventIrcKick(string prefix, string command, string parms) { - string[] args = parms.Split(CS_SPACE,3); - string UserKicker = prefix.Split('!')[0]; - string IrcChannel = args[0]; - string UserKicked = args[1]; - string KickMessage = args[2]; + string[] args = parms.Split(CS_SPACE, 3); + string UserKicker = prefix.Split('!')[0]; + string IrcChannel = args[0]; + string UserKicked = args[1]; + string KickMessage = args[2]; m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCKick {1}:{2}", idn, m_server, m_ircChannel); BroadcastSim(UserKicker, "/me kicks kicks {0} off {1} saying \"{2}\"", UserKicked, IrcChannel, KickMessage); @@ -822,7 +829,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat public void eventIrcQuit(string prefix, string command, string parms) { - string IrcUser = prefix.Split('!')[0]; + string IrcUser = prefix.Split('!')[0]; string QuitMessage = parms; m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCQuit {1}:{2}", idn, m_server, m_ircChannel); @@ -842,65 +849,65 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // m_log.InfoFormat("[IRC-Watchdog] Status scan, pdk = {0}, icc = {1}", _pdk_, _icc_); - _pdk_ = (_pdk_+1)%PING_PERIOD; // cycle the ping trigger + _pdk_ = (_pdk_ + 1) % PING_PERIOD; // cycle the ping trigger _icc_++; // increment the inter-consecutive-connect-delay counter lock (m_connectors) - foreach (IRCConnector connector in m_connectors) - { + foreach (IRCConnector connector in m_connectors) + { - // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector); + // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector); - if (connector.Enabled) - { - if (!connector.Connected) + if (connector.Enabled) { - try + if (!connector.Connected) { - // m_log.DebugFormat("[IRC-Watchdog] Connecting {1}:{2}", connector.idn, connector.m_server, connector.m_ircChannel); - connector.Connect(); + try + { + // m_log.DebugFormat("[IRC-Watchdog] Connecting {1}:{2}", connector.idn, connector.m_server, connector.m_ircChannel); + connector.Connect(); + } + catch (Exception e) + { + m_log.ErrorFormat("[IRC-Watchdog] Exception on connector {0}: {1} ", connector.idn, e.Message); + } } - catch (Exception e) + else { - m_log.ErrorFormat("[IRC-Watchdog] Exception on connector {0}: {1} ", connector.idn, e.Message); - } - } - else - { - if (connector.m_pending) - { - if (connector.m_timeout == 0) + if (connector.m_pending) { - m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); - connector.Reconnect(); + if (connector.m_timeout == 0) + { + m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); + connector.Reconnect(); + } + else + connector.m_timeout--; } - else - connector.m_timeout--; - } - // Being marked connected is not enough to ping. Socket establishment can sometimes take a long - // time, in which case the watch dog might try to ping the server before the socket has been - // set up, with nasty side-effects. + // Being marked connected is not enough to ping. Socket establishment can sometimes take a long + // time, in which case the watch dog might try to ping the server before the socket has been + // set up, with nasty side-effects. - else if (_pdk_ == 0) - { - try - { - connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server)); - connector.m_writer.Flush(); - } - catch (Exception e) + else if (_pdk_ == 0) { - m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message); - m_log.Debug(e); - connector.Reconnect(); + try + { + connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server)); + connector.m_writer.Flush(); + } + catch (Exception e) + { + m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message); + m_log.Debug(e); + connector.Reconnect(); + } } - } + } } } - } // m_log.InfoFormat("[IRC-Watchdog] Status scan completed"); diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs index 53b103e..d4fe5e0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs @@ -41,49 +41,71 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat internal class RegionState { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly OpenMetaverse.Vector3 CenterOfRegion = new OpenMetaverse.Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); - private const int DEBUG_CHANNEL = 2147483647; + private const int DEBUG_CHANNEL = 2147483647; - private static int _idk_ = 0; + private static int _idk_ = 0; // Runtime variables; these values are assigned when the // IrcState is created and remain constant thereafter. - internal string Region = String.Empty; - internal string Host = String.Empty; - internal string LocX = String.Empty; - internal string LocY = String.Empty; - internal string IDK = String.Empty; + internal string Region = String.Empty; + internal string Host = String.Empty; + internal string LocX = String.Empty; + internal string LocY = String.Empty; + internal string IDK = String.Empty; // System values - used only be the IRC classes themselves - internal ChannelState cs = null; // associated IRC configuration - internal Scene scene = null; // associated scene - internal IConfig config = null; // configuration file reference - internal bool enabled = true; - + internal ChannelState cs = null; // associated IRC configuration + internal Scene scene = null; // associated scene + internal IConfig config = null; // configuration file reference + internal bool enabled = true; + + //AgentAlert + internal bool showAlert = false; + internal string alertMessage = String.Empty; + internal IDialogModule dialogModule = null; + // This list is used to keep track of who is here, and by // implication, who is not. - internal List clients = new List(); + internal List clients = new List(); // Setup runtime variable values public RegionState(Scene p_scene, IConfig p_config) { - - scene = p_scene; + scene = p_scene; config = p_config; Region = scene.RegionInfo.RegionName; - Host = scene.RegionInfo.ExternalHostName; - LocX = Convert.ToString(scene.RegionInfo.RegionLocX); - LocY = Convert.ToString(scene.RegionInfo.RegionLocY); - IDK = Convert.ToString(_idk_++); + Host = scene.RegionInfo.ExternalHostName; + LocX = Convert.ToString(scene.RegionInfo.RegionLocX); + LocY = Convert.ToString(scene.RegionInfo.RegionLocY); + IDK = Convert.ToString(_idk_++); + + showAlert = config.GetBoolean("alert_show", false); + string alertServerInfo = String.Empty; + + if (showAlert) + { + bool showAlertServerInfo = config.GetBoolean("alert_show_serverinfo", true); + + if (showAlertServerInfo) + alertServerInfo = String.Format("\nServer: {0}\nPort: {1}\nChannel: {2}\n\n", + config.GetString("server", ""), config.GetString("port", ""), config.GetString("channel", "")); + + string alertPreMessage = config.GetString("alert_msg_pre", "This region is linked to Irc."); + string alertPostMessage = config.GetString("alert_msg_post", "Everything you say in public chat can be listened."); + + alertMessage = String.Format("{0}\n{1}{2}", alertPreMessage, alertServerInfo, alertPostMessage); + + dialogModule = scene.RequestModuleInterface(); + } // OpenChannel conditionally establishes a connection to the // IRC server. The request will either succeed, or it will @@ -93,9 +115,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // Connect channel to world events - scene.EventManager.OnChatFromWorld += OnSimChat; + scene.EventManager.OnChatFromWorld += OnSimChat; scene.EventManager.OnChatFromClient += OnSimChat; - scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; + scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; m_log.InfoFormat("[IRC-Region {0}] Initialization complete", Region); @@ -106,8 +128,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat ~RegionState() { - if (cs != null) - cs.RemoveRegion(this); + if (cs != null) + cs.RemoveRegion(this); } // Called by PostInitialize after all regions have been created @@ -138,7 +160,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { if (clients.Contains(client)) { - 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); //Check if this person is excluded from IRC @@ -147,7 +169,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat 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; clients.Remove(client); } @@ -171,13 +193,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { if (clients.Contains(client)) { - if (enabled && (cs.irc.Enabled) && (cs.irc.Connected) && (cs.ClientReporting)) + if (enabled && (cs.irc.Enabled) && (cs.irc.Connected) && (cs.ClientReporting)) { string clientName = String.Format("{0} {1}", presence.Firstname, presence.Lastname); m_log.DebugFormat("[IRC-Region {0}] {1} has left", Region, clientName); cs.irc.PrivMsg(cs.NoticeMessageFormat, cs.irc.Nick, Region, String.Format("{0} has left", clientName)); } - client.OnLogout -= OnClientLoggedOut; + client.OnLogout -= OnClientLoggedOut; client.OnConnectionClosed -= OnClientLoggedOut; clients.Remove(client); } @@ -195,14 +217,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat private void OnMakeRootAgent(ScenePresence presence) { - IClientAPI client = presence.ControllingClient; try { if (!clients.Contains(client)) { - client.OnLogout += OnClientLoggedOut; + client.OnLogout += OnClientLoggedOut; client.OnConnectionClosed += OnClientLoggedOut; clients.Add(client); if (enabled && (cs.irc.Enabled) && (cs.irc.Connected) && (cs.ClientReporting)) @@ -216,17 +237,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat } } } + + if (dialogModule != null && showAlert) + dialogModule.SendAlertToUser(client, alertMessage, true); } catch (Exception ex) { m_log.ErrorFormat("[IRC-Region {0}]: MakeRootAgent exception: {1}", Region, ex.Message); m_log.Debug(ex); } - } // This handler detects chat events int he virtual world. - public void OnSimChat(Object sender, OSChatMessage msg) { @@ -317,14 +339,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat // that evident. default: - m_log.DebugFormat("[IRC-Region {0}] Forwarding unrecognized command to IRC : {1}", + m_log.DebugFormat("[IRC-Region {0}] Forwarding unrecognized command to IRC : {1}", Region, msg.Message); cs.irc.Send(msg.Message); break; } } catch (Exception ex) - { + { m_log.WarnFormat("[IRC-Region {0}] error processing in-world command channel input: {1}", Region, ex.Message); m_log.Debug(ex); @@ -366,7 +388,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.DebugFormat("[IRC-Region {0}] heard on channel {1} : {2}", Region, msg.Channel, msg.Message); - if (null != avatar && cs.RelayChat && (msg.Channel == 0 || msg.Channel == DEBUG_CHANNEL)) + if (null != avatar && cs.RelayChat && (msg.Channel == 0 || msg.Channel == DEBUG_CHANNEL)) { string txt = msg.Message; if (txt.StartsWith("/me ")) @@ -376,13 +398,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat return; } - if (null == avatar && cs.RelayPrivateChannels && null != cs.AccessPassword && + if (null == avatar && cs.RelayPrivateChannels && null != cs.AccessPassword && msg.Channel == cs.RelayChannelOut) { Match m = cs.AccessPasswordRegex.Match(msg.Message); if (null != m) { - m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(), + m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(), m.Groups["message"].ToString()); cs.irc.PrivMsg(cs.PrivateMessageFormat, m.Groups["avatar"].ToString(), scene.RegionInfo.RegionName, m.Groups["message"].ToString()); -- cgit v1.1