예제 #1
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            lock (this._database.Connection)
            {
                using (IDbCommand command = this._database.Connection.CreateCommand())
                {
                    command.CommandText = "SELECT title, rule FROM rules WHERE visible = 'true'";
                    IDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        window.AppendHeader(reader.GetString(0));
                        string rule = reader.GetString(1);
                        rule = rule.Replace("[b]", bot.ColorNormal);
                        rule = rule.Replace("[/b]", HTML.CreateColorEnd());
                        window.AppendHighlightStart();
                        window.AppendRawString(rule);
                        window.AppendColorEnd();
                        window.AppendLineBreak(2);
                    }
                    reader.Close();
                }
            }
            bot.SendReply(e, "Rules »» ", window);
        }
예제 #2
0
        private void RequestSbState(BotShell bot, string user)
        {
            ShadowbreedState state;

            lock (this.Shadowbreeds)
            {
                if (!this.Shadowbreeds.ContainsKey(user.ToLower()))
                {
                    return;
                }
                state = this.Shadowbreeds[user.ToLower()];
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Shadowbreed");

            window.AppendHighlight("Intro");
            window.AppendLineBreak();
            window.AppendNormal("You have been requested to set your Shadowbreed state.");
            window.AppendLineBreak();
            window.AppendNormal("Your current Shadowbreed state is: ");
            window.AppendRawString(this.ColorizeState(state));
            window.AppendLineBreak();
            window.AppendNormal("Please select one of the following states that best suits your situation.");
            window.AppendLineBreak(2);

            window.AppendHighlight("Up ");
            window.AppendNormal("[");
            window.AppendBotCommand("Set", "sb set " + user + " up");
            window.AppendNormal("] ");
            window.AppendLineBreak();
            window.AppendNormal("Your Shadowbreed is up and available to use.");
            window.AppendLineBreak();
            window.AppendNormal("You're alive and present at the raid.");
            window.AppendLineBreak(2);

            window.AppendHighlight("Down ");
            window.AppendNormal("[");
            window.AppendBotCommand("Set", "sb set " + user + " down");
            window.AppendNormal("] ");
            window.AppendLineBreak();
            window.AppendNormal("Your Shadowbreed is not up and can't be used.");
            window.AppendLineBreak();
            window.AppendNormal("You're alive and present at the raid.");
            window.AppendLineBreak(2);

            window.AppendHighlight("Unavailable ");
            window.AppendNormal("[");
            window.AppendBotCommand("Set", "sb set " + user + " unavailable");
            window.AppendNormal("] ");
            window.AppendLineBreak();
            window.AppendNormal("You don't have a Shadowbreed.");
            window.AppendLineBreak();
            window.AppendNormal("Or you're not present at the raid.");

            bot.SendPrivateMessage(user, bot.ColorHighlight + "Please set your Shadowbreed state »» " + window.ToString(), AoLib.Net.PacketQueue.Priority.Urgent, true);
        }
예제 #3
0
        private void OnAuctionCommand(BotShell bot, CommandArgs e)
        {
            if (!this._running)
            {
                bot.SendReply(e, "There is currently no auction running");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Auction");
            window.AppendHighlight("Item: ");
            window.AppendNormalStart();
            window.AppendRawString(this._item);
            window.AppendString(" [");
            window.AppendBotCommand("Abort", "auction abort");
            window.AppendString("]");
            window.AppendColorEnd();
            window.AppendLineBreak();
            window.AppendHighlight("High Bidder: ");
            if (this._currentBid > 0)
            {
                window.AppendNormal(this._bidder);
                window.AppendLineBreak();
                window.AppendHighlight("High Bid: ");
                window.AppendNormal(this._currentBid.ToString());
            }
            else
            {
                window.AppendNormal("N/A");
            }
            window.AppendLineBreak();
            double points = this._core.GetPoints(e.Sender);

            if (points > this._core.MinimumPoints)
            {
                window.AppendHighlight("Your Points: ");
                if (points > this._currentBid)
                {
                    window.AppendColorString(RichTextWindow.ColorGreen, points.ToString());
                }
                else
                {
                    window.AppendColorString(RichTextWindow.ColorRed, points.ToString());
                }
                window.AppendLineBreak();
            }
            window.AppendHighlight("Time Left: ");
            window.AppendNormal(this._timeLeft.ToString() + " seconds");
            window.AppendLineBreak();
            bot.SendReply(e, "Auction »» ", window);
        }
예제 #4
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            Int32              cycle  = 7 + 7 + 7;
            string             today  = string.Empty;
            DateTimeFormatInfo dtfi   = new CultureInfo("en-US", false).DateTimeFormat;
            RichTextWindow     window = new RichTextWindow(bot);

            window.AppendTitle("Beast Days");

            for (int i = 0; i < cycle; i++)
            {
                Int64 current           = TimeStamp.Now + ((24 * 60 * 60) * i);
                Int64 secondsSinceStart = current - TimeStamp.FromDateTime(new DateTime(2006, 10, 23));
                Int64 seconds           = secondsSinceStart % (cycle * (24 * 60 * 60));
                Int64 day = (seconds / (24 * 60 * 60)) + 1;

                string type = string.Empty;
                if (day <= 7)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorBlue, "Omni");
                }
                else if (day > 7 && day <= 14)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorGreen, "FFA");
                }
                else if (day > 14)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorOrange, "Clan");
                }

                if (type == string.Empty)
                {
                    continue;
                }

                if (i == 0)
                {
                    today = type;
                }

                window.AppendHighlight(TimeStamp.ToDateTime(current).ToString("[dd/MM/yyyy]", dtfi));
                window.AppendNormal(TimeStamp.ToDateTime(current).ToString(" dddd: ", dtfi));
                window.AppendRawString(type);
                window.AppendLineBreak();
            }

            bot.SendReply(e, "Today is " + today + " day »» " + window.ToString());
        }
