From d307109e1af20c5b1b27743853236d7842d871f0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 13 Feb 2009 19:03:18 +0000 Subject: * refactor: move alert commands from Scene to DialogModule --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 3fe57bc..6dd020a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -26,6 +26,8 @@ */ using System.Collections.Generic; +using System.Reflection; +using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -36,7 +38,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { public class DialogModule : IRegionModule, IDialogModule { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_scene; @@ -44,6 +46,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog { m_scene = scene; m_scene.RegisterModuleInterface(this); + + m_scene.AddCommand( + this, "alert", "alert ", "Send an alert to a user", HandleAlertConsoleCommand); + + m_scene.AddCommand( + this, "alert general", "alert general ", "Send an alert to everyone", HandleAlertConsoleCommand); } public void PostInitialise() {} @@ -137,5 +145,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); } } + + /// + /// Handle an alert command from the console. + /// + /// + /// + public void HandleAlertConsoleCommand(string module, string[] cmdparams) + { + if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) + return; + + if (cmdparams[1] == "general") + { + string message = CombineParams(cmdparams, 2); + + m_log.InfoFormat( + "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); + SendGeneralAlert(message); + } + else + { + string firstName = cmdparams[1]; + string lastName = cmdparams[2]; + string message = CombineParams(cmdparams, 3); + + m_log.InfoFormat( + "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", + m_scene.RegionInfo.RegionName, firstName, lastName, message); + SendAlertToUser(firstName, lastName, message, false); + } + } + + private string CombineParams(string[] commandParams, int pos) + { + string result = string.Empty; + for (int i = pos; i < commandParams.Length; i++) + { + result += commandParams[i] + " "; + } + + return result; + } } } -- cgit v1.1