Ejemplo n.º 1
0
 public Command(VirtualServer _server, string _name, Action <ServerMessage, string> _cmd, PrivilegeLevel _priv, HelpMsgStrings _helpmessage)
 {
     server      = _server;
     name        = _name;
     helpmessage = _helpmessage;
     priv        = _priv;
     cmd         = _cmd;
 }
        public WelcomeMessageCommandHandler(VirtualServer _server, string _command, HelpMsgStrings _helpmsgstring) : base(_server)
        {
            command       = _command;
            helpmsgstring = _helpmsgstring;
            string message = String.Join("\n", server.FileSetup(command + ".txt"));

            if (message == String.Empty)
            {
                wmls = new WelcomeMessage("Welcome " + WelcomeMessageId.raw);
            }
            else
            {
                var split = message.Split("\n".ToArray(), 2);
                if (split.Length == 2)
                {
                    if (split[0] == "on")
                    {
                        on = true;
                    }
                    else if (split[0] == "off")
                    {
                        on = false;
                    }
                    else
                    {
                        Console.WriteLine("Welcome message in corrupted format: " + message);
                    }

                    wmls = new WelcomeMessage(split[1]);
                }
                else
                {
                    wmls = new WelcomeMessage("Welcome " + WelcomeMessageId.raw);
                }
            }
        }
Ejemplo n.º 3
0
        protected Command makeEnableableAdminCommand(string name, Action <ServerMessage, string> cmd, HelpMsgStrings helpmsgstrings)
        {
            Action <ServerMessage, string> f = (x, y) => { if (!on)
                                                           {
                                                               server.safeSendMessage(x.Channel, module_name + " module is not enabled."); return;
                                                           }
                                                           ; cmd(x, y); };

            return(Command.AdminCommand(server, name, f, helpmsgstrings));
        }
Ejemplo n.º 4
0
        protected Command makeEnableableCommand(string name, Action <ServerMessage, string> cmd, PrivilegeLevel priv, HelpMsgStrings helpmsgstrings)
        {
            Action <ServerMessage, string> f = (x, y) => { if (!on)
                                                           {
                                                               return;
                                                           }
                                                           cmd(x, y); };

            return(new Command(server, name, f, priv, helpmsgstrings));
        }
Ejemplo n.º 5
0
 public static Command AdminCommand(VirtualServer _server, string _name, Action <ServerMessage, String> _cmd, HelpMsgStrings _helpmessage)
 {
     return(new Command(_server, _name, _cmd, PrivilegeLevel.BotAdmin, _helpmessage));
 }