public static void ProcessCommand(string command, Stream io, int security, string user, Encoding encoding)
{
if (String.IsNullOrWhiteSpace(command))
{
return;
}
try
{
byte[] writebuffer;
var cmdsplit = command.Split(' ');
if (cmdsplit.Length < 1) return;
var label = cmdsplit[0];
if (SBWAPI.PluginManager.Default.ProcessCommand(label, command, io, security, user, encoding)) return;
if (command.StartsWith("#"))
{
if (security < 4)
{
writebuffer =
encoding.GetBytes(
"\u001B[31mYou do not have permission to send special commands\u001B[0m\r\n");
io.Write(writebuffer, 0, writebuffer.Length);
return;
}
if (CommandProcessors.ContainsKey(label))
CommandProcessors[label](command, io, security, user, encoding);
return;
}
if (command.StartsWith("/"))
{
if (security < 3)
{
writebuffer = encoding.GetBytes(
"\u001B[31mYou do not have permission to send commands\u001B[0m\r\n");
io.Write(writebuffer, 0, writebuffer.Length);
return;
}
if (CommandProcessors.ContainsKey(label))
CommandProcessors[label](command, io, security, user, encoding);
else
{
ServerHandler.ProcessHandler.ExtOutput(string.Format("<{0}> {1}", user, command));
ServerHandler.ProcessHandler.Instance.Command(command.Remove(0, 1));
}
return;
}
CommandProcessors["\uFFFF"](command, io, security, user, encoding);
}
catch
{
}
}