예제 #5
0
        private void OnHelpDisplayCommand(BotShell bot, CommandArgs e)
        {
            string command = e.Words[0];

            command = bot.Commands.GetMainCommand(command);
            if (!bot.Commands.Exists(command) || !bot.Commands.GetRights(command).Help)
            {
                bot.SendReply(e, "No such help topic");
                return;
            }

            PluginLoader  loader = bot.Plugins.GetLoader(bot.Commands.GetInternalName(command));
            CommandRights rights = bot.Commands.GetRights(command);
            UserLevel     level  = bot.Users.GetUser(e.Sender);

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Information");
            window.AppendHighlight("Command: ");
            window.AppendNormal(Format.UppercaseFirst(command));
            window.AppendLineBreak();
            window.AppendHighlight("Plugin: ");
            window.AppendNormal(loader.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Private Message Access: ");
            if (level >= rights.PrivateMessage)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.PrivateMessage.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.PrivateMessage.ToString());
            }
            window.AppendLineBreak();
            window.AppendHighlight("Private Channel Access: ");
            if (level >= rights.PrivateChannel)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.PrivateChannel.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.PrivateChannel.ToString());
            }
            window.AppendLineBreak();
            window.AppendHighlight("Organization Access: ");
            if (level >= rights.Organization)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.Organization.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.Organization.ToString());
            }
            window.AppendLineBreak(2);

            window.AppendHeader("Help");
            window.AppendHighlightStart();
            string help = bot.Commands.GetHelp(command);

            if (help == null || help.Trim() == string.Empty)
            {
                window.AppendString("No additional help available for this command");
            }
            else
            {
                window.AppendRawString(help);
            }
            window.AppendColorEnd();

            bot.SendReply(e, "VhaBot Help »» " + Format.UppercaseFirst(command) + " »» ", window);
        }
