Changed console command "alert" and added new command "alert-user".

This addresses Mantis #4709.
Command "alert" always sends a message to everybody; the variant "alert general" has been removed. Sending messages to one user is done with the dedicated command "alert-user".
0.7.1-dev
Marck 2011-02-16 18:34:44 +01:00
parent 5c15c5e0ff
commit 25265c964f
1 changed files with 18 additions and 42 deletions

View File

@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
{ {
m_scene = scene; m_scene = scene;
m_scene.RegisterModuleInterface<IDialogModule>(this); m_scene.RegisterModuleInterface<IDialogModule>(this);
m_scene.AddCommand( m_scene.AddCommand(
this, "alert", "alert <first> <last> <message>", this, "alert", "alert <message>",
"Send an alert to a user", "Send an alert to everyone",
HandleAlertConsoleCommand); HandleAlertConsoleCommand);
m_scene.AddCommand( m_scene.AddCommand(
this, "alert general", "alert [general] <message>", this, "alert-user", "alert-user <first> <last> <message>",
"Send an alert to everyone", "Send an alert to a user",
"If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.",
HandleAlertConsoleCommand); HandleAlertConsoleCommand);
} }
@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
{ {
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
return; return;
bool isGeneral = false;
string firstName = string.Empty;
string lastName = string.Empty;
string message = string.Empty; string message = string.Empty;
if (cmdparams.Length > 1) if (cmdparams[0].ToLower().Equals("alert"))
{ {
firstName = cmdparams[1]; message = CombineParams(cmdparams, 1);
isGeneral = firstName.ToLower().Equals("general"); m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
} m_scene.RegionInfo.RegionName, message);
if (cmdparams.Length == 2 && !isGeneral) SendGeneralAlert(message);
{
// alert "message"
message = cmdparams[1];
isGeneral = true;
}
else if (cmdparams.Length > 2 && isGeneral)
{
// alert general <message>
message = CombineParams(cmdparams, 2);
} }
else if (cmdparams.Length > 3) else if (cmdparams.Length > 3)
{ {
// alert <first> <last> <message> string firstName = cmdparams[1];
lastName = cmdparams[2]; string lastName = cmdparams[2];
message = CombineParams(cmdparams, 3); 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);
} }
else else
{ {
OpenSim.Framework.Console.MainConsole.Instance.Output( OpenSim.Framework.Console.MainConsole.Instance.Output(
"Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); "Usage: alert <message> | alert-user <first> <last> <message>");
return; return;
} }
if (isGeneral)
{
m_log.InfoFormat(
"[DIALOG]: Sending general alert in region {0} with message {1}",
m_scene.RegionInfo.RegionName, message);
SendGeneralAlert(message);
}
else
{
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) private string CombineParams(string[] commandParams, int pos)