Пример #1
0
        private void OnGlyphsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            string raffle = string.Empty;
            bool   empty  = true;

            lock (this._items)
            {
                foreach (KeyValuePair <int, string> kvp in this._items)
                {
                    window.AppendHeader(kvp.Value);
                    int i = 0;
                    lock (this._database.Connection)
                    {
                        using (IDbCommand command = this._database.Connection.CreateCommand())
                        {
                            command.CommandText = "SELECT id, looter, time FROM glyphs WHERE item = " + kvp.Key + " AND visible = 'true'";
                            IDataReader reader = command.ExecuteReader();
                            while (reader.Read())
                            {
                                i++;
                                window.AppendNormal(Format.DateTime(reader.GetInt64(2), FormatStyle.Compact) + " ");
                                window.AppendHighlight(reader.GetString(1));
                                window.AppendLineBreak();
                                empty = false;
                            }
                            reader.Close();
                        }
                    }
                    if (i == 0)
                    {
                        window.AppendHighlight("None");
                        window.AppendLineBreak();
                    }
                    window.AppendLineBreak();
                    raffle += " " + i;
                }
            }

            if (!empty)
            {
                window.AppendHeader("Options");
                window.AppendBotCommand("Start Raffle", "glyphs raffle" + raffle);
                window.AppendLineBreak();
                window.AppendBotCommand("Clear List", "glyphs clear");
                bot.SendReply(e, "Glyphs List »» ", window);
            }
            else
            {
                bot.SendReply(e, "The glyphs list is current empty");
            }
        }
Пример #2
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);
        }
Пример #3
0
        private void OnConfigurationColorCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Usage: configuration color [plugin] [key]");
                return;
            }
            if (!bot.Configuration.IsRegistered(e.Args[0], e.Args[1]))
            {
                bot.SendReply(e, "No such configuration entry");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            bool   first   = true;
            string section = e.Args[0].ToLower();
            string key     = e.Args[1].ToLower();
            string command = "configuration set " + section + " " + key + " ";

            foreach (KeyValuePair <string, string> color in this.Colors)
            {
                if (color.Value != string.Empty)
                {
                    window.AppendString("  ");
                    window.AppendBotCommandStart(command + color.Value, true);
                    window.AppendColorString(color.Value, color.Key);
                    window.AppendCommandEnd();
                    window.AppendLineBreak();
                }
                else
                {
                    if (!first)
                    {
                        window.AppendLineBreak();
                    }
                    window.AppendHeader(color.Key);
                    first = false;
                }
            }
            window.AppendLineBreak();
            window.AppendHeader("Other");
            window.AppendHighlight("To select a different color not listed above use: ");
            window.AppendLineBreak();
            window.AppendNormal("/tell " + bot.Character + " " + command + "<color hex>");
            bot.SendReply(e, "Color Selection »» ", window);
        }
Пример #4
0
 private void StartedEvent(object sender, EventArgs e)
 {
     if (this.CreditsEnabled)
     {
         if (!this._core.Locked)
         {
             this._core.Locked = true;
             //this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "The raid has been " + HTML.CreateColorString(RichTextWindow.ColorRed, "locked") + " pending raid credits type selection");
         }
         this.CreditsType = -1;
         RichTextWindow window = new RichTextWindow(this._bot);
         window.AppendTitle("Raid Credits Selection");
         window.AppendHighlight("The raid credits system has been enabled.");
         window.AppendLineBreak();
         window.AppendHighlight("Please select which type of raid credits should be used for this raid.");
         window.AppendLineBreak(2);
         lock (this._database.Connection)
         {
             using (IDbCommand command = this._database.Connection.CreateCommand())
             {
                 command.CommandText = "SELECT type, name, description, credits FROM credits_types";
                 IDataReader reader = command.ExecuteReader();
                 while (reader.Read())
                 {
                     window.AppendHeader(reader.GetString(1));
                     window.AppendHighlight(reader.GetString(2));
                     window.AppendLineBreak();
                     window.AppendNormal("[");
                     window.AppendBotCommand("Select", "raid credits " + reader.GetInt32(0));
                     window.AppendNormal("]");
                     window.AppendLineBreak(2);
                 }
                 reader.Close();
             }
         }
         window.AppendHeader("No Credits");
         window.AppendHighlight("Selecting this option will cause no raid credits to be charged this raid.");
         window.AppendLineBreak();
         window.AppendHighlight("This option is useful for unannounced or unplanned raids.");
         window.AppendLineBreak();
         window.AppendNormal("[");
         window.AppendBotCommand("Select", "raid unlock");
         window.AppendNormal("]");
         window.AppendLineBreak(2);
         this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "Please select raid credits type »» " + window.ToString());
     }
 }
Пример #5
0
 public void OnBattleCommand(BotShell bot, CommandArgs e)
 {
     try
     {
         using (IDbCommand command = this._database.Connection.CreateCommand())
         {
             RichTextWindow window = new RichTextWindow(bot);
             window.AppendTitle("Tower Battle History");
             window.AppendLineBreak();
             command.CommandText = "SELECT [time], [atkrSide] , [atkrOrg], [atkrName], [defSide], [defOrg], [zone], [xCoord], [yCoord], [LCA] FROM [towerhistory] WHERE victory = 0 ORDER BY [time] DESC LIMIT 10";
             IDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 window.AppendHeader(Format.DateTime(reader.GetInt64(0), FormatStyle.Compact) + " GMT");
                 if (!reader.IsDBNull(2))
                 {
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(3), reader.GetString(1)), reader.GetString(3));
                     window.AppendNormal(" - (");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(2), reader.GetString(1)), reader.GetString(2));
                     window.AppendNormal(")");
                     window.AppendLineBreak();
                 }
                 else
                 {
                     WhoisResult whois = XML.GetWhois(reader.GetString(3), bot.Dimension);
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(3), whois.Stats.Faction), reader.GetString(3));
                     window.AppendNormal(" - (Unguilded)");
                     window.AppendLineBreak();
                 }
                 window.AppendHighlight("Defender: ");
                 window.AppendColorString(this.sideColorWindow(reader.GetString(5), reader.GetString(4)), reader.GetString(5));
                 window.AppendLineBreak();
                 window.AppendHighlight("Location: ");
                 window.AppendNormal(reader.GetString(6) + " (x");
                 window.AppendColorString("FF0000", reader.GetInt64(9).ToString());
                 window.AppendNormal(" " + reader.GetInt64(7) + "x" + reader.GetInt64(8) + ")");
                 window.AppendLineBreak(2);
             }
             bot.SendReply(e, " Tower Battle Results »» ", window);
             return;
         }
     }
     catch
     {
         bot.SendReply(e, "Error retrieving battle history!");
     }
 }
Пример #6
0
        public void OnLinksCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            int links = 0;

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT id, category, link, description FROM links ORDER BY category, description";
                IDataReader reader       = command.ExecuteReader();
                string      lastCategory = "";
                while (reader.Read())
                {
                    int    id          = reader.GetInt32(0);
                    string category    = reader.GetString(1);
                    string link        = reader.GetString(2);
                    string description = reader.GetString(3);
                    if (category != lastCategory)
                    {
                        if (links > 0)
                        {
                            window.AppendLineBreak();
                        }
                        window.AppendHeader(category);
                        lastCategory = category;
                    }
                    window.AppendHighlight(description);
                    window.AppendNormalStart();
                    window.AppendString(" [");
                    window.AppendCommand("Visit", "/start " + link);
                    window.AppendString("] [");
                    window.AppendBotCommand("Remove", "links remove " + id);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                    links++;
                }
            }
            if (links > 0)
            {
                bot.SendReply(e, "Links and Bookmarks »» ", window);
            }
            else
            {
                bot.SendReply(e, "There are currently no links in the database");
            }
        }
