예제 #1
0
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            switch (Command)
            {
            case "on":
                if (Bot.DisplayMessages)
                {
                    Bot.IrcClient.LocalUser.SendMessage(Admin, "IRC echo is already on!.");
                }
                else
                {
                    Bot.DisplayMessages = true;
                    Bot.IrcClient.LocalUser.SendMessage(Admin, "Set IRC echo on.");
                }
                break;

            case "off":
                if (!Bot.DisplayMessages)
                {
                    Bot.IrcClient.LocalUser.SendMessage(Admin, "IRC echo is already off!.");
                }
                else
                {
                    Bot.DisplayMessages = false;
                    Bot.IrcClient.LocalUser.SendMessage(Admin, "Set IRC echo off.");
                }
                break;

            default:
                Bot.IrcClient.LocalUser.SendMessage(Admin, "Echo is currently " + (Bot.DisplayMessages ? "on" : "off"));
                break;
            }

            return(true);
        }
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            Bot.UserRegCheck(Command);
            Bot.IrcClient.LocalUser.SendMessage(Admin, "Performing reg check on " + Command);

            return(true);
        }
예제 #3
0
        static void Main(string[] args)
        {
            // run as console app
            if (Environment.UserInteractive)
            {
                IRCBotClient ircBot = new IRCBotClient();

                // start it
                ircBot.Start(true);
            }

            // run as windows service
            else
            {
                // set workpath to .exe path (not default for services)
                // very important
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                // create bot-service wrapper
                ServiceBase serviceWrap =
                    new BotServiceWrapper <GameTick, ResourceManager, DataController, IRCBotConfig, IRCBotClient>();

                // run service
                ServiceBase.Run(serviceWrap);
            }
        }
예제 #4
0
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            Bot.IrcClient.LocalUser.SendMessage(Admin, Command
                                                + (Bot.IsUserRegistered(Command) ? " is registered." : " is not registered."));

            return(true);
        }
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandHelp.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandCheckReg.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandRegister.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandList.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandAdd.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandRemove.HELPSTRING);
            Bot.IrcClient.LocalUser.SendMessage(Admin, IRCAdminBotCommandEcho.HELPSTRING);

            return(true);
        }
예제 #6
0
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            if (Bot.Config.AllowedUsers.Contains(Command))
            {
                Bot.Config.AllowedUsers.Remove(Command);
                Bot.IrcClient.LocalUser.SendMessage(Admin, "Removed " + Command + " as a bot user.");
            }
            else
            {
                Bot.IrcClient.LocalUser.SendMessage(Admin, "Could not find " + Command + " in bot user list.");
            }

            return(true);
        }
예제 #7
0
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            if (!Bot.Config.AllowedUsers.Contains(Command))
            {
                Bot.Config.AllowedUsers.Add(Command);
                Bot.IrcClient.LocalUser.SendMessage(Admin, "Added " + Command + " as a bot user.");
            }
            else
            {
                Bot.IrcClient.LocalUser.SendMessage(Admin, Command + " is already on the bot user list.");
            }

            return(true);
        }
예제 #8
0
        public static bool ParseAdminCommand(string Admin, string Command, IRCBotClient Bot)
        {
            string[] splitCommand = Command.Split(' ');

            IRCAdminBotCommand botCommand = null;

            switch (splitCommand[0])
            {
            case IRCAdminBotCommandHelp.COMMAND:
                botCommand = new IRCAdminBotCommandHelp();
                break;

            case IRCAdminBotCommandCheckReg.COMMAND:
                botCommand = new IRCAdminBotCommandCheckReg();
                break;

            case IRCAdminBotCommandRegister.COMMAND:
                botCommand = new IRCAdminBotCommandRegister();
                break;

            case IRCAdminBotCommandList.COMMAND:
                botCommand = new IRCAdminBotCommandList();
                break;

            case IRCAdminBotCommandAdd.COMMAND:
                botCommand = new IRCAdminBotCommandAdd();
                break;

            case IRCAdminBotCommandRemove.COMMAND:
                botCommand = new IRCAdminBotCommandRemove();
                break;

            case IRCAdminBotCommandEcho.COMMAND:
                botCommand = new IRCAdminBotCommandEcho();
                break;
            }

            if (botCommand == null)
            {
                return(false);
            }

            return(botCommand.PerformCommand(Admin, Command.Substring(splitCommand[0].Length).TrimStart(' '), Bot));
        }
예제 #9
0
        static void Main(string[] args)
        {
            string configFile    = Config.CONFIGFILE;
            string configFileAlt = Config.CONFIGFILE_ALT;

            // try parse config parameter
            string cmdConfig = Config.GetFilenameFromCmdArgs(args);

            // overwrite with user specified config
            if (cmdConfig != null)
            {
                configFile = configFileAlt = cmdConfig;
            }

            // run as console app
            if (Environment.UserInteractive)
            {
                IRCBotClient ircBot = new IRCBotClient();

                // start it
                ircBot.Start(true, configFile, configFileAlt);
            }

            // run as windows service
            else
            {
                // set workpath to .exe path (not default for services)
                // very important
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

                // create bot-service wrapper
                ServiceBase serviceWrap =
                    new BotServiceWrapper <GameTick, ResourceManager, DataController, IRCBotConfig, IRCBotClient>(
                        configFile, configFileAlt);

                // run service
                ServiceBase.Run(serviceWrap);
            }
        }
        /// <summary>
        /// Performs command
        /// </summary>
        /// <returns></returns>
        public override bool PerformCommand(string Admin, string Command, IRCBotClient Bot)
        {
            switch (Command)
            {
            case "admins":
                Bot.IrcClient.LocalUser.SendMessage(Admin,
                                                    "Bot admins: " + string.Join(", ", Bot.Config.Admins));
                return(true);

            case "users":
                Bot.IrcClient.LocalUser.SendMessage(Admin,
                                                    "Bot users: " + string.Join(", ", Bot.Config.AllowedUsers));
                return(true);

            case "registered":
                Bot.IrcClient.LocalUser.SendMessage(Admin,
                                                    "Registered users: " + string.Join(", ", Bot.UserRegistration.Keys));
                return(true);
            }

            return(false);
        }
예제 #11
0
 public abstract bool PerformCommand(string Admin, string Command, IRCBotClient Bot);