예제 #6
0
        private void OnConfigurationDisplayCommand(BotShell bot, CommandArgs e)
        {
            string internalName = e.Args[0].ToLower();

            if (!bot.Plugins.Exists(internalName))
            {
                bot.SendReply(e, "No such plugin!");
                return;
            }
            ConfigurationEntry[] entires = bot.Configuration.List(internalName);
            if (entires.Length < 1)
            {
                bot.SendReply(e, "This plugin has no settings to configure");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);
            PluginLoader   loader = bot.Plugins.GetLoader(internalName);

            window.AppendTitle("Configuration");
            foreach (ConfigurationEntry entry in entires)
            {
                window.AppendHighlight(entry.Name + ": ");
                window.AppendNormalStart();
                string command = "configuration set " + internalName + " " + entry.Key.ToLower();
                switch (entry.Type)
                {
                case ConfigType.String:
                    string value1 = bot.Configuration.GetString(entry.Section, entry.Key, (string)entry.DefaultValue);
                    if (entry.Values != null && entry.Values.Length > 0)
                    {
                        window.AppendMultiBox(command, value1, entry.StringValues);
                    }
                    else
                    {
                        window.AppendString(value1 + " [");
                        window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [text]");
                        window.AppendString("]");
                    }
                    break;

                case ConfigType.Integer:
                    string value2 = bot.Configuration.GetInteger(entry.Section, entry.Key, (int)entry.DefaultValue).ToString();
                    if (entry.Values != null && entry.Values.Length > 0)
                    {
                        window.AppendMultiBox(command, value2, entry.StringValues);
                    }
                    else
                    {
                        window.AppendString(value2 + " [");
                        window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [number]");
                        window.AppendString("]");
                    }
                    break;

                case ConfigType.Boolean:
                    string value3 = "Off";
                    if (bot.Configuration.GetBoolean(entry.Section, entry.Key, (bool)entry.DefaultValue))
                    {
                        value3 = "On";
                    }
                    window.AppendMultiBox(command, value3, "On", "Off");
                    break;

                case ConfigType.Username:
                    string value4 = bot.Configuration.GetUsername(entry.Section, entry.Key, (string)entry.DefaultValue);
                    window.AppendString(value4 + " [");
                    window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [username]");
                    window.AppendString("]");
                    break;

                case ConfigType.Date:
                    DateTime value5 = bot.Configuration.GetDate(entry.Section, entry.Key, (DateTime)entry.DefaultValue);
                    window.AppendString(value5.ToString("dd/MM/yyyy") + " [");
                    window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [dd]/[mm]/[yyyy]");
                    window.AppendString("]");
                    break;

                case ConfigType.Time:
                    TimeSpan value6 = bot.Configuration.GetTime(entry.Section, entry.Key, (TimeSpan)entry.DefaultValue);
                    window.AppendString(string.Format("{0:00}:{1:00}:{2:00}", Math.Floor(value6.TotalHours), value6.Minutes, value6.Seconds) + " [");
                    window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [hh]:[mm]:[ss]");
                    window.AppendString("]");
                    break;

                case ConfigType.Dimension:
                    string value7 = bot.Configuration.GetDimension(entry.Section, entry.Key, (Server)entry.DefaultValue).ToString();
                    window.AppendMultiBox(command, value7, Server.RubiKa.ToString(), Server.Test.ToString());
                    break;

                case ConfigType.Color:
                    string value8 = bot.Configuration.GetColor(entry.Section, entry.Key, (string)entry.DefaultValue);
                    window.AppendColorString(value8, value8);
                    window.AppendString(" [");
                    window.AppendBotCommand("Edit", "configuration color " + internalName + " " + entry.Key.ToLower());
                    window.AppendString("]");
                    break;

                case ConfigType.Password:
                    string value9 = bot.Configuration.GetPassword(entry.Section, entry.Key, (string)entry.DefaultValue);
                    for (int i = 0; i < value9.Length; i++)
                    {
                        window.AppendString("*");
                    }
                    window.AppendString(" [");
                    window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [password]");
                    window.AppendString("]");
                    break;

                case ConfigType.Custom:
                    string value10 = bot.Configuration.GetCustom(entry.Section, entry.Key);
                    if (value10 != null)
                    {
                        window.AppendRawString(value10);
                    }
                    break;
                }
                window.AppendString(" [");
                window.AppendBotCommand("Default", "configuration reset " + internalName + " " + entry.Key.ToLower());
                window.AppendString("]");
                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Configuration »» " + loader.Name + " »» ", window);
        }
예제 #7
0
        public void OnPluginsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window          = new RichTextWindow(bot);
            RichTextWindow windowCore      = new RichTextWindow(bot);
            RichTextWindow windowLoaded    = new RichTextWindow(bot);
            RichTextWindow windowInstalled = new RichTextWindow(bot);
            RichTextWindow windowDisabled  = new RichTextWindow(bot);

            window.AppendTitle("Plugins");
            window.AppendNormal("Plugins provide functionality and features for your bot. You can load different plugins based on your needs.");
            window.AppendLineBreak();
            window.AppendNormal("After loading plugins it's wise to open the ");
            window.AppendBotCommand("configuration interface", "configuration");
            window.AppendNormal(" to futher configure the loaded plugins.");
            window.AppendLineBreak();
            window.AppendNormal("If you're unsure about which plugin you need, ");
            window.AppendBotCommand("click here", "plugins overview");
            window.AppendNormal(" to get an overview of all available plugins.");
            window.AppendLineBreak(2);

            string[] plugins = bot.Plugins.GetPlugins();
            foreach (string plugin in plugins)
            {
                RichTextWindow tmpWindow;
                PluginState    state = bot.Plugins.GetState(plugin);
                switch (state)
                {
                case PluginState.Core:
                    tmpWindow = windowCore;
                    tmpWindow.AppendNormalStart();
                    break;

                case PluginState.Loaded:
                    tmpWindow = windowLoaded;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Unload", "plugins unload " + plugin);
                    tmpWindow.AppendString("] ");
                    break;

                case PluginState.Installed:
                    tmpWindow = windowInstalled;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Load", "plugins load " + plugin);
                    tmpWindow.AppendString("] [");
                    tmpWindow.AppendBotCommand("Uninstall", "plugins uninstall " + plugin);
                    tmpWindow.AppendString("] ");
                    break;

                default:
                    tmpWindow = windowDisabled;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Install", "plugins install " + plugin);
                    tmpWindow.AppendString("] ");
                    break;
                }
                tmpWindow.AppendString("[");
                tmpWindow.AppendBotCommand("Info", "plugins info " + plugin);
                tmpWindow.AppendString("] ");
                tmpWindow.AppendColorEnd();

                PluginLoader info = bot.Plugins.GetLoader(plugin);
                tmpWindow.AppendHighlight(info.Name);
                tmpWindow.AppendLineBreak();
            }

            window.AppendHeader("Core Plugins");
            if (windowCore.Text != string.Empty)
            {
                window.AppendRawString(windowCore.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Loaded");
            if (windowLoaded.Text != string.Empty)
            {
                window.AppendRawString(windowLoaded.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Installed");
            if (windowInstalled.Text != string.Empty)
            {
                window.AppendRawString(windowInstalled.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Disabled");
            if (windowDisabled.Text != string.Empty)
            {
                window.AppendRawString(windowDisabled.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }

            bot.SendReply(e, "Plugins »» ", window);
        }
예제 #8
0
        private void OnVerifyCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: verify [id]");
                return;
            }
            int id = 0;

            try
            {
                id = Convert.ToInt32(e.Args[0]);
            }
            catch
            {
                bot.SendReply(e, "Invalid ID");
                return;
            }
            lock (this._results)
            {
                // Get verification result
                if (!this._results.ContainsKey(id))
                {
                    bot.SendReply(e, "Unable to locate " + HTML.CreateColorString(bot.ColorHeaderHex, id.ToString()) + " in my records");
                    return;
                }
                Verify   verify    = this._results[id];
                TimeSpan ago       = DateTime.Now - verify.Time;
                string   agoString = ago.Seconds + " seconds";
                if (ago.Minutes > 0)
                {
                    agoString = ago.Minutes + " minutes and " + agoString;
                }
                string reply = HTML.CreateColorString(bot.ColorHeaderHex, agoString) + " ago, I told " + HTML.CreateColorString(bot.ColorHeaderHex, verify.User) + ": " + verify.Result;

                // Find more results
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle(verify.User + "'s History");
                int results = 0;
                foreach (Verify value in this._results.Values)
                {
                    if (value.User != verify.User)
                    {
                        continue;
                    }
                    results++;
                    window.AppendHighlight(Format.Time(value.Time, FormatStyle.Medium) + ": ");
                    window.AppendNormalStart();
                    window.AppendRawString(value.Result);
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }

                // Send reply
                if (results > 1)
                {
                    bot.SendReply(e, reply + " »» ", window, "More Information");
                }
                else
                {
                    bot.SendReply(e, reply);
                }
            }
        }
예제 #9
0
        private void OnTimeCommand(BotShell bot, CommandArgs e)
        {
            DateTime       now    = DateTime.Now.ToUniversalTime();
            RichTextWindow window = new RichTextWindow(bot);
            string         spacer = HTML.CreateColorString("#000000", "i");

            window.AppendTitle("US Pacific");
            window.AppendHighlight("Winter Offset");
            window.AppendLineBreak();
            window.AppendNormalStart();
            window.AppendRawString("  " + Format.Time(now.AddHours(-3.5), FormatStyle.Compact) + " NST (GMT-3:30)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-4), FormatStyle.Compact) + " AST (GMT-4)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-5), FormatStyle.Compact) + " EST (GMT-5)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-6), FormatStyle.Compact) + " CST (GMT-6)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-7), FormatStyle.Compact) + " MST (GMT-7)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-8), FormatStyle.Compact) + " PST (GMT-8)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-9), FormatStyle.Compact) + " AKST (GMT-9)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-10), FormatStyle.Compact) + " HAST (GMT-10)");
            window.AppendLineBreak();

            window.AppendHighlight("Summer Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-2.5), FormatStyle.Compact) + " NDT (GMT-2:30)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-3), FormatStyle.Compact) + " ADT (GMT-3)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-4), FormatStyle.Compact) + " EDT (GMT-4)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-5), FormatStyle.Compact) + " CDT (GMT-5)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-6), FormatStyle.Compact) + " MDT (GMT-6)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-7), FormatStyle.Compact) + " PDT (GMT-7)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-8), FormatStyle.Compact) + " AKDT (GMT-8)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(-9), FormatStyle.Compact) + " HADT (GMT-9)");
            window.AppendLineBreak(2);

            window.AppendHeader("Europe");
            window.AppendHighlight("Winter Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(0), FormatStyle.Compact) + " WET (GMT+0)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(1), FormatStyle.Compact) + " CET (GMT+1)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(2), FormatStyle.Compact) + " EET (GMT+2)");
            window.AppendLineBreak();
            window.AppendHighlight("Summer Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(1), FormatStyle.Compact) + " WEST (GMT+1)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(2), FormatStyle.Compact) + " CEST (GMT+2)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(3), FormatStyle.Compact) + " EEST (GMT+3)");
            window.AppendLineBreak(2);

            window.AppendHeader("Australia");
            window.AppendHighlight("Winter Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(8), FormatStyle.Compact) + " AWST (GMT+8)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(9.5), FormatStyle.Compact) + " ACST (GMT+9:30)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(10), FormatStyle.Compact) + " AEST (GMT+10)");
            window.AppendLineBreak();
            window.AppendHighlight("Summer Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(9), FormatStyle.Compact) + " AWDT (GMT+9)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(10.5), FormatStyle.Compact) + " ACDT (GMT+10:30)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(11), FormatStyle.Compact) + " AEDT (GMT+11)");
            window.AppendLineBreak(2);

            window.AppendHeader("Asian Pacific / Middle East");
            window.AppendHighlight("Default Offset");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(8), FormatStyle.Compact) + " HON (GMT+8)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(7), FormatStyle.Compact) + " BAN (GMT+7)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(7), FormatStyle.Compact) + " JAK (GMT+7)");
            window.AppendLineBreak();
            window.AppendRawString("  " + Format.Time(now.AddHours(3), FormatStyle.Compact) + " KUW (GMT+3)");
            window.AppendColorEnd();


            bot.SendReply(e, "The Current Time is " + HTML.CreateColorString(bot.ColorHeaderHex, Format.Time(DateTime.Now.ToUniversalTime(), FormatStyle.Large) + " GMT") + " »» ", window, "More Information");
        }
