Exemple #1
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            // make !status display various stats of the bot and the current state of all slaves and their friendslists, also include links to relog etc
            switch (e.Command)
            {
            case "shutdown":
                bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Shutting Down");
                bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Shutting Down", AoLib.Net.PacketQueue.Priority.Urgent, true);
                bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Shutting Down");
                System.Threading.Thread.Sleep(1000);
                bot.Shutdown();
                break;

            case "restart":
                if (!bot.CoreConnected)
                {
                    bot.SendReply(e, "Restart is not available");
                    return;
                }
                bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Rebooting");
                bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Rebooting", AoLib.Net.PacketQueue.Priority.Urgent, true);
                bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Rebooting");
                System.Threading.Thread.Sleep(1000);
                bot.Restart();
                break;

            case "core":
                this.OnCoreCommand(bot, e);
                break;

            case "core shutdown":
            case "core start":
            case "core restart":
                if (e.Args.Length < 1 || !e.Args[0].Contains("@"))
                {
                    bot.SendReply(e, "Usage: " + e.Command + " [bot@dimension]");
                    return;
                }
                if (!bot.Master)
                {
                    bot.SendReply(e, "This bot is not a master bot");
                    return;
                }
                CoreCommand command;
                if (e.Command == "core shutdown")
                {
                    command = CoreCommand.Shutdown;
                }
                else if (e.Command == "core start")
                {
                    command = CoreCommand.Start;
                }
                else
                {
                    command = CoreCommand.Restart;
                }
                MessageResult result = bot.SendCoreMessage(this.InternalName, e.Args[0].ToLower(), command);
                switch (result)
                {
                case MessageResult.Success:
                    bot.SendReply(e, "Your command has been relayed to the core and will be executed shortly");
                    break;

                case MessageResult.InvalidTarget:
                    bot.SendReply(e, "The target you specified appeared to be invalid");
                    break;

                case MessageResult.NotConnected:
                    bot.SendReply(e, "Unable to connect to the core in order to issue this command");
                    break;

                default:
                    bot.SendReply(e, "An unknown error prevented your command from being executed");
                    break;
                }
                break;

            case "core clean":
                bot.Clean();
                bot.SendReply(e, "Memory cleaning routines have been executed");
                break;
            }
        }