From bb5dd9fbbc39d2023c29ecc9deecd06523c7e467 Mon Sep 17 00:00:00 2001 From: Marck Date: Tue, 17 Aug 2010 20:54:51 +0200 Subject: Some code cleanup for console command alert. Made parsing of parameters more robust. Allow general alerts without specifying keyword 'general'. Extended help texts. --- .../CoreModules/Avatar/Dialog/DialogModule.cs | 52 ++++++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 2105f3c..2b3d2a9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -51,10 +51,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog m_scene.RegisterModuleInterface(this); m_scene.AddCommand( - this, "alert", "alert ", "Send an alert to a user", HandleAlertConsoleCommand); + this, "alert", "alert ", + "Send an alert to a user", + HandleAlertConsoleCommand); m_scene.AddCommand( - this, "alert general", "alert general ", "Send an alert to everyone", HandleAlertConsoleCommand); + this, "alert general", "alert [general] ", + "Send an alert to everyone", + "If keyword 'general' is omitted, then must be surrounded by quotation marks.", + HandleAlertConsoleCommand); } public void PostInitialise() {} @@ -173,20 +178,49 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) return; - if (cmdparams[1] == "general") + bool isGeneral = false; + string firstName = string.Empty; + string lastName = string.Empty; + string message = string.Empty; + + if (cmdparams.Length > 1) + { + firstName = cmdparams[1]; + isGeneral = firstName.ToLower().Equals("general"); + } + if (cmdparams.Length == 2 && !isGeneral) + { + // alert "message" + message = cmdparams[1]; + isGeneral = true; + } + else if (cmdparams.Length > 2 && isGeneral) + { + // alert general + message = CombineParams(cmdparams, 2); + } + else if (cmdparams.Length > 3) { - string message = CombineParams(cmdparams, 2); + // alert + lastName = cmdparams[2]; + message = CombineParams(cmdparams, 3); + } + else + { + OpenSim.Framework.Console.MainConsole.Instance.Output( + "Usage: alert \"message\" | alert general | alert "); + return; + } + if (isGeneral) + { m_log.InfoFormat( - "[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message); + "[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); -- cgit v1.1 From 86a61696d714f92264528a51486c9dce7840a9bb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 20 Aug 2010 17:58:02 +0100 Subject: minor: remove mono compiler warning --- .../CoreModules/InterGrid/OpenGridProtocolModule.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 87a0a8d..fd0e879 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.InterGrid bool enabled = false; IConfig cfg = null; IConfig httpcfg = null; - IConfig startupcfg = null; +// IConfig startupcfg = null; try { cfg = config.Configs["OpenGridProtocol"]; @@ -117,14 +117,14 @@ namespace OpenSim.Region.CoreModules.InterGrid { } - try - { - startupcfg = config.Configs["Startup"]; - } - catch (NullReferenceException) - { - - } +// try +// { +// startupcfg = config.Configs["Startup"]; +// } +// catch (NullReferenceException) +// { +// +// } // if (startupcfg != null) // { -- cgit v1.1