Пример #7
0
        private void OnCallersCommand(BotShell bot, CommandArgs e)
        {
            if (this.Callers.Count < 1)
            {
                bot.SendReply(e, "There are no assigned callers");
                return;
            }
            RichTextWindow callersWindow = new RichTextWindow(bot);

            callersWindow.AppendTitle("Callers");
            string assistAll = string.Empty;

            lock (this.Callers)
            {
                foreach (string caller in this.Callers)
                {
                    callersWindow.AppendHighlight(Format.UppercaseFirst(caller));
                    callersWindow.AppendNormalStart();
                    callersWindow.AppendString(" [");
                    callersWindow.AppendCommand("Assist", "/assist " + caller);
                    callersWindow.AppendString("] [");
                    callersWindow.AppendCommand("Macro", "/macro " + caller + " /assist " + caller);
                    callersWindow.AppendString("] [");
                    callersWindow.AppendBotCommand("Remove", "callers remove " + caller);
                    callersWindow.AppendString("]");
                    callersWindow.AppendColorEnd();
                    callersWindow.AppendLineBreak();
                    assistAll += "/assist " + caller + "\\n ";
                }
            }
            callersWindow.AppendLineBreak();
            callersWindow.AppendHeader("Options");
            callersWindow.AppendHighlight("Assist All: ");
            callersWindow.AppendCommand("Click", assistAll.Substring(0, assistAll.Length - 3));
            callersWindow.AppendLineBreak();
            callersWindow.AppendHighlight("Assist All Macro: ");
            callersWindow.AppendNormal("/macro assist " + assistAll.Substring(0, assistAll.Length - 3));
            callersWindow.AppendLineBreak();
            callersWindow.AppendHighlight("Clear List: ");
            callersWindow.AppendBotCommand("Click", "callers remove all");
            bot.SendReply(e, "Callers »» ", callersWindow);
        }
Пример #8
0
        public void OnPluginsOverviewCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            string[] plugins = bot.Plugins.GetPlugins();
            foreach (string plugin in plugins)
            {
                if (bot.Plugins.GetState(plugin) == PluginState.Core)
                {
                    continue;
                }

                PluginLoader info = bot.Plugins.GetLoader(plugin);
                window.AppendHeader(info.Name + " v" + info.Version);

                if (!string.IsNullOrEmpty(info.Description))
                {
                    window.AppendHighlight("Description: ");
                    window.AppendNormal(info.Description);
                    window.AppendLineBreak();
                }

                window.AppendHighlight("Author: ");
                window.AppendNormal(info.Author);
                window.AppendLineBreak();

                window.AppendHighlight("Commands: ");
                List <string> commands = new List <string>();
                foreach (Command command in info.Commands)
                {
                    if (!command.IsAlias)
                    {
                        commands.Add(Format.UppercaseFirst(command.CommandName));
                    }
                }
                window.AppendNormal(string.Join(", ", commands.ToArray()));

                window.AppendLineBreak(2);
            }
            bot.SendReply(e, "Plugins Overview »» ", window);
        }
Пример #9
0
 public void OnVictoryCommand(BotShell bot, CommandArgs e)
 {
     try
     {
         using (IDbCommand command = this._database.Connection.CreateCommand())
         {
             RichTextWindow window = new RichTextWindow(bot);
             window.AppendTitle("Tower Victory History");
             window.AppendLineBreak();
             command.CommandText = "SELECT [time], [atkrSide], [atkrOrg], [defSide], [defOrg], [zone] FROM [towerhistory] WHERE victory = 1 ORDER BY [time] DESC LIMIT 10";
             IDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 window.AppendHeader(Format.DateTime(reader.GetInt64(0), FormatStyle.Compact) + " GMT");
                 if (!reader.IsDBNull(1))
                 {
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(2), reader.GetString(1)), reader.GetString(2));
                     window.AppendLineBreak();
                     window.AppendHighlight("Defender: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(4), reader.GetString(3)), reader.GetString(4));
                     window.AppendLineBreak();
                     window.AppendHighlight("Location: ");
                     window.AppendNormal(reader.GetString(5));
                     window.AppendLineBreak(2);
                 }
                 else
                 {
                     window.AppendColorString(this.sideColor(reader.GetString(4), reader.GetString(3)), reader.GetString(4));
                     window.AppendNormal(" lost their base in " + reader.GetString(5) + ".");
                     window.AppendLineBreak(2);
                 }
             }
             bot.SendReply(e, " Tower Victory Results »» ", window);
             return;
         }
     }
     catch
     {
         bot.SendReply(e, "Error retrieving battle victory history!");
     }
 }
Пример #10
0
        private void OnForumCommand(BotShell bot, CommandArgs e)
        {
            string username = e.Sender;

            if (e.Args.Length > 0)
            {
                username = Format.UppercaseFirst(e.Args[0]);
            }

            ForumAccount account = this.GetAccount(username);

            if (account == null)
            {
                bot.SendReply(e, "Unable to locate " + HTML.CreateColorString(bot.ColorHeaderHex, username + "'s") + " forum account");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle(username + "'s Forum Account");

            window.AppendHighlight("Name: ");
            window.AppendNormal(account.Realname);
            window.AppendLineBreak();

            window.AppendHighlight("Primary Group: ");
            if (account.PrimaryGroup != string.Empty)
            {
                window.AppendNormal(account.PrimaryGroup);
            }
            else
            {
                window.AppendNormal("N/A");
            }
            window.AppendLineBreak();

            window.AppendHighlight("E-mail Address: ");
            window.AppendNormal(account.Email);
            window.AppendLineBreak();

            window.AppendHighlight("Post Count: ");
            window.AppendNormal(account.Posts.ToString());
            if (account.Rank != string.Empty)
            {
                window.AppendNormal(" (" + account.Rank + ")");
            }
            window.AppendLineBreak();

            window.AppendHighlight("Epeen: ");
            window.AppendNormal(account.Karma.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Enabled: ");
            if (account.Enabled)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, "Yes");
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, "No");
                if (username == e.Sender)
                {
                    window.AppendNormal(" [");
                    window.AppendBotCommand("Activate", "forum activate");
                    window.AppendNormal("]");
                }
            }
            window.AppendLineBreak();

            window.AppendHighlight("Registered On: ");
            window.AppendNormal(Format.DateTime(account.Registered, FormatStyle.Medium));
            window.AppendLineBreak();

            if (account.Seen > 0)
            {
                window.AppendHighlight("Last Seen: ");
                TimeSpan span = TimeStamp.ToDateTime(TimeStamp.Now) - TimeStamp.ToDateTime(account.Seen);
                window.AppendNormal(Format.Time(span, FormatStyle.Large) + " ago");
                window.AppendLineBreak();
            }

            if (account.Groups.Count > 0)
            {
                window.AppendLineBreak();
                window.AppendHeader("Additional Groups");
                foreach (string group in account.Groups.Values)
                {
                    window.AppendHighlight(group);
                    window.AppendLineBreak();
                }
            }
            bot.SendReply(e, username + "'s Forum Account »» " + window.ToString());
        }