예제 #10
0
        private void OnAdminsCommand(BotShell bot, CommandArgs e)
        {
            SortedDictionary <string, UserLevel> members = bot.Users.GetUsers();
            List <string> chars = new List <string>();

            RichTextWindow window      = new RichTextWindow(bot);
            RichTextWindow superadmins = new RichTextWindow(bot);
            RichTextWindow admins      = new RichTextWindow(bot);
            RichTextWindow leaders     = new RichTextWindow(bot);

            int adminCount = 0;

            foreach (KeyValuePair <string, UserLevel> member in members)
            {
                RichTextWindow tmp = null;
                switch (member.Value)
                {
                case UserLevel.SuperAdmin:
                    tmp = superadmins;
                    break;

                case UserLevel.Admin:
                    tmp = admins;
                    break;

                case UserLevel.Leader:
                    tmp = leaders;
                    break;

                default:
                    continue;
                }
                chars.Add(member.Key.ToLower());
                tmp.AppendHighlightStart();
                tmp.AppendString(member.Key);
                tmp.AppendString(" is ");
                if (bot.FriendList.IsOnline(member.Key) == OnlineState.Online)
                {
                    tmp.AppendColorString(RichTextWindow.ColorGreen, "Online");
                }
                else
                {
                    tmp.AppendColorString(RichTextWindow.ColorRed, "Offline");
                }
                tmp.AppendColorEnd();
                tmp.AppendLineBreak();
                if (!bot.FriendList.IsFriend(member.Key))
                {
                    bot.FriendList.Add(this.InternalName, member.Key);
                }
                foreach (string alt in bot.Users.GetAlts(member.Key))
                {
                    chars.Add(alt.ToLower());
                    tmp.AppendNormalStart();
                    tmp.AppendString("- " + Format.UppercaseFirst(alt));
                    tmp.AppendString(" is ");
                    if (bot.FriendList.IsOnline(alt) == OnlineState.Online)
                    {
                        tmp.AppendColorString(RichTextWindow.ColorGreen, "Online");
                    }
                    else
                    {
                        tmp.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    }
                    tmp.AppendColorEnd();
                    tmp.AppendLineBreak();
                    if (!bot.FriendList.IsFriend(alt))
                    {
                        bot.FriendList.Add(this.InternalName, alt);
                    }
                }
                adminCount++;
            }
            foreach (string friend in bot.FriendList.List(this.InternalName))
            {
                if (!chars.Contains(friend.ToLower()))
                {
                    bot.FriendList.Remove(this.InternalName, friend);
                }
            }

            window.AppendTitle("Super Admins");
            window.AppendRawString(superadmins.Text);
            window.AppendLineBreak();

            window.AppendHeader("Admins");
            window.AppendRawString(admins.Text);
            window.AppendLineBreak();

            window.AppendHeader("Leaders");
            window.AppendRawString(leaders.Text);
            window.AppendLineBreak();

            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, adminCount.ToString()) + " Admins »» ", window);
        }
