示例#1
0
        private void OnServerCommand(BotShell bot, CommandArgs e)
        {
            bot.SendReply(e, "Server Status »» Gathering Data...");

            ServerStatusResult server = XML.GetServerStatus();

            if (server == null || server.Dimensions == null)
            {
                bot.SendReply(e, "Unable to gather server information " + this.TimeoutError);
                return;
            }
            ServerStatusResult_Dimension dimension = server.GetDimension(bot.Dimension);
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Server Information");

            window.AppendHighlight("Server Manager: ");
            if (dimension.ServerManager.Online)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, "Online");
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, "Offline");
            }
            window.AppendLineBreak();

            window.AppendHighlight("Client Manager: ");
            if (dimension.ClientManager.Online)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, "Online");
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, "Offline");
            }
            window.AppendLineBreak();

            window.AppendHighlight("Chat Server: ");
            if (dimension.ChatServer.Online)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, "Online");
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, "Offline");
            }
            window.AppendLineBreak(2);

            window.AppendHeader("Alignment");
            window.AppendHighlight("Clan: ");
            window.AppendNormal(dimension.Distribution.Clan.Percent + "%");
            window.AppendLineBreak();
            window.AppendHighlight("Neutral: ");
            window.AppendNormal(dimension.Distribution.Neutral.Percent + "%");
            window.AppendLineBreak();
            window.AppendHighlight("Omni: ");
            window.AppendNormal(dimension.Distribution.Omni.Percent + "%");
            window.AppendLineBreak(2);

            foreach (ServerStatusResult_Playfield pf in dimension.Playfields)
            {
                bool skip = false;
                foreach (string arg in e.Args)
                {
                    if (!pf.Name.ToLower().Contains(arg.ToLower()))
                    {
                        skip = true;
                    }
                }

                if (skip)
                {
                    continue;
                }

                switch (pf.Status)
                {
                case PlayfieldStatus.Online:
                    window.AppendImage("GFX_GUI_FRIENDLIST_STATUS_GREEN");
                    break;

                default:
                    window.AppendImage("GFX_GUI_FRIENDLIST_STATUS_RED");
                    break;
                }
                window.AppendNormalStart();
                window.AppendString(" ");
                window.AppendColorStart(RichTextWindow.ColorGreen);
                double players = 0;
                while (players <= pf.Players && players <= 8 && pf.Players != 0)
                {
                    players += 0.5;
                    window.AppendString("l");
                }
                window.AppendColorEnd();
                while (players <= 8)
                {
                    players += 0.5;
                    window.AppendString("l");
                }
                window.AppendString(" ");
                window.AppendColorEnd();

                window.AppendHighlight(pf.Name);
                window.AppendNormal(string.Format(" (ID: {0} Players: {1}%)", pf.ID, pf.Players));
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Server Status »» ", window);
        }
示例#2
0
        private void OnCommandsMapCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Commands Map");
            window.AppendNormal("This is a map of all commands currently available on this bot.");
            window.AppendLineBreak();
            window.AppendNormal("The commands are listed in the following format: [command] ([tell] [pg] [org] / [default tell] [default pg] [default org])");
            window.AppendLineBreak();
            window.AppendNormal("The letters represent the required userlevel you need for the command.");
            window.AppendLineBreak();
            window.AppendNormal("The color of the command represents whether the command has help or not. Red means there is no help available. Orange means there should be help available but this command was unable to retrieve it. Green means there is help available.");
            window.AppendLineBreak(2);

            foreach (string plugin in bot.Plugins.GetLoadedPlugins())
            {
                string[]     commands = bot.Commands.GetCommands(plugin);
                PluginLoader loader   = bot.Plugins.GetLoader(plugin);
                window.AppendHeader(loader.ToString());
                if (commands.Length > 0)
                {
                    foreach (string command in commands)
                    {
                        CommandRights rights = bot.Commands.GetRights(command);
                        if (rights.Help)
                        {
                            if (bot.Commands.GetHelp(command) != string.Empty)
                            {
                                window.AppendColorStart(RichTextWindow.ColorGreen);
                            }
                            else
                            {
                                window.AppendColorStart(RichTextWindow.ColorOrange);
                            }
                        }
                        else
                        {
                            window.AppendColorStart(RichTextWindow.ColorRed);
                        }
                        window.AppendString(Format.UppercaseFirst(command));
                        window.AppendColorEnd();

                        string tell = rights.PrivateMessage.ToString().Substring(0, 1).ToUpper();
                        string pg   = rights.PrivateChannel.ToString().Substring(0, 1).ToUpper();
                        string org  = rights.Organization.ToString().Substring(0, 1).ToUpper();
                        rights = bot.Commands.GetDefaultRights(command);
                        string d_tell = rights.PrivateMessage.ToString().Substring(0, 1).ToUpper();
                        string d_pg   = rights.PrivateChannel.ToString().Substring(0, 1).ToUpper();
                        string d_org  = rights.Organization.ToString().Substring(0, 1).ToUpper();

                        window.AppendNormal(" (" + tell + pg + org + "/" + d_tell + d_pg + d_org + ")");
                        window.AppendLineBreak();
                    }
                }
                else
                {
                    window.AppendNormal("No commands available");
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Commands Map »» ", window);
        }