Пример #11
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "umob":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: umob [search string]");
                    return;
                }
                string search = string.Empty;
                search = e.Words[0];
                search = search.ToLower();

                string url = string.Format(this.UrlTemplate, this.Server, HttpUtility.UrlEncode(search));
                string xml = HTML.GetHtml(url, 20000);
                if (xml == null || xml == string.Empty)
                {
                    bot.SendReply(e, "Unable to query the unique mobs database");
                    return;
                }
                // if (xml.ToLower().StartsWith("<error>"))
                // {
                //     if (xml.Length > 13)
                //     {
                //         bot.SendReply(e, "Error: " + xml.Substring(7, xml.Length - 13));
                //         return;
                //     }
                //     else
                //     {
                //         bot.SendReply(e, "An unknown error has occured!");
                //         return;
                //     }
                // }

                string       result = string.Empty;
                MemoryStream stream = null;
                try
                {
                    stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
                    XmlSerializer  serializer     = new XmlSerializer(typeof(UniquesResults));
                    UniquesResults search_results = (UniquesResults)serializer.Deserialize(stream);
                    stream.Close();
                    if (search_results.Mobs == null || search_results.Mobs.Length == 0)
                    {
                        result = "No mobs were found";
                    }
                    else
                    {
                        RichTextWindow window = new RichTextWindow(bot);
                        if (search_results.Mobs.Length > this.NonPageSize)
                        {
                            window.AppendTitle("Unique Mobs Database");
                            window.AppendHighlight("Server: ");
                            window.AppendNormal(this.Server);
                            window.AppendLineBreak();
                            window.AppendHighlight("Version: ");
                            window.AppendNormal(search_results.Version);
                            window.AppendLineBreak();
                            window.AppendHighlight("Search String: ");
                            window.AppendNormal(search);
                            window.AppendLineBreak();
                            window.AppendHighlight("Results: ");
                            window.AppendNormal(search_results.Mobs.Length.ToString() + " / " + search_results.Max);
                            window.AppendLineBreak(2);
                            window.AppendHeader("Search Results");
                        }
                        else
                        {
                            window.AppendLineBreak();
                        }
                        foreach (UniqueMob mob in search_results.Mobs)
                        {
                            if (search_results.Mobs.Length <= this.NonPageSize)
                            {
                                window.AppendString("    ");
                            }
                            window.AppendHighlight(mob.name + " ");
                            window.AppendNormalStart();
                            window.AppendLineBreak();
                            window.AppendString("    Level: " + mob.level);
                            window.AppendLineBreak();
                            window.AppendString("    Location: " + mob.location + " (" + mob.coords + ")");
                            window.AppendLineBreak();
                            window.AppendString("    Drops: ");
                            window.AppendLineBreak();
                            foreach (UItemsResults_Item item in mob.Items)
                            {
                                window.AppendHighlight(item.Name + " ");
                                window.AppendNormalStart();
                                window.AppendString("[");
                                window.AppendItem("QL " + item._ql, item.LowID, item.HighID, item.QL);
                                window.AppendString("] (" + item._droprate + "%)");
                                window.AppendColorEnd();
                                window.AppendLineBreak();
                            }
                            window.AppendLineBreak(2);
                            //window.AppendLineBreak();
                        }
                        if (search_results.Mobs.Length > this.NonPageSize)
                        {
                            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, search_results.Mobs.Length.ToString()) + " Results »» ", window);
                        }
                        else
                        {
                            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, search_results.Mobs.Length.ToString()) + " Results »»" + window.Text.TrimEnd('\n'));
                        }
                        return;
                    }
                }
                catch
                {
                    result = "Unable to query the unique mobs database";
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                    }
                }
                bot.SendReply(e, result);
                break;
            }
        }
Пример #12
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "items":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: items [search string]");
                    return;
                }
                int ql = 0;
                try
                {
                    ql = Convert.ToInt32(e.Args[0]);
                    if (ql <= 0 || ql >= 1000)
                    {
                        bot.SendReply(e, "Quality level has to be between 0 and 999");
                        return;
                    }
                }
                catch { }
                if (ql != 0 && e.Words.Length == 1)
                {
                    bot.SendReply(e, "Correct Usage: items [quality level] [search string]");
                    return;
                }
                string search = string.Empty;
                if (ql != 0)
                {
                    search = e.Words[1];
                }
                else
                {
                    search = e.Words[0];
                }
                search = search.ToLower();

                string url = string.Format(this.UrlTemplate, this.Server, HttpUtility.UrlEncode(search), ql, Max);
                string xml = HTML.GetHtml(url, 60000);
                if (xml == null || xml == string.Empty)
                {
                    bot.SendReply(e, "Unable to query the central items database");
                    return;
                }
                if (xml.ToLower().StartsWith("<error>"))
                {
                    if (xml.Length > 13)
                    {
                        bot.SendReply(e, "Error: " + xml.Substring(7, xml.Length - 13));
                        return;
                    }
                    else
                    {
                        bot.SendReply(e, "An unknown error has occured!");
                        return;
                    }
                }

                string       result = string.Empty;
                MemoryStream stream = null;
                try
                {
                    stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
                    XmlSerializer serializer = new XmlSerializer(typeof(ItemsResults));
                    ItemsResults  items      = (ItemsResults)serializer.Deserialize(stream);
                    stream.Close();
                    if (items.Items == null || items.Items.Length == 0)
                    {
                        result = "No items were found";
                    }
                    else
                    {
                        RichTextWindow window = new RichTextWindow(bot);
                        if (items.Items.Length > this.NonPageSize)
                        {
                            window.AppendTitle("Central Items Database");
                            window.AppendHighlight("Server: ");
                            window.AppendNormal(this.Server);
                            window.AppendLineBreak();
                            window.AppendHighlight("Version: ");
                            window.AppendNormal(items.Version);
                            window.AppendLineBreak();
                            window.AppendHighlight("Search String: ");
                            window.AppendNormal(search);
                            window.AppendLineBreak();
                            window.AppendHighlight("Results: ");
                            window.AppendNormal(items.Items.Length.ToString() + " / " + items.Max);
                            window.AppendLineBreak(2);
                            window.AppendHeader("Search Results");
                        }
                        else
                        {
                            window.AppendLineBreak();
                        }
                        foreach (ItemsResults_Item item in items.Items)
                        {
                            if (items.Items.Length <= this.NonPageSize)
                            {
                                window.AppendString("    ");
                            }
                            window.AppendHighlight(item.Name + " ");
                            window.AppendNormalStart();
                            window.AppendString("[");
                            window.AppendItem("QL " + item.LowQL, item.LowID, item.HighID, item.LowQL);
                            window.AppendString("] ");
                            if (ql != 0 && ql > item.LowQL && ql < item.HighQL)
                            {
                                window.AppendString("[");
                                window.AppendItem("QL " + ql, item.LowID, item.HighID, ql);
                                window.AppendString("] ");
                            }
                            if (item.HighQL != item.LowQL)
                            {
                                window.AppendString("[");
                                window.AppendItem("QL " + item.HighQL, item.LowID, item.HighID, item.HighQL);
                                window.AppendString("] ");
                            }
                            window.AppendColorEnd();
                            window.AppendLineBreak();
                            if (item.IconID > 0 && items.Items.Length > this.NonPageSize)
                            {
                                window.AppendIcon(item.IconID);
                                window.AppendLineBreak();
                            }
                        }
                        if (items.Items.Length > this.NonPageSize)
                        {
                            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, items.Items.Length.ToString()) + " Results »» ", window);
                        }
                        else
                        {
                            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, items.Items.Length.ToString()) + " Results »»" + window.Text.TrimEnd('\n'));
                        }
                        return;
                    }
                }
                catch
                {
                    result = "Unable to query the central items database";
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                    }
                }
                bot.SendReply(e, result);
                break;
            }
        }