예제 #11
0
        public void CreateSbList(BotShell bot, ref RichTextWindow window, List <string> users)
        {
            users.Sort();
            RichTextWindow up      = new RichTextWindow(bot);
            RichTextWindow unknown = new RichTextWindow(bot);
            RichTextWindow down    = new RichTextWindow(bot);

            foreach (string user in users)
            {
                ShadowbreedState state = ShadowbreedState.Unknown;
                lock (this.Shadowbreeds)
                    if (this.Shadowbreeds.ContainsKey(user))
                    {
                        state = this.Shadowbreeds[user];
                    }

                RichTextWindow tmp;
                switch (state)
                {
                case ShadowbreedState.Up:
                    tmp = up;
                    break;

                case ShadowbreedState.Unknown:
                    tmp = unknown;
                    break;

                default:
                    tmp = down;
                    break;
                }

                tmp.AppendHighlight(Format.UppercaseFirst(user) + " ");
                tmp.AppendNormalStart();
                tmp.AppendString("(");
                tmp.AppendRawString(this.ColorizeState(state));
                tmp.AppendString(") ");
                if (state != ShadowbreedState.Up)
                {
                    tmp.AppendString("[");
                    tmp.AppendBotCommand("Up", "sb set " + user + " up");
                    tmp.AppendString("] ");
                }
                if (state != ShadowbreedState.Down)
                {
                    tmp.AppendString("[");
                    tmp.AppendBotCommand("Down", "sb set " + user + " down");
                    tmp.AppendString("] ");
                }
                if (state != ShadowbreedState.Unavailable)
                {
                    tmp.AppendString("[");
                    tmp.AppendBotCommand("Unavailable", "sb set " + user + " unavailable");
                    tmp.AppendString("] ");
                }
                tmp.AppendColorEnd();
                tmp.AppendLineBreak();
            }
            window.AppendRawString(up.Text);
            window.AppendRawString(unknown.Text);
            window.AppendRawString(down.Text);
        }
예제 #12
0
        public void OnOnlineCommand(BotShell bot, CommandArgs e)
        {
            List <string>         titles  = new List <string>();
            List <RichTextWindow> windows = new List <RichTextWindow>();
            string args = string.Empty;

            if (e.Args.Length > 0)
            {
                args = e.Args[0];
            }

            // Notify List
            if (this.IncludeNotifyList)
            {
                string[] online = bot.FriendList.Online("notify");
                if (online.Length > 0)
                {
                    RichTextWindow notifyWindow = new RichTextWindow(bot);
                    notifyWindow.AppendHeader(online.Length + " Users Online");
                    int results = 0;
                    this.BuildList(bot, online, ref notifyWindow, ref results, args);
                    if (results > 0)
                    {
                        titles.Add(HTML.CreateColorString(bot.ColorHeaderHex, results.ToString()) + " Users Online");
                        windows.Add(notifyWindow);
                    }
                }
            }

            // Private Channel
            if (this.IncludePrivateChannel)
            {
                Dictionary <UInt32, Friend> list = bot.PrivateChannel.List();
                List <string> guests             = new List <string>();
                foreach (KeyValuePair <UInt32, Friend> user in list)
                {
                    guests.Add(user.Value.User);
                }
                if (guests.Count > 0)
                {
                    RichTextWindow guestsWindow = new RichTextWindow(bot);
                    guestsWindow.AppendHeader(guests.Count + " Users on the Private Channel");
                    int results = 0;
                    this.BuildList(bot, guests.ToArray(), ref guestsWindow, ref results, args);
                    if (results > 0)
                    {
                        titles.Add(HTML.CreateColorString(bot.ColorHeaderHex, results.ToString()) + " Users on the Private Channel");
                        windows.Add(guestsWindow);
                    }
                }
            }

            // Output
            if (titles.Count < 1)
            {
                bot.SendReply(e, "The are currently no users online");
                return;
            }
            if (SeperateSections)
            {
                for (int i = 0; i < windows.Count; i++)
                {
                    RichTextWindow window = new RichTextWindow(bot);
                    window.AppendTitle();
                    window.AppendRawString(windows[i].Text);
                    bot.SendReply(e, titles[i] + " »» ", window);
                }
            }
            else
            {
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle();
                foreach (RichTextWindow subWindow in windows)
                {
                    window.AppendRawString(subWindow.Text);
                }
                bot.SendReply(e, string.Join(", ", titles.ToArray()) + " »» ", window);
            }
        }