Пример #13
0
        private void OnCoreCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("BotShell Status");
            window.AppendHighlight("Current Thread: ");
            window.AppendNormal(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Owner: ");
            window.AppendNormal(bot.Admin);
            window.AppendLineBreak();
            window.AppendHighlight("Registered Commands: ");
            window.AppendNormal(bot.Commands.GetCommandsCount().ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Command Syntax: ");
            window.AppendNormal(bot.CommandSyntax);
            window.AppendLineBreak();
            window.AppendHighlight("Max Window Size Private Message: ");
            window.AppendNormal(bot.MaxWindowSizePrivateMessage.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Max Window Size Private Channel: ");
            window.AppendNormal(bot.MaxWindowSizePrivateChannel.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Max Window Size Organization: ");
            window.AppendNormal(bot.MaxWindowSizeOrganization.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Friendslist Usage: ");
            window.AppendNormal(bot.FriendList.UsedSlots + "/" + bot.FriendList.TotalSlots);
            window.AppendLineBreak();
            window.AppendHighlight("Runtime Version: ");
            window.AppendNormal(Environment.Version.ToString());
            try
            {
                // Non-priviliged accounts and mono might not like this, but I do \o/
                Process process = Process.GetCurrentProcess();
                window.AppendLineBreak();
                window.AppendHighlight("Process ID: ");
                window.AppendNormal(process.Id.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Threads: ");
                window.AppendNormal(process.Threads.Count.ToString());
                foreach (ProcessThread thread in process.Threads)
                {
                    window.AppendLineBreak();
                    window.AppendHighlight("Threads #" + thread.Id + ": ");
                    window.AppendNormal(thread.ThreadState.ToString() + " (S: " + Format.Date(thread.StartTime, FormatStyle.Compact) + " " + Format.Time(thread.StartTime, FormatStyle.Medium) + " / U: " + Format.Time(thread.TotalProcessorTime, FormatStyle.Compact) + (thread.ThreadState == ThreadState.Wait ? " / W: " + thread.WaitReason.ToString() : "") + ")");
                }
            }
            catch { }
            window.AppendLineBreak(2);

            List <Chat> chats = new List <Chat>();

            chats.Add(bot.GetMainBot());
            for (int i = 1; i <= bot.GetSlavesCount(); i++)
            {
                Chat slave = bot.GetSlaveBot(i);
                if (slave != null)
                {
                    chats.Add(slave);
                }
            }
            foreach (Chat chat in chats)
            {
                window.AppendHeader(chat.Character);
                window.AppendHighlight("Status: ");
                window.AppendNormal(chat.State.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Fast Queue Count: ");
                window.AppendNormal(chat.FastQueueCount.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Slow Queue Count: ");
                window.AppendNormal(chat.SlowQueueCount.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Friends: ");
                window.AppendNormal(chat.GetTotalFriends().ToString());
                window.AppendLineBreak();
                window.AppendHighlight("ID: ");
                window.AppendNormal(chat.ID.ToString());
                window.AppendLineBreak();
                if (chat.Organization != null && chat.Organization != string.Empty)
                {
                    window.AppendHighlight("Organization: ");
                    window.AppendNormal(chat.Organization);
                    window.AppendLineBreak();
                    window.AppendHighlight("Organization Channel: ");
                    window.AppendNormal(chat.OrganizationID.IntValue().ToString());
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "BotShell Status »» " + window.ToString());
        }
Пример #14
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");
        }
Пример #15
0
        public void OnTokensCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                // Tokens overview
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Tokens Overview");
                window.AppendHighlight("Level 1-14: ");
                window.AppendNormal("1 token");
                window.AppendLineBreak();
                window.AppendHighlight("Level 15-49: ");
                window.AppendNormal("2 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 50-74: ");
                window.AppendNormal("3 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 75-99: ");
                window.AppendNormal("4 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 100-124: ");
                window.AppendNormal("5 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 125-149: ");
                window.AppendNormal("6 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 150-174: ");
                window.AppendNormal("7 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 175-189: ");
                window.AppendNormal("8 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 190-220: ");
                window.AppendNormal("9 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Veteran tokens (7 veteran points): ");
                window.AppendNormal("50 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("OFAB tokens (1.000 victory points): ");
                window.AppendNormal("10 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("OFAB tokens (10.000 victory points): ");
                window.AppendNormal("100 tokens");
                window.AppendLineBreak();

                bot.SendReply(e, "Tokens »» ", window);
                return;
            }
            else
            {
                // Validate and parse input
                if (e.Args.Length < 2)
                {
                    bot.SendReply(e, "Correct Usage: tokens [[level]] [current] [goal]");
                    return;
                }
                int level   = 220;
                int current = 0;
                int goal    = 0;
                if (e.Args.Length == 2)
                {
                    if (e.SenderWhois != null && e.SenderWhois.Success)
                    {
                        level = e.SenderWhois.Stats.Level;
                    }
                    if (!int.TryParse(e.Args[0], out current) || !int.TryParse(e.Args[1], out goal))
                    {
                        bot.SendReply(e, "Correct Usage: tokens [current] [goal]");
                        return;
                    }
                }
                else
                {
                    if (!int.TryParse(e.Args[0], out level) || !int.TryParse(e.Args[1], out current) || !int.TryParse(e.Args[2], out goal))
                    {
                        bot.SendReply(e, "Correct Usage: tokens [level] [current] [goal]");
                        return;
                    }
                }
                if (level > 220)
                {
                    level = 220;
                }
                if (level < 1)
                {
                    level = 1;
                }
                if (current < 0)
                {
                    current = 0;
                }
                if (goal < 0)
                {
                    goal = 0;
                }
                if (current >= goal)
                {
                    bot.SendReply(e, "Congratulations, you've already reached your goal");
                    return;
                }

                // Determine how much tokens
                int tokens = 1;
                if (level > 189)
                {
                    tokens = 9;
                }
                else if (level > 174)
                {
                    tokens = 8;
                }
                else if (level > 149)
                {
                    tokens = 7;
                }
                else if (level > 124)
                {
                    tokens = 6;
                }
                else if (level > 99)
                {
                    tokens = 5;
                }
                else if (level > 74)
                {
                    tokens = 4;
                }
                else if (level > 49)
                {
                    tokens = 3;
                }
                else if (level > 14)
                {
                    tokens = 2;
                }

                // Calculate requirements
                double need  = goal - current;
                double step1 = need / (double)tokens;
                double step2 = (double)step1 / 7;
                double bags  = Math.Ceiling(4 * step2);
                step1 = Math.Ceiling(step1);
                double vpToken  = Math.Ceiling(need / 10);
                double vp       = vpToken * 1000;
                double vp2      = vpToken * 10;
                double vetToken = Math.Ceiling(need / 50);
                double vet      = vetToken * 7;
                double vet2     = vetToken * 50;

                // Format output
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Tokens Calculator Results");
                window.AppendHighlight("Level: ");
                window.AppendNormal(level.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Current amount of tokens: ");
                window.AppendNormal(current.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Goal amount of tokens: ");
                window.AppendNormal(goal.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Tokens needed: ");
                window.AppendNormal(need.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Tokens per mission token: ");
                window.AppendNormal(tokens.ToString());
                window.AppendLineBreak(2);

                window.AppendHeader("Requirements");
                window.AppendHighlight("Token bags: ");
                window.AppendNormal(bags.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Mission tokens: ");
                window.AppendNormal(step1.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Veteran tokens (" + vet + " veteran points): ");
                window.AppendNormal(vetToken.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("OFAB tokens (" + vp + " victory points): ");
                window.AppendNormal(vpToken.ToString());
                window.AppendLineBreak();

                bot.SendReply(e, "Tokens »» ", window);
            }
        }
Пример #16
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);
            }
        }
Пример #17
0
        public RichTextWindow GetAltsWindow(BotShell bot, string user)
        {
            string main = bot.Users.GetMain(user);

            string[] alts = bot.Users.GetAlts(main);
            if (alts.Length < 1)
            {
                return(null);
            }

            RichTextWindow window     = new RichTextWindow(bot);
            List <string>  characters = new List <string>();

            characters.Add(main);
            foreach (string alt in alts)
            {
                characters.Add(alt);
            }

            window.AppendTitle();
            foreach (string character in characters)
            {
                window.AppendHeader(Format.UppercaseFirst(character));
                window.AppendHighlight("Status: ");
                if (bot.FriendList.IsOnline(character) == OnlineState.Online)
                {
                    window.AppendColorString(RichTextWindow.ColorGreen, "Online");
                }
                else
                {
                    window.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    window.AppendLineBreak();
                    window.AppendHighlight("Last Seen: ");
                    Int64 seen = bot.FriendList.Seen(character);
                    if (seen > 1)
                    {
                        window.AppendNormal(Format.DateTime(seen, FormatStyle.Large) + " GMT");
                    }
                    else
                    {
                        window.AppendNormal("N/A");
                    }
                }
                window.AppendLineBreak();
                window.AppendHighlight("User Level: ");
                window.AppendNormal(bot.Users.GetUser(character).ToString());
                window.AppendLineBreak();

                WhoisResult whois = XML.GetWhois(character, bot.Dimension);
                if (whois != null && whois.Success)
                {
                    window.AppendHighlight("Profession: ");
                    window.AppendNormal(whois.Stats.Profession);
                    window.AppendLineBreak();
                    window.AppendHighlight("Level: ");
                    window.AppendNormal(whois.Stats.Level.ToString());
                    if (whois.Stats.DefenderLevel > 0)
                    {
                        window.AppendNormal(" / " + whois.Stats.DefenderLevel);
                    }
                    window.AppendLineBreak();
                    if (whois.InOrganization)
                    {
                        window.AppendHighlight("Organization: ");
                        window.AppendNormal(whois.Organization.Name);
                        window.AppendLineBreak();
                        window.AppendHighlight("Rank: ");
                        window.AppendNormal(whois.Organization.Rank);
                        window.AppendLineBreak();
                    }
                }
                window.AppendLineBreak();
            }
            return(window);
        }
Пример #18
0
        private void OnWhoisCommand(BotShell bot, CommandArgs e, AoLib.Net.Server dimension, Boolean showDimension)
        {
            if (!showDimension && dimension == AoLib.Net.Server.Test)
            {
                bot.SendReply(e, "The whois command is not available on the test server.");
                return;
            }
            if (dimension == bot.Dimension)
            {
                if (bot.GetUserID(e.Args[0]) < 100)
                {
                    bot.SendReply(e, "No such user: "******": ");
                }
                error += "Unable to gather information on that user " + this.TimeoutError;
                bot.SendReply(e, error);
                return;
            }

            RichTextWindow window  = new RichTextWindow(bot);
            StringBuilder  builder = new StringBuilder();

            if (showDimension)
            {
                builder.Append(HTML.CreateColorString(bot.ColorHeaderHex, dimension.ToString() + ": "));
            }

            builder.Append(String.Format("{0} (Level {1}", whois.Name.Nickname, whois.Stats.Level));
            window.AppendTitle(whois.Name.ToString());

            window.AppendHighlight("Breed: ");
            window.AppendNormal(whois.Stats.Breed);
            window.AppendLineBreak();

            window.AppendHighlight("Gender: ");
            window.AppendNormal(whois.Stats.Gender);
            window.AppendLineBreak();

            window.AppendHighlight("Profession: ");
            window.AppendNormal(whois.Stats.Profession);
            window.AppendLineBreak();

            window.AppendHighlight("Level: ");
            window.AppendNormal(whois.Stats.Level.ToString());
            window.AppendLineBreak();

            if (whois.Stats.DefenderLevel != 0)
            {
                window.AppendHighlight("Defender Rank: ");
                window.AppendNormal(String.Format("{0} ({1})", whois.Stats.DefenderRank, whois.Stats.DefenderLevel));
                window.AppendLineBreak();

                builder.Append(" / Defender Rank " + whois.Stats.DefenderLevel);
            }

            if (dimension == bot.Dimension)
            {
                window.AppendHighlight("Status: ");
                UInt32      userid = bot.GetUserID(whois.Name.Nickname);
                OnlineState state  = bot.FriendList.IsOnline(userid);
                switch (state)
                {
                case OnlineState.Online:
                    window.AppendColorString(RichTextWindow.ColorGreen, "Online");
                    break;

                case OnlineState.Offline:
                    window.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    Int64 seen = bot.FriendList.Seen(whois.Name.Nickname);
                    if (seen > 0)
                    {
                        window.AppendLineBreak();
                        window.AppendHighlight("Last Seen: ");
                        window.AppendNormal(Format.DateTime(seen, FormatStyle.Compact));
                    }
                    break;

                default:
                    window.AppendColorString(RichTextWindow.ColorOrange, "Unknown");
                    break;
                }
                window.AppendLineBreak();
            }

            builder.Append(")");
            builder.Append(String.Format(" is a {0} {1}", whois.Stats.Faction, whois.Stats.Profession));

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

            if (whois.InOrganization)
            {
                window.AppendHighlight("Organization: ");
                window.AppendNormal(whois.Organization.Name);
                window.AppendLineBreak();

                window.AppendHighlight("Organization Rank: ");
                window.AppendNormal(whois.Organization.Rank);
                window.AppendLineBreak();

                builder.AppendFormat(", {0} of {1}", whois.Organization.Rank, whois.Organization.Name);
            }

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

            if (dimension == bot.Dimension)
            {
                window.AppendHeader("Options");
                window.AppendCommand("Add to Friendlist", "/cc addbuddy " + whois.Name.Nickname);
                window.AppendLineBreak();
                window.AppendCommand("Remove from Friendlist", "/cc rembuddy " + whois.Name.Nickname);
                window.AppendLineBreak();
                window.AppendBotCommand("Character History", "history " + whois.Name.Nickname);
                window.AppendLineBreak();
                if (whois.Organization != null && whois.Organization.Name != null)
                {
                    window.AppendBotCommand("Organization Information", "organization " + whois.Name.Nickname);
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }

            window.AppendHeader("Links");
            window.AppendCommand("Official Character Website", "/start " + string.Format(this.CharWebsite, (int)dimension, whois.Name.Nickname));
            window.AppendLineBreak();
            if (whois.Organization != null && whois.Organization.Name != null)
            {
                window.AppendCommand("Official Organization Website", "/start " + string.Format(this.OrgWebsite, (int)dimension, whois.Organization.ID));
                window.AppendLineBreak();
            }
            window.AppendCommand("Auno's Character Website", "/start " + string.Format(this.CharAunoWebsite, (int)dimension, whois.Name.Nickname));
            window.AppendLineBreak();
            if (whois.Organization != null && whois.Organization.Name != null)
            {
                window.AppendCommand("Auno's Organization Website", "/start " + string.Format(this.OrgAunoWebsite, (int)dimension, whois.Organization.Name.Replace(' ', '+')));
                window.AppendLineBreak();
            }

            builder.Append(" »» " + window.ToString("More Information"));
            bot.SendReply(e, builder.ToString());
        }
Пример #19
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            string raider;
            bool   other = false;

            if (e.Args.Length > 0 && (bot.Users.GetUser(e.Sender) > bot.Commands.GetRight(e.Command, e.Type) || bot.Users.GetUser(e.Sender) == UserLevel.SuperAdmin))
            {
                other = true;
            }
            if (other)
            {
                raider = bot.Users.GetMain(e.Args[0]);
            }
            else
            {
                raider = bot.Users.GetMain(e.Sender);
            }

            double points   = this._core.GetPoints(raider);
            int    activity = (int)((float)this._core.GetActivity(raider) / 60);

            string[] alts = bot.Users.GetAlts(raider);

            if (points < this._core.MinimumPoints)
            {
                bot.SendReply(e, "There is no information available for " + HTML.CreateColorString(bot.ColorHeaderHex, raider));
                return;
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle(raider + "'s Information");
            User user = bot.Users.GetUserInformation(raider);

            if (user != null)
            {
                window.AppendHighlight("Added By: ");
                window.AppendNormal(user.AddedBy);
                window.AppendLineBreak();
                window.AppendHighlight("Added On: ");
                if (user.AddedOn > 0)
                {
                    window.AppendNormal(Format.DateTime(user.AddedOn, FormatStyle.Medium));
                }
                else
                {
                    window.AppendNormal("N/A");
                }
                window.AppendLineBreak();
                window.AppendHighlight("User Level: ");
                window.AppendNormal(user.UserLevel.ToString());
                window.AppendLineBreak();
            }
            if (alts.Length > 0)
            {
                window.AppendHighlight("Alts: ");
                window.AppendNormal(string.Join(", ", alts));
                window.AppendLineBreak();
            }
            window.AppendHighlight("Points: ");
            window.AppendNormal(points.ToString() + " points");
            window.AppendLineBreak();
            window.AppendHighlight("Activity: ");
            window.AppendNormal(activity.ToString() + " minutes");
            window.AppendLineBreak();
            if (this._core.Running)
            {
                window.AppendLineBreak();
                window.AppendHeader("Raid Information");
                RaidCore.Raider account = this._core.GetRaiderByMain(raider);
                window.AppendHighlight("Status: ");
                if (account == null || !account.OnRaid)
                {
                    window.AppendNormal("Not on the current raid");
                    window.AppendLineBreak();
                }
                else
                {
                    window.AppendNormal("Currently on this raid");
                    window.AppendLineBreak();
                    window.AppendHighlight("Character: ");
                    window.AppendNormal(account.Character);
                    window.AppendLineBreak();
                    window.AppendHighlight("Joined on: ");
                    window.AppendNormal(Format.DateTime(account.JoinTime, FormatStyle.Compact));
                    window.AppendLineBreak();
                    window.AppendHighlight("Contribution: ");
                    window.AppendNormal(Math.Floor((float)account.Activity / 60) + " minutes (" + ((float)((float)account.Activity / ((float)this._core.TimeRunning.TotalSeconds - (float)this._core.TimePaused.TotalSeconds) * 100)).ToString("##0.0") + "%)");
                    window.AppendLineBreak();
                }
            }

            bot.SendReply(e, raider + "'s Information »» ", window);
        }
Пример #20
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);
        }
Пример #21
0
        private void OnRaidHistoryCommand(BotShell bot, CommandArgs e)
        {
            RaidCore.Raid[] raids = this._core.GetRaids();
            if (raids.Length == 0)
            {
                bot.SendReply(e, "There's no raid history available");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            for (int i = raids.Length; i > 0; i--)
            {
                RaidCore.Raid raid = raids[i - 1];
                string        start;
                if (raid.StartTime > 0)
                {
                    start = Format.DateTime(raid.StartTime, FormatStyle.Compact) + " GMT";
                }
                else
                {
                    start = "N/A";
                }
                string stop;
                if (raid.StopTime > 0)
                {
                    stop = Format.DateTime(raid.StopTime, FormatStyle.Compact) + " GMT";
                }
                else
                {
                    stop = "N/A";
                }
                window.AppendHeader(start + " - " + stop);
                window.AppendHighlight("Started By: ");
                window.AppendNormal(raid.StartAdmin);
                window.AppendLineBreak();
                window.AppendHighlight("Stopped By: ");
                window.AppendNormal(raid.StopAdmin);
                window.AppendLineBreak();
                window.AppendHighlight("Duration: ");
                window.AppendNormal((raid.Activity / 60) + " minutes");
                window.AppendLineBreak();
                window.AppendHighlight("Description: ");
                window.AppendNormal(raid.Description);
                window.AppendLineBreak();
                window.AppendHighlight("Raiders: ");
                window.AppendNormal(raid.Raiders + " [");
                window.AppendBotCommand("View", "raid history " + raid.RaidID);
                window.AppendNormal("] [");
                window.AppendBotCommand("Log", "raid logs " + raid.RaidID);
                window.AppendNormal("]");
                // Replace with IntraBroadcast when done
                if (this._bot.Plugins.IsLoaded("RaidLootLog"))
                {
                    window.AppendNormal(" [");
                    window.AppendBotCommand("Loot log", "lootlog " + raid.RaidID);
                    window.AppendNormal("]");
                }
                window.AppendLineBreak(2);
            }
            bot.SendReply(e, "Raid History »» ", window);
        }
Пример #22
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            // Version Information
            window.AppendTitle("Version Information");

            window.AppendHighlight("Core Version: ");
            window.AppendNormal(BotShell.VERSION + " " + BotShell.BRANCH + " (Build: " + BotShell.BUILD + ")");
            window.AppendLineBreak();

            window.AppendHighlight("AoLib Version: ");
            window.AppendNormal(AoLib.Net.Chat.VERSION + " (Build: " + AoLib.Net.Chat.BUILD + ")");
            window.AppendLineBreak();

            window.AppendHighlight("CLR Version: ");
            window.AppendNormal(Environment.Version.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Bot Owner: ");
            window.AppendNormal(bot.Admin);
            window.AppendLineBreak(2);

            // Credits
            window.AppendHeader("Credits");
            window.AppendHighlight("Core Developer");
            window.AppendLineBreak();
            window.AppendNormal("- Vhab (rk1)");
            window.AppendLineBreak();
            window.AppendHighlight("Developers");
            window.AppendLineBreak();
            window.AppendNormal("- Iriche (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- Naturalistic (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- Tsuyoi (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- veremit (rk1)");
            window.AppendLineBreak();
            window.AppendHighlight("Contributors");
            window.AppendLineBreak();
            window.AppendNormal("- Toxor (rk2) (aka Techboy)");
            window.AppendLineBreak();
            window.AppendNormal("- Telperion (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- Moepl (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- Fayelure (rk1)");
            window.AppendLineBreak();
            window.AppendNormal("- Neksus (rk2)");
            window.AppendLineBreak(2);

            // Statistics
            window.AppendHeader("Statistics");
            window.AppendHighlight("Bot Uptime: ");
            window.AppendNormal(string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds", Math.Floor(bot.Stats.Uptime.TotalDays), bot.Stats.Uptime.Hours, bot.Stats.Uptime.Minutes, bot.Stats.Uptime.Seconds));
            window.AppendLineBreak();

            // Mono doesn't support performance counters
            Type mono = Type.GetType("Mono.Runtime");

            if (mono == null)
            {
                try
                {
                    PerformanceCounter pc = new PerformanceCounter("System", "System Up Time");
                    pc.NextValue();
                    TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());
                    window.AppendHighlight("Host Uptime: ");
                    window.AppendNormal(string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds", Math.Floor(ts.TotalDays), ts.Hours, ts.Minutes, ts.Seconds));
                    window.AppendLineBreak();
                }
                catch { }
            }

            window.AppendHighlight("Host OS: ");
            window.AppendNormal(Environment.OSVersion.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Commands Processed: ");
            window.AppendNormal(bot.Stats.Counter_Commands.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Private Messages Received: ");
            window.AppendNormal(bot.Stats.Counter_PrivateMessages_Received.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Channel Messages Received: ");
            window.AppendNormal(bot.Stats.Counter_ChannelMessages_Received.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Private Channel Messages Received: ");
            window.AppendNormal(bot.Stats.Counter_PrivateChannelMessages_Received.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Private Messages Sent: ");
            window.AppendNormal(bot.Stats.Counter_PrivateMessages_Sent.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Channel Messages Sent: ");
            window.AppendNormal(bot.Stats.Counter_ChannelMessages_Sent.ToString());
            window.AppendLineBreak();

            window.AppendHighlight("Private Channel Messages Sent: ");
            window.AppendNormal(bot.Stats.Counter_PrivateChannelMessages_Sent.ToString());
            window.AppendLineBreak();

            window.AppendLineBreak();
            window.AppendHeader("Links");
            window.AppendCommand("VhaBot Central", "/start http://www.vhabot.net/");
            window.AppendLineBreak();
            window.AppendCommand("VhaBot Forums", "/start http://forums.vhabot.net/");
            window.AppendLineBreak();
            window.AppendCommand("VhaBot Characters Database", "/start http://characters.vhabot.net/");
            window.AppendLineBreak();
            window.AppendCommand("VhaBot Tools", "/start http://tools.vhabot.net/");

            bot.SendReply(e, "VhaBot " + BotShell.VERSION + " " + BotShell.BRANCH + " - " + BotShell.EDITION + " Edition »» " + window.ToString("More Information"));
        }
Пример #23
0
        private void OnTeamsAdminCommand(BotShell bot, CommandArgs e)
        {
            List <string> seen  = new List <string>();
            List <int>    teams = new List <int>();

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT team FROM teams GROUP BY team";
                IDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    teams.Add((int)reader.GetInt64(0));
                }
                reader.Close();
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Teams Manager");
            window.AppendCommand("Display Teams", "/g " + bot.Character + " " + bot.CommandSyntax + "teams");
            window.AppendLineBreak();
            window.AppendBotCommand("Refresh Manager", "teams admin");
            window.AppendLineBreak();
            window.AppendBotCommand("Clear Teams", "teams clear");
            window.AppendLineBreak();

            int currentTeam   = -1;
            int currentMember = 0;

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT username, team, leader FROM teams ORDER BY team, username";
                IDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string username = Format.UppercaseFirst(reader.GetString(0));
                    seen.Add(username);
                    int  team   = (int)reader.GetInt64(1);
                    bool leader = (reader.GetInt64(2) > 0);
                    if (team != currentTeam)
                    {
                        currentMember = 0;
                        currentTeam   = team;
                        window.AppendLineBreak();
                        window.AppendHeader("Team " + team);
                    }
                    currentMember++;
                    WhoisResult whois = XML.GetWhois(username, bot.Dimension);
                    if (whois != null && whois.Success)
                    {
                        window.AppendHighlight(Format.Whois(whois, FormatStyle.Compact));
                    }
                    else
                    {
                        window.AppendHighlight(username);
                    }

                    window.AppendNormalStart();
                    if (leader)
                    {
                        window.AppendString(" (");
                        window.AppendColorString(RichTextWindow.ColorRed, "Leader");
                        window.AppendString(")");
                    }
                    foreach (int tm in teams)
                    {
                        if (tm == team)
                        {
                            continue;
                        }
                        window.AppendString(" [");
                        window.AppendBotCommand(tm.ToString(), "teams set " + username + " " + tm);
                        window.AppendString("]");
                    }
                    if (!leader)
                    {
                        window.AppendString(" [");
                        window.AppendBotCommand("Leader", "teams leader " + username + " " + team);
                        window.AppendString("]");
                    }
                    window.AppendString(" [");
                    window.AppendBotCommand("Remove", "teams remove " + username);
                    window.AppendString("]");
                    window.AppendString(" [");
                    window.AppendBotCommand("New Team", "teams start " + username);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }
                reader.Close();
            }
            window.AppendLineBreak();

            window.AppendHeader("Looking for Team");
            int           lft  = 0;
            List <string> list = new List <string>();

            foreach (Friend user in bot.PrivateChannel.List().Values)
            {
                list.Add(user.User);
            }

            // If 'Raid :: Core' is loaded, fetch the lft list from there
            List <string> raiders = new List <string>();

            if (bot.Plugins.IsLoaded("raidcore"))
            {
                try
                {
                    ReplyMessage reply = bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "GetActiveRaiders", 100);
                    if (reply != null && reply.Args.Length > 0)
                    {
                        raiders = new List <string>((string[])reply.Args);
                    }
                }
                catch { }
            }

            // Sort LFT list
            SortedDictionary <string, SortedDictionary <string, WhoisResult> > sorted = new SortedDictionary <string, SortedDictionary <string, WhoisResult> >();

            foreach (string member in list)
            {
                WhoisResult whois = XML.GetWhois(member, bot.Dimension);
                if (whois == null || !whois.Success)
                {
                    whois = null;
                }
                if (!sorted.ContainsKey(whois.Stats.Profession))
                {
                    sorted.Add(whois.Stats.Profession, new SortedDictionary <string, WhoisResult>());
                }
                sorted[whois.Stats.Profession].Add(member, whois);
            }

            // Display LFT list
            foreach (KeyValuePair <string, SortedDictionary <string, WhoisResult> > kvp in sorted)
            {
                window.AppendHighlight(kvp.Key);
                window.AppendLineBreak();
                foreach (KeyValuePair <string, WhoisResult> member in kvp.Value)
                {
                    if (seen.Contains(member.Key))
                    {
                        continue;
                    }
                    window.AppendNormalStart();
                    window.AppendString("- ");
                    if (member.Value != null && member.Value.Success)
                    {
                        window.AppendString(Format.Whois(member.Value, FormatStyle.Compact));
                    }
                    else
                    {
                        window.AppendString(member.Key);
                    }
                    if (raiders.Contains(member.Key))
                    {
                        window.AppendString(" [");
                        window.AppendColorString(RichTextWindow.ColorGreen, "R");
                        window.AppendString("]");
                    }
                    foreach (int tm in teams)
                    {
                        window.AppendString(" [");
                        window.AppendBotCommand(tm.ToString(), "teams set " + member.Key + " " + tm);
                        window.AppendString("]");
                    }
                    window.AppendString(" [");
                    window.AppendBotCommand("New Team", "teams start " + member.Key);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                    lft++;
                }
                window.AppendLineBreak();
            }
            if (lft == 0)
            {
                window.AppendHighlight("None");
            }
            bot.SendReply(e, "Teams Manager »» ", window);
        }
Пример #24
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);
        }
Пример #25
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: aigen [ankari/ilari/rimah/jaax/xoch/cha]");
                return;
            }

            string msg        = String.Empty;
            string botName    = String.Empty;
            string bioName1   = String.Empty;
            string bioName2   = String.Empty;
            string genName    = String.Empty;
            string botInfo    = String.Empty;
            int    bioId1     = 0;
            int    bioId2     = 0;
            int    botImageId = 100337;
            int    bioImageId = 255705;
            int    botId      = 0;

            switch (e.Args[0])
            {
            case "ankari":
                genName  = "General - Ankari'Khaz";
                botId    = 247145;
                botName  = "Arithmetic Lead Viralbots";
                bioId1   = 247684;
                bioName1 = "Kyr'Ozch Bio-Material - Type 1";
                bioId2   = 247685;
                bioName2 = "Kyr'Ozch Bio-Material - Type 2";
                msg      = "Low Evade/Dodge,low AR, casting Viral/Virral nukes.";
                botInfo  = "(Nanoskill / Tradeskill)";
                break;

            case "ilari":
                genName  = "General - Ilari'Khaz";
                botId    = 247146;
                botName  = "Spiritual Lead Viralbots";
                bioId1   = 247681;
                bioName1 = "Kyr'Ozch Bio-Material - Type 992";
                bioId2   = 247679;
                bioName2 = "Kyr'Ozch Bio-Material - Type 880";
                msg      = "Low Evade/Dodge.";
                botInfo  = "(Nanocost / Nanopool / Max Nano)";
                break;

            case "rimah":
                genName  = "General - Rimah'Khaz";
                botId    = 247143;
                botName  = "Observant Lead Viralbots";
                bioId1   = 247675;
                bioName1 = "Kyr'Ozch Bio-Material - Type 112";
                bioId2   = 247678;
                bioName2 = "Kyr'Ozch Bio-Material - Type 240";
                msg      = "Low Evade/Dodge.";
                botInfo  = "(Init / Evades)";
                break;

            case "jaax":
                genName  = "General - Jaax'Khaz";
                botId    = 247139;
                botName  = "Strong Lead Viralbots";
                bioId1   = 247694;
                bioName1 = "Kyr'Ozch Bio-Material - Type 3";
                bioId2   = 247688;
                bioName2 = "Kyr'Ozch Bio-Material - Type 4";
                msg      = "High Evade, Low Dodge.";
                botInfo  = "(Melee / Spec Melee / Add All Def / Add Damage)";
                break;

            case "xoch":
                genName  = "General - Xoch'Khaz";
                botId    = 247137;
                botName  = "Enduring Lead Viralbots";
                bioId1   = 247690;
                bioName1 = "Kyr'Ozch Bio-Material - Type 5";
                bioId2   = 247692;
                bioName2 = "Kyr'Ozch Bio-Material - Type 12";
                msg      = "High Evade/Dodge, casting Ilari Biorejuvenation heals.";
                botInfo  = "(Max Health / Body Dev)";
                break;

            case "cha":
                genName  = "General - Cha'Khaz";
                botId    = 247141;
                botName  = "Supple Lead Viralbots";
                bioId1   = 247696;
                bioName1 = "Kyr'Ozch Bio-Material - Type 13";
                bioId2   = 247674;
                bioName2 = "Kyr'Ozch Bio-Material - Type 76";
                msg      = "High Evade/NR, Low Dodge.";
                botInfo  = "(Ranged / Spec Ranged / Add All Off)";
                break;

            default:
                bot.SendReply(e, "Unknown Alien General. Available options are: " + HTML.CreateColorString(bot.ColorHeaderHex, "ankari, ilari, rimah, jaax, xoch, cha"));
                return;
            }


            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle(genName);

            window.AppendHighlight("Type: ");
            window.AppendNormal(msg);
            window.AppendLineBreak(2);

            window.AppendHeader("Drops");
            window.AppendHighlight(botName + " ");
            window.AppendNormalStart();
            window.AppendString(botInfo + " [");
            window.AppendItem("QL " + 300, botId, botId, 300);
            window.AppendString("] ");
            window.AppendColorEnd();
            window.AppendLineBreak();
            window.AppendIcon(botImageId);
            window.AppendLineBreak(2);

            window.AppendHighlight(bioName1 + " ");
            window.AppendNormalStart();
            window.AppendString("[");
            window.AppendItem("QL " + 300, bioId1, bioId1, 300);
            window.AppendString("] ");
            window.AppendColorEnd();
            window.AppendLineBreak();
            window.AppendIcon(bioImageId);
            window.AppendLineBreak();

            window.AppendLineBreak();
            window.AppendHighlight(bioName2 + " ");
            window.AppendNormalStart();
            window.AppendString("[");
            window.AppendItem("QL " + 300, bioId2, bioId2, 300);
            window.AppendString("] ");
            window.AppendColorEnd();
            window.AppendLineBreak();
            window.AppendIcon(bioImageId);
            window.AppendLineBreak();

            bot.SendReply(e, genName + " »» ", window);
        }
Пример #26
0
        private void OnSbCommand(BotShell bot, CommandArgs e)
        {
            List <string> atrox    = new List <string>();
            List <string> nanomage = new List <string>();
            List <string> opifex   = new List <string>();
            List <string> solitus  = new List <string>();

            foreach (KeyValuePair <UInt32, Friend> kvp in bot.PrivateChannel.List())
            {
                WhoisResult whois = XML.GetWhois(kvp.Value.User, bot.Dimension);
                if (whois == null || whois.Stats == null || whois.Stats.Breed == null)
                {
                    continue;
                }

                lock (this.Shadowbreeds)
                    if (!this.Shadowbreeds.ContainsKey(kvp.Value.User.ToLower()))
                    {
                        if (whois.Stats.Level >= 205)
                        {
                            this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unknown);
                        }
                        else
                        {
                            this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unavailable);
                        }
                    }

                switch (whois.Stats.Breed.ToLower())
                {
                case "atrox":
                    atrox.Add(whois.Name.Nickname.ToLower());
                    break;

                case "nano":
                    nanomage.Add(whois.Name.Nickname.ToLower());
                    break;

                case "opifex":
                    opifex.Add(whois.Name.Nickname.ToLower());
                    break;

                case "solitus":
                    solitus.Add(whois.Name.Nickname.ToLower());
                    break;
                }
            }

            lock (this.Shadowbreeds)
            {
                List <string> remove = new List <string>();
                foreach (KeyValuePair <string, ShadowbreedState> shadowbreed in this.Shadowbreeds)
                {
                    if (atrox.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (nanomage.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (opifex.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (solitus.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    remove.Add(shadowbreed.Key);
                }
                foreach (string shadowbreed in remove)
                {
                    this.Shadowbreeds.Remove(shadowbreed);
                }

                if (this.Shadowbreeds.Count < 1)
                {
                    bot.SendReply(e, "The Shadowbreeds list is empty");
                    return;
                }
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            if (atrox.Count > 0)
            {
                window.AppendHeader("Atrox");
                this.CreateSbList(bot, ref window, atrox);
                window.AppendLineBreak();
            }
            if (nanomage.Count > 0)
            {
                window.AppendHeader("Nanomage");
                this.CreateSbList(bot, ref window, nanomage);
                window.AppendLineBreak();
            }
            if (opifex.Count > 0)
            {
                window.AppendHeader("Opifex");
                this.CreateSbList(bot, ref window, opifex);
                window.AppendLineBreak();
            }
            if (solitus.Count > 0)
            {
                window.AppendHeader("Solitus");
                this.CreateSbList(bot, ref window, solitus);
                window.AppendLineBreak();
            }

            window.AppendHeader("Options");
            window.AppendBotCommand("Request Shadowbreed State", "sb get");
            window.AppendLineBreak();
            window.AppendBotCommand("Reset Shadowbreed List", "sb reset");

            bot.SendReply(e, "Shadowbreeds »» ", window);
        }
Пример #27
0
        private void OnNewsID(BotShell bot, CommandArgs e)
        {
            double d;

            if (e.Args.Length == 0)
            {
                bot.SendReply(e, "Correct Usage: news id [id]");
                return;
            }
            if (double.TryParse(e.Args[0], System.Globalization.NumberStyles.Integer, _cultureInfo, out d) == true)
            {
                try
                {
                    using (IDbCommand command = this._database.Connection.CreateCommand())
                    {
                        command.CommandText = "SELECT [news_name], [news_sticky] FROM [news] WHERE [news_id] = " + e.Args[0];
                        IDataReader reader = command.ExecuteReader();
                        if (reader.Read())
                        {
                            if ((reader.GetString(0) == e.Sender || bot.Users.Authorized(e.Sender, UserLevel.Admin)) && e.Type == CommandType.Tell)
                            {
                                RichTextWindow window = new RichTextWindow(bot);
                                window.AppendTitle("News Options");
                                window.AppendHighlight("Sticky: ");
                                if (reader.GetInt64(1) == 1)
                                {
                                    window.AppendColorString(RichTextWindow.ColorGreen, "Enabled");
                                    window.AppendNormal(" [");
                                    window.AppendBotCommand("Disable", "news sticky " + e.Args[0] + " 0");
                                    window.AppendNormal("]");
                                }
                                else
                                {
                                    window.AppendColorString(RichTextWindow.ColorOrange, "Disabled");
                                    window.AppendNormal(" [");
                                    window.AppendBotCommand("Enable", "news sticky " + e.Args[0] + " 1");
                                    window.AppendNormal("]");
                                }
                                window.AppendLineBreak(2);

                                window.AppendHeader("Icon");
                                if (reader.GetInt64(1) == 1)
                                {
                                    window.AppendNormal("There are no icons available for sticky posts");
                                }
                                else
                                {
                                    int counter = 0;
                                    foreach (string Icon in _iconList)
                                    {
                                        window.AppendBotCommandStart("news icon " + e.Args[0] + " " + counter.ToString());
                                        window.AppendImage(Icon);
                                        window.AppendLinkEnd();
                                        window.AppendNormal(" ");
                                        counter = counter + 1;
                                    }
                                }
                                bot.SendReply(e, "News Options »» ", window);
                                return;
                            }
                            else
                            {
                                bot.SendReply(e, "You don't own this news post");
                                return;
                            }
                        }
                        else
                        {
                            bot.SendReply(e, "No such news post");
                            return;
                        }
                    }
                }
                catch
                {
                    bot.SendReply(e, "Error during news fetching. Please try again later");
                    return;
                }
            }
            bot.SendReply(e, "Invalid ID");
        }
Пример #28
0
 private void OnNews(BotShell bot, CommandArgs e)
 {
     try
     {
         using (IDbCommand command = this._database.Connection.CreateCommand())
         {
             RichTextWindow window = new RichTextWindow(bot);
             window.AppendTitle();
             bool  titleSticky = false;
             bool  titleNormal = false;
             Int64 lastPost    = 0;
             command.CommandText = "SELECT [news_id], [news_name] , [news_date], [news_text], [news_icon], [news_sticky] FROM [news] ORDER BY [news_sticky] DESC, [news_date] DESC LIMIT 15";
             IDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 if (reader.GetInt64(2) > lastPost)
                 {
                     lastPost = reader.GetInt64(2);
                 }
                 if (reader.GetInt64(5) == 1)
                 {
                     if (!titleSticky)
                     {
                         window.AppendHeader("Sticky News Posts");
                         window.AppendLineBreak();
                         titleSticky = true;
                     }
                 }
                 else
                 {
                     if (!titleNormal)
                     {
                         window.AppendHeader("Current News Posts");
                         window.AppendLineBreak();
                         titleNormal = true;
                     }
                 }
                 window.AppendBotCommandStart("news id " + reader.GetInt64(0).ToString());
                 if (reader.GetInt64(5) == 1)
                 {
                     window.AppendImage("GFX_GUI_WINDOW_ICON_POPUP");
                 }
                 else
                 {
                     window.AppendImage(_iconList[reader.GetInt64(4)]);
                 }
                 window.AppendLinkEnd();
                 window.AppendHighlight(" " + Format.DateTime(reader.GetInt64(2), FormatStyle.Compact) + " GMT by " + reader.GetString(1));
                 window.AppendLineBreak(true);
                 window.AppendNormal(reader.GetString(3));
                 if ((reader.GetString(1) == e.Sender || bot.Users.Authorized(e.Sender, UserLevel.Admin)))
                 {
                     window.AppendLineBreak(true);
                     window.AppendNormal("[");
                     window.AppendBotCommand("Remove", "news remove " + reader.GetInt64(0));
                     window.AppendNormal("]");
                 }
                 window.AppendLineBreak(2);
             }
             if (lastPost == 0)
             {
                 bot.SendReply(e, "There's currently no news");
                 return;
             }
             else
             {
                 bot.SendReply(e, "News last edited on " + HTML.CreateColorString(bot.ColorHeaderHex, Format.DateTime(lastPost, FormatStyle.Compact)) + " »» ", window);
                 return;
             }
         }
     }
     catch
     {
         bot.SendReply(e, "Error during news fetching. Please try again later");
         return;
     }
 }
Пример #29
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);
        }
Пример #30
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);
        }