예제 #13
0
        private void OnOrganizationCommand(BotShell bot, CommandArgs e)
        {
            if (bot.GetUserID(e.Args[0]) < 100)
            {
                bot.SendReply(e, "No such user: "******"Organization »» Gathering Data...");

            WhoisResult whoisResult = XML.GetWhois(e.Args[0], bot.Dimension);

            if (whoisResult != null && whoisResult.Organization != null)
            {
                OrganizationResult organization = XML.GetOrganization(whoisResult.Organization.ID, bot.Dimension);
                if (organization != null && organization.Members != null)
                {
                    RichTextWindow window        = new RichTextWindow(bot);
                    RichTextWindow membersWindow = new RichTextWindow(bot);

                    window.AppendTitle(organization.Name);

                    window.AppendHighlight("Leader: ");
                    window.AppendNormal(organization.Leader.Nickname);
                    window.AppendLineBreak();

                    window.AppendHighlight("Alignment: ");
                    window.AppendNormal(organization.Faction);
                    window.AppendLineBreak();

                    window.AppendHighlight("Members: ");
                    window.AppendNormal(organization.Members.Items.Length.ToString());
                    window.AppendLineBreak();

                    SortedDictionary <string, int> profs   = new SortedDictionary <string, int>();
                    SortedDictionary <string, int> breeds  = new SortedDictionary <string, int>();
                    SortedDictionary <string, int> genders = new SortedDictionary <string, int>();

                    membersWindow.AppendHeader("Members");

                    foreach (OrganizationMember member in organization.Members.Items)
                    {
                        if (!profs.ContainsKey(member.Profession))
                        {
                            profs.Add(member.Profession, 0);
                        }
                        profs[member.Profession]++;

                        if (!breeds.ContainsKey(member.Breed))
                        {
                            breeds.Add(member.Breed, 0);
                        }
                        breeds[member.Breed]++;

                        if (!genders.ContainsKey(member.Gender))
                        {
                            genders.Add(member.Gender, 0);
                        }
                        genders[member.Gender]++;

                        membersWindow.AppendHighlight(member.Nickname);
                        membersWindow.AppendNormal(string.Format(" {0} (L {1} / DR {2}) {3} {4}", member.Rank, member.Level, member.DefenderLevel, member.Breed, member.Profession));
                        membersWindow.AppendLineBreak();
                    }

                    string stats;
                    char[] trimchars = new char[] { ' ', ',' };

                    window.AppendHighlight("Genders: ");
                    stats = string.Empty;
                    foreach (KeyValuePair <string, int> kvp in genders)
                    {
                        stats += kvp.Value + " " + kvp.Key + ", ";
                    }
                    window.AppendNormal(stats.Trim(trimchars));
                    window.AppendLineBreak();

                    window.AppendHighlight("Breeds: ");
                    stats = string.Empty;
                    foreach (KeyValuePair <string, int> kvp in breeds)
                    {
                        stats += kvp.Value + " " + kvp.Key + ", ";
                    }
                    window.AppendNormal(stats.Trim(trimchars));
                    window.AppendLineBreak();

                    window.AppendHighlight("Professions: ");
                    stats = string.Empty;
                    foreach (KeyValuePair <string, int> kvp in profs)
                    {
                        stats += kvp.Value + " " + kvp.Key + ", ";
                    }
                    window.AppendNormal(stats.Trim(trimchars));
                    window.AppendLineBreak();

                    window.AppendHighlight("ID: ");
                    window.AppendNormal(organization.ID.ToString());
                    window.AppendLineBreak();

                    window.AppendHighlight("Last Updated: ");
                    window.AppendNormal(organization.LastUpdated);
                    window.AppendLineBreak(2);

                    window.AppendRawString(membersWindow.Text);

                    bot.SendReply(e, organization.Name + " »» ", window);
                    return;
                }
            }
            bot.SendReply(e, "Unable to gather information on that organization " + this.TimeoutError);
        }