Example #1
0
        private void OnSecurityCommand(BotShell bot, CommandArgs e)
        {
            bot.SendReply(e, "Gathering Data. This can take several minutes. Please stand by...");
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Invalid ID's / Rerolled Characters");
            List <SecurityProcessItem> members = new List <SecurityProcessItem>();

            lock (this._database.Connection)
            {
                using (IDbCommand command = this._database.Connection.CreateCommand())
                {
                    command.CommandText = "SELECT username as name, userID as id, 'Main' as type FROM members UNION SELECT altname, altID, 'Alt' FROM alts ORDER BY name";
                    IDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        string username = reader.GetString(0);
                        UInt32 userID   = (UInt32)reader.GetInt64(1);
                        string type     = reader.GetString(2);
                        members.Add(new SecurityProcessItem(username, userID, type));
                    }
                    reader.Close();
                }
            }
            foreach (SecurityProcessItem member in members)
            {
                UInt32 realID = bot.GetUserID(member.Username);
                if (realID == 0)
                {
                    window.AppendHighlight(member.Username);
                    window.AppendNormalStart();
                    window.AppendString(" (" + member.Type + ") (");
                    window.AppendColorString(RichTextWindow.ColorRed, "Deleted");
                    window.AppendString(") [");
                    window.AppendBotCommand("Account", "account " + member.Username);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }
                else if (realID != member.UserID)
                {
                    window.AppendHighlight(member.Username);
                    window.AppendNormalStart();
                    window.AppendString(" (Current=" + member.UserID + " Real=" + realID + ") (" + member.Type + ") (");
                    window.AppendColorString(RichTextWindow.ColorOrange, "Invalid ID");
                    window.AppendString(") [");
                    window.AppendBotCommand("Account", "account " + member.Username);
                    window.AppendString("] [");
                    window.AppendBotCommand("Fix", "security fixid " + member.Username);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }
            }
            bot.SendReply(e, "Security Report »» ", window);
        }
Example #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);
        }
Example #3
0
        private void OnCommandsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Command Rights");
            foreach (string plugin in bot.Plugins.GetPlugins())
            {
                if (bot.Plugins.GetState(plugin) == PluginState.Loaded)
                {
                    string[] commands = bot.Commands.GetCommands(plugin);
                    if (commands.Length > 0)
                    {
                        PluginLoader loader = bot.Plugins.GetLoader(plugin);
                        window.AppendNormalStart();
                        window.AppendString("[");
                        window.AppendBotCommand("Configure", "commands " + plugin.ToLower());
                        window.AppendString("] ");
                        window.AppendColorEnd();

                        window.AppendHighlight(loader.Name);
                        window.AppendNormal(" (" + commands.Length + " commands)");
                        window.AppendLineBreak();
                    }
                }
            }
            bot.SendReply(e, "Commands »» ", window);
        }
Example #4
0
        private void OnConfigurationCommand(BotShell bot, CommandArgs e)
        {
            string[] plugins = bot.Configuration.ListRegisteredPlugins();
            if (plugins == null || plugins.Length == 0)
            {
                bot.SendReply(e, "No configuration entries registered");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Configuration");
            foreach (string plugin in plugins)
            {
                PluginLoader loader = bot.Plugins.GetLoader(plugin);
                window.AppendNormalStart();
                window.AppendString("[");
                window.AppendBotCommand("Configure", "configuration " + plugin.ToLower());
                window.AppendString("] ");
                window.AppendColorEnd();

                window.AppendHighlight(loader.Name);
                window.AppendNormal(" (" + bot.Configuration.List(plugin).Length + " settings)");
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Configuration »» ", window);
        }
Example #5
0
        private void OnRaidHistoryExtendedCommand(BotShell bot, CommandArgs e)
        {
            int id = -1;

            try { id = Convert.ToInt32(e.Args[0]); }
            catch { }
            if (id < 0)
            {
                bot.SendReply(e, "Invalid RaidID");
                return;
            }
            RaidCore.Raider[] raiders = this._core.GetRaiders(id);
            if (raiders.Length == 0)
            {
                bot.SendReply(e, "There are no raiders listed under that RaidID");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Raiders on Raid #" + id);
            foreach (RaidCore.Raider raider in raiders)
            {
                window.AppendHighlight(raider.Character);
                window.AppendNormalStart();
                if (raider.Character != raider.Main)
                {
                    window.AppendString(" (Main: " + raider.Main + ")");
                }
                window.AppendString(" (" + Math.Round((float)raider.Activity / 60, 1) + " minutes)");
                window.AppendString(" (" + Format.DateTime(raider.JoinTime, FormatStyle.Compact) + " GMT)");
                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Raiders on Raid #" + id + " »» ", window);
        }
Example #6
0
        private void OnHelpCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("VhaBot Help");
            bool found = false;

            foreach (string plugin in bot.Plugins.GetPlugins())
            {
                if (bot.Plugins.IsLoaded(plugin))
                {
                    string[]      commands     = bot.Commands.GetCommands(plugin);
                    List <string> helpCommands = new List <string>();
                    foreach (string command in commands)
                    {
                        CommandRights rights = bot.Commands.GetRights(command);
                        if (rights.Help && !rights.IsAlias)
                        {
                            helpCommands.Add(command);
                        }
                    }
                    helpCommands.Sort();
                    if (helpCommands.Count > 0)
                    {
                        PluginLoader loader = bot.Plugins.GetLoader(plugin);
                        window.AppendHighlight(loader.Name);
                        window.AppendLineBreak();
                        window.AppendNormalStart();
                        int i = 0;
                        foreach (string command in helpCommands)
                        {
                            window.AppendBotCommand(Format.UppercaseFirst(command), "help " + command);
                            i++;
                            if (i < helpCommands.Count)
                            {
                                window.AppendString(", ");
                            }
                        }
                        window.AppendColorEnd();
                        window.AppendLineBreak(2);
                        found = true;
                    }
                }
            }
            if (found)
            {
                bot.SendReply(e, "VhaBot Help »» ", window);
            }
            else
            {
                bot.SendReply(e, "No help available");
            }
        }
Example #7
0
        private void OnAuctionCommand(BotShell bot, CommandArgs e)
        {
            if (!this._running)
            {
                bot.SendReply(e, "There is currently no auction running");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

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

            if (points > this._core.MinimumPoints)
            {
                window.AppendHighlight("Your Points: ");
                if (points > this._currentBid)
                {
                    window.AppendColorString(RichTextWindow.ColorGreen, points.ToString());
                }
                else
                {
                    window.AppendColorString(RichTextWindow.ColorRed, points.ToString());
                }
                window.AppendLineBreak();
            }
            window.AppendHighlight("Time Left: ");
            window.AppendNormal(this._timeLeft.ToString() + " seconds");
            window.AppendLineBreak();
            bot.SendReply(e, "Auction »» ", window);
        }
Example #8
0
        private void OnTeamsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendHighlight(":: ");
            window.AppendColorString(bot.ColorHeaderHex, "Teams");
            window.AppendHighlight(" ::");
            bool found         = false;
            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));
                    int    team     = (int)reader.GetInt64(1);
                    bool   leader   = (reader.GetInt64(2) > 0);
                    if (team != currentTeam)
                    {
                        currentMember = 0;
                        currentTeam   = team;
                        window.AppendLineBreak();
                        window.AppendHighlight("  Team " + team + ": ");
                    }
                    currentMember++;
                    window.AppendNormalStart();
                    window.AppendString("");
                    if (leader)
                    {
                        window.AppendColorString(RichTextWindow.ColorRed, username);
                    }
                    else
                    {
                        window.AppendString(username);
                    }
                    window.AppendString(" ");
                    window.AppendColorEnd();
                    found = true;
                }
                reader.Close();
            }
            if (found)
            {
                bot.SendReply(e, window.Text);
                return;
            }
            bot.SendReply(e, "There are currently no teams setup");
        }
Example #9
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");
            }
        }
Example #10
0
        private void CreateSelectLine(BotShell bot, ref RichTextWindow window, string command)
        {
            CommandRights rights = bot.Commands.GetRights(command);

            command = command.Replace(" ", "_");
            this.CreateSelectPanel(ref window, rights.PrivateMessage, "commands set " + command + " tell");
            window.AppendString(" ");
            this.CreateSelectPanel(ref window, rights.PrivateChannel, "commands set " + command + " pg");
            window.AppendString(" ");
            this.CreateSelectPanel(ref window, rights.Organization, "commands set " + command + " org");
            window.AppendHighlight(" " + Format.UppercaseFirst(command.Replace("_", " ")));

            window.AppendNormalStart();
            window.AppendString(" [");
            window.AppendBotCommand("Reset", "commands reset " + command);
            window.AppendString("]");
            window.AppendColorEnd();
        }
Example #11
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);
        }
Example #12
0
        private void CreateSelectPanel(ref RichTextWindow window, UserLevel right, string command)
        {
            command = command.Trim();
            window.AppendNormalStart();

            window.AppendString("[");
            window.AppendBotCommand("D", command + " Disabled", (right == UserLevel.Disabled));
            window.AppendString(" ");
            window.AppendBotCommand("G", command + " Guest", (right == UserLevel.Guest));
            window.AppendString(" ");
            window.AppendBotCommand("M", command + " Member", (right == UserLevel.Member));
            window.AppendString(" ");
            window.AppendBotCommand("L", command + " Leader", (right == UserLevel.Leader));
            window.AppendString(" ");
            window.AppendBotCommand("A", command + " Admin", (right == UserLevel.Admin));
            window.AppendString(" ");
            window.AppendBotCommand("S", command + " SuperAdmin", (right == UserLevel.SuperAdmin));
            window.AppendString("]");

            window.AppendColorEnd();
        }
Example #13
0
        private void OnRaidListCommand(BotShell bot, CommandArgs e)
        {
            if (!this._core.Running)
            {
                bot.SendReply(e, "There is currently no raid active");
                return;
            }
            RaidCore.Raider[] raiders = this._core.GetRaiders();
            if (raiders.Length == 0)
            {
                bot.SendReply(e, "There is currently nobody on the raid");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Raiders List");
            SortedDictionary <string, Dictionary <RaidCore.Raider, WhoisResult> > sorted = new SortedDictionary <string, Dictionary <RaidCore.Raider, WhoisResult> >();

            foreach (RaidCore.Raider raider in raiders)
            {
                WhoisResult whois = XML.GetWhois(raider.Character, bot.Dimension);
                if (whois == null || !whois.Success)
                {
                    whois                     = new WhoisResult();
                    whois.Name                = new WhoisResult_Name();
                    whois.Name.Nickname       = raider.Character;
                    whois.Stats               = new WhoisResult_Stats();
                    whois.Stats.Level         = 0;
                    whois.Stats.Profession    = "Unknown";
                    whois.Stats.DefenderLevel = 0;
                }
                if (!sorted.ContainsKey(whois.Stats.Profession))
                {
                    sorted.Add(whois.Stats.Profession, new Dictionary <RaidCore.Raider, WhoisResult>());
                }
                sorted[whois.Stats.Profession].Add(raider, whois);
            }
            foreach (KeyValuePair <string, Dictionary <RaidCore.Raider, WhoisResult> > kvp in sorted)
            {
                window.AppendHighlight(kvp.Key);
                window.AppendLineBreak();
                foreach (KeyValuePair <RaidCore.Raider, WhoisResult> raider in kvp.Value)
                {
                    window.AppendNormalStart();
                    window.AppendString("- " + raider.Key.Character);
                    if (raider.Key.Main != raider.Key.Character)
                    {
                        window.AppendString(" (" + raider.Key.Main + ")");
                    }
                    if (raider.Value.Stats.Profession != "Unknown")
                    {
                        window.AppendString(" (L " + raider.Value.Stats.Level + "/" + raider.Value.Stats.DefenderLevel + ")");
                    }
                    if (!raider.Key.OnRaid)
                    {
                        window.AppendString(" (");
                        window.AppendColorString(RichTextWindow.ColorRed, "Inactive");
                        window.AppendString(")");
                    }
                    window.AppendString(" [");
                    window.AppendCommand("Check", "/assist " + raider.Key.Character);
                    window.AppendString("] [");
                    window.AppendBotCommand("Kick", "raid kick " + raider.Key.Character);
                    window.AppendString("] ");
                    window.AppendColorEnd();
                    window.AppendLineBreak(true);
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Raiders List »» ", window);
        }
Example #14
0
        public void OnPluginsInfoCommand(BotShell bot, CommandArgs e)
        {
            PluginLoader info = bot.Plugins.GetLoader(e.Args[1]);

            if (info == null)
            {
                bot.SendReply(e, "Unable to get plugin information");
                return;
            }
            RichTextWindow infoWindow = new RichTextWindow(bot);

            infoWindow.AppendTitle("Plugin Information");
            infoWindow.AppendHighlight("Name: ");
            infoWindow.AppendNormal(info.Name);
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Version: ");
            infoWindow.AppendNormal(info.Version.ToString());
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Author: ");
            infoWindow.AppendNormal(info.Author);
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Internal Name: ");
            infoWindow.AppendNormal(info.InternalName);
            infoWindow.AppendLineBreak();
            if (info.Description != null)
            {
                infoWindow.AppendHighlight("Description: ");
                infoWindow.AppendNormal(info.Description);
                infoWindow.AppendLineBreak();
            }
            infoWindow.AppendHighlight("State: ");
            infoWindow.AppendNormal(bot.Plugins.GetState(info.InternalName).ToString());
            infoWindow.AppendLineBreak();
            if (info.Commands.Length > 0)
            {
                infoWindow.AppendHighlight("Commands: ");
                infoWindow.AppendLineBreak();
                bool isLoaded = bot.Plugins.IsLoaded(info.InternalName);
                lock (info)
                {
                    foreach (Command command in info.Commands)
                    {
                        infoWindow.AppendNormalStart();
                        infoWindow.AppendString("  " + Format.UppercaseFirst(command.CommandName));
                        if (!isLoaded && bot.Commands.Exists(command.CommandName))
                        {
                            infoWindow.AppendString(" (");
                            infoWindow.AppendColorString(RichTextWindow.ColorRed, "Conflict with " + bot.Plugins.GetName(bot.Commands.GetInternalName(command.CommandName)));
                            infoWindow.AppendString(")");
                        }
                        infoWindow.AppendColorEnd();
                        infoWindow.AppendLineBreak();
                    }
                }
            }
            if (info.Dependencies.Length > 0)
            {
                infoWindow.AppendHighlight("Dependencies: ");
                infoWindow.AppendLineBreak();
                lock (info)
                {
                    foreach (string dependency in info.Dependencies)
                    {
                        infoWindow.AppendNormalStart();
                        infoWindow.AppendString("  ");
                        if (bot.Plugins.Exists(dependency))
                        {
                            infoWindow.AppendString(bot.Plugins.GetName(dependency));
                            infoWindow.AppendString(" (");
                            if (bot.Plugins.IsLoaded(dependency))
                            {
                                infoWindow.AppendColorString(RichTextWindow.ColorGreen, "Loaded");
                            }
                            else
                            {
                                infoWindow.AppendColorString(RichTextWindow.ColorOrange, "Not Loaded");
                            }
                            infoWindow.AppendString(") [");
                            infoWindow.AppendCommand("Info", "plugins info " + dependency);
                            infoWindow.AppendString("]");
                        }
                        else
                        {
                            infoWindow.AppendString(dependency + " (");
                            infoWindow.AppendColorString(RichTextWindow.ColorRed, "Not Found");
                            infoWindow.AppendString(")");
                        }
                        infoWindow.AppendColorEnd();
                        infoWindow.AppendLineBreak();
                    }
                }
            }
            bot.SendReply(e, "Plugin Information »» " + infoWindow.ToString());
        }
Example #15
0
        private void OnHistoryCommand(BotShell bot, CommandArgs e)
        {
            if (bot.GetUserID(e.Args[0]) < 100)
            {
                bot.SendReply(e, "No such user: "******"'s History »» Gathering Data...");

            HistoryResult history = XML.GetHistory(e.Args[0].ToLower(), bot.Dimension);

            if (history == null || history.Items == null)
            {
                bot.SendReply(e, "Unable to gather information on that user " + this.TimeoutError);
                return;
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Auno.org Player History");
            window.AppendHighlight("Character: ");
            window.AppendNormal(Format.UppercaseFirst(e.Args[0]));
            window.AppendLineBreak();
            window.AppendHighlight("Entries: ");
            window.AppendNormal(history.Items.Length.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("URL: ");
            window.AppendNormal(string.Format(this.CharAunoWebsite, (int)bot.Dimension, e.Args[0].ToLower()));
            window.AppendLineBreak(2);

            window.AppendHighlightStart();
            window.AppendString("Date             ");
            window.AppendString("LVL   ");
            window.AppendString("DR   ");
            window.AppendColorString("000000", "'");
            window.AppendString("Faction   ");
            window.AppendString("Organization");
            window.AppendColorEnd();
            window.AppendLineBreak();

            foreach (HistoryResult_Entry entry in history.Items)
            {
                window.AppendNormalStart();
                window.AppendString(entry.Date);
                window.AppendHighlight(" | ");
                window.AppendString(entry.Level.ToString("000"));
                window.AppendHighlight(" | ");
                window.AppendString(entry.DefenderLevel.ToString("00"));
                window.AppendHighlight(" | ");
                switch (entry.Faction.ToLower())
                {
                case "clan":
                    window.AppendString("Clan    ");
                    break;

                case "omni":
                    window.AppendString("Omni   ");
                    break;

                case "neutral":
                    window.AppendString("Neutral");
                    break;

                default:
                    window.AppendString("Unknown");
                    break;
                }
                window.AppendHighlight(" | ");
                if (entry.Organization != null && entry.Organization != String.Empty)
                {
                    window.AppendString(entry.Rank);
                    window.AppendString(" of ");
                    window.AppendString(entry.Organization);
                }
                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, Format.UppercaseFirst(e.Args[0]) + "'s History »» ", window);
        }
Example #16
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);
        }
Example #17
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;
            }
        }
Example #18
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;
            }
        }
Example #19
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");
        }
Example #20
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);
        }
Example #21
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);
        }
Example #22
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);
        }
Example #23
0
        public void BuildList(BotShell bot, string[] users, ref RichTextWindow window, ref int results, string profs)
        {
            if (window == null)
            {
                return;
            }
            if (users.Length == 0)
            {
                return;
            }

            SortedDictionary <string, SortedDictionary <string, WhoisResult> > list = new SortedDictionary <string, SortedDictionary <string, WhoisResult> >();
            Dictionary <string, WhoisResult> whoisResults = new Dictionary <string, WhoisResult>();

            foreach (string user in users)
            {
                if (user == null || user == string.Empty)
                {
                    continue;
                }

                string      header;
                WhoisResult whois = XML.GetWhois(user, bot.Dimension);
                if (profs != null && profs != string.Empty)
                {
                    if (whois == null || whois.Stats == null)
                    {
                        continue;
                    }
                    if (!whois.Stats.Profession.StartsWith(profs, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }
                }
                if (whois != null && whois.Stats != null)
                {
                    if (this.DisplayMode == "Level")
                    {
                        header = whois.Stats.Level.ToString();
                    }
                    else
                    {
                        header = whois.Stats.Profession;
                    }

                    if (!whoisResults.ContainsKey(user.ToLower()))
                    {
                        whoisResults.Add(user.ToLower(), whois);
                    }
                }
                else
                if (this.DisplayMode == "Level")
                {
                    header = "0";
                }
                else
                {
                    header = "Unknown";
                }

                if (this.DisplayMode == "Alphabetical")
                {
                    header = user.ToUpper().ToCharArray()[0].ToString();
                }

                if (!list.ContainsKey(header))
                {
                    list.Add(header, new SortedDictionary <string, WhoisResult>());
                }
                list[header].Add(user, whois);
            }
            results = 0;
            foreach (KeyValuePair <string, SortedDictionary <string, WhoisResult> > prof in list)
            {
                if (this.DisplayHeaders == "Text")
                {
                    window.AppendHighlight(prof.Key);
                    window.AppendLineBreak();
                }
                else if (this.DisplayHeaders == "Icons")
                {
                    window.AppendImage("GFX_GUI_FRIENDLIST_SPLITTER");
                    window.AppendLineBreak();
                    window.AppendIcon(Icons[prof.Key]);
                    window.AppendHighlight(prof.Key);
                    window.AppendLineBreak();
                    window.AppendImage("GFX_GUI_FRIENDLIST_SPLITTER");
                    window.AppendLineBreak();
                }
                foreach (KeyValuePair <string, WhoisResult> user in prof.Value)
                {
                    // Name
                    window.AppendNormalStart();
                    window.AppendString("   ");
                    int    level   = 0;
                    int    ailevel = 0;
                    string name    = Format.UppercaseFirst(user.Key);

                    // Level
                    if (user.Value != null && user.Value.Stats != null)
                    {
                        level   = user.Value.Stats.Level;
                        ailevel = user.Value.Stats.DefenderLevel;
                    }
                    if (level < 10)
                    {
                        window.AppendColorString("000000", "00");
                    }
                    else if (level < 100)
                    {
                        window.AppendColorString("000000", "0");
                    }
                    window.AppendString(level + " ");

                    if (ailevel < 10)
                    {
                        window.AppendColorString("000000", "0");
                    }
                    window.AppendColorString(RichTextWindow.ColorGreen, ailevel + " ");
                    window.AppendString(name);

                    // Organization
                    bool displayOrganization = false;
                    if (this.DisplayOrganization == "Always")
                    {
                        displayOrganization = true;
                    }

                    if (this.DisplayOrganization == "Foreign")
                    {
                        displayOrganization = true;
                        if (bot.InOrganization && whoisResults.ContainsKey(name.ToLower()) && whoisResults[name.ToLower()].InOrganization && bot.Organization == whoisResults[name.ToLower()].Organization.Name)
                        {
                            displayOrganization = false;
                        }
                    }

                    if (displayOrganization)
                    {
                        if (!whoisResults.ContainsKey(name.ToLower()))
                        {
                            window.AppendString(" (Unknown)");
                        }
                        else if (whoisResults[name.ToLower()].InOrganization)
                        {
                            window.AppendString(" (" + whoisResults[name.ToLower()].Organization.ToString() + ")");
                        }
                        else
                        {
                            window.AppendString(" (Not Guilded)");
                        }
                    }

                    // Rank
                    if (this.DisplayRanks)
                    {
                        UserLevel userLevel = bot.Users.GetUser(name);
                        if (userLevel > UserLevel.Member)
                        {
                            window.AppendString(" (");
                            window.AppendColorString(RichTextWindow.ColorRed, bot.Users.GetUser(name).ToString());
                            window.AppendString(")");
                        }
                    }

                    // Alts
                    if (this.DisplayAlts)
                    {
                        string   main = bot.Users.GetMain(name);
                        string[] alts = bot.Users.GetAlts(main);
                        if (alts.Length > 0)
                        {
                            window.AppendString(" :: ");
                            if (main == name)
                            {
                                window.AppendBotCommand("Alts", "alts " + main);
                            }
                            else
                            {
                                window.AppendBotCommand(main + "'s Alts", "alts " + main);
                            }
                        }
                    }

                    // Afk
                    if (this.DisplayAfk)
                    {
                        lock (this.Afk)
                        {
                            if (this.Afk.ContainsKey(name))
                            {
                                window.AppendString(" :: ");
                                window.AppendColorString(RichTextWindow.ColorRed, "AFK");
                            }
                        }
                    }
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                    results++;
                }
                if (this.DisplayHeaders == "Text" || this.DisplayHeaders == "Icons")
                {
                    window.AppendLineBreak();
                }
            }
            if (this.DisplayHeaders == "Off")
            {
                window.AppendLineBreak();
            }
        }
Example #24
0
        private void OnCommandsMapCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

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

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

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

                        window.AppendNormal(" (" + tell + pg + org + "/" + d_tell + d_pg + d_org + ")");
                        window.AppendLineBreak();
                    }
                }
                else
                {
                    window.AppendNormal("No commands available");
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Commands Map »» ", window);
        }
Example #25
0
        private void OnVerifyCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: verify [id]");
                return;
            }
            int id = 0;

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

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

                // Send reply
                if (results > 1)
                {
                    bot.SendReply(e, reply + " »» ", window, "More Information");
                }
                else
                {
                    bot.SendReply(e, reply);
                }
            }
        }
Example #26
0
        private void OnConfigurationDisplayCommand(BotShell bot, CommandArgs e)
        {
            string internalName = e.Args[0].ToLower();

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

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

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

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

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

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

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

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

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

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

                case ConfigType.Custom:
                    string value10 = bot.Configuration.GetCustom(entry.Section, entry.Key);
                    if (value10 != null)
                    {
                        window.AppendRawString(value10);
                    }
                    break;
                }
                window.AppendString(" [");
                window.AppendBotCommand("Default", "configuration reset " + internalName + " " + entry.Key.ToLower());
                window.AppendString("]");
                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Configuration »» " + loader.Name + " »» ", window);
        }
Example #27
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            if (e.FromSlave && e.Type == CommandType.PrivateChannel)
            {
                return;
            }

            switch (e.Command)
            {
            case "lock":
                if (this._locked)
                {
                    bot.SendReply(e, "The private channel already is locked");
                    return;
                }
                this._lockedBy = e.Sender;
                this._locked   = true;
                string lockMessage = bot.ColorHeader + e.Sender + bot.ColorHighlight + " has locked the private channel";
                this.SendMessage(bot, lockMessage);
                break;

            case "unlock":
                if (!this._locked)
                {
                    bot.SendReply(e, "The private channel already is unlocked");
                    return;
                }
                this._locked = false;
                string unlockMessage = bot.ColorHeader + e.Sender + bot.ColorHighlight + " has unlocked the private channel";
                this.SendMessage(bot, unlockMessage);
                break;

            case "join":
                if (bot.PrivateChannel.IsOn(e.SenderID))
                {
                    bot.SendReply(e, "You already are on the private channel");
                    return;
                }
                if (this._locked && bot.Users.GetUser(e.Sender) < UserLevel.Leader)
                {
                    bot.SendReply(e, "The private channel is currently locked by " + bot.ColorHeader + this._lockedBy);
                    return;
                }
                bot.SendReply(e, "Inviting you to the private channel");
                bot.PrivateChannel.Invite(e.SenderID);
                break;

            case "leave":
                if (!bot.PrivateChannel.IsOn(e.SenderID))
                {
                    bot.SendReply(e, "You're not on the private channel");
                    return;
                }
                if (e.Type != CommandType.PrivateChannel)
                {
                    bot.SendReply(e, "Kicking you from the private channel");
                }

                // Remove a user from the vhabot raid system before letting him leave
                if (bot.Plugins.IsLoaded("raidcore"))
                {
                    bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "RemoveRaider", 1000, e.Sender);
                }

                bot.PrivateChannel.Kick(e.SenderID);
                break;

            case "invite":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: invite [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******" already is on the private channel");
                    break;
                }
                if (this._locked && bot.Users.GetUser(e.Sender) < UserLevel.Leader)
                {
                    bot.SendReply(e, "The private channel is currently locked by " + bot.ColorHeader + this._lockedBy);
                    return;
                }
                bot.SendReply(e, "Inviting " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " to the private channel");
                bot.PrivateChannel.Invite(e.Args[0]);
                break;

            case "kick":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: kick [username]");
                    break;
                }
                if (e.Args[0].ToLower() == "all")
                {
                    bot.SendReply(e, "Clearing the private channel");
                    bot.PrivateChannel.KickAll();
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******" isn't on the private channel");
                    break;
                }
                if (bot.Users.GetMain(e.Args[0]).Equals(bot.Admin, StringComparison.CurrentCultureIgnoreCase))
                {
                    bot.SendReply(e, "You can't kick the bot owner");
                    break;
                }
                if (bot.Users.GetUser(e.Args[0]) > bot.Users.GetUser(e.Sender))
                {
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " outranks you");
                    break;
                }
                // Remove a user from the vhabot raid system before kicking them
                if (bot.Plugins.IsLoaded("RaidCore"))
                {
                    bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "RemoveRaider", 1000, e.Args[0]);
                }

                bot.SendReply(e, "Kicking " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " from the private channel");
                bot.PrivateChannel.Kick(e.Args[0]);
                break;

            case "guestlist":
                string[] guestlist = bot.FriendList.List("guestlist");
                if (guestlist.Length == 0)
                {
                    bot.SendReply(e, "There are no users on the guestlist");
                    break;
                }
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Guestlist");
                foreach (string guest in guestlist)
                {
                    window.AppendHighlight(Format.UppercaseFirst(guest));
                    window.AppendNormalStart();
                    window.AppendString(" [");
                    window.AppendBotCommand("Remove", "guestlist remove " + guest);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }
                bot.SendReply(e, guestlist.Length + " Guests »» ", window);
                break;

            case "guestlist add":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: guestlist add [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"guestlist", e.Args[0]))
                {
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " already is on the guestlist");
                    break;
                }
                bot.FriendList.Add("guestlist", e.Args[0]);
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " has been added to the guestlist");
                break;

            case "guestlist remove":
                if (e.Args.Length < 1)
                {
                    if (bot.FriendList.IsFriend("guestlist", e.Sender))
                    {
                        bot.SendReply(e, "You have been removed from the guestlist");
                        bot.FriendList.Remove("guestlist", e.Sender);
                    }
                    else
                    {
                        bot.SendReply(e, "You're not on the guestlist");
                    }
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"guestlist", e.Args[0]))
                {
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " is not on the guestlist");
                    break;
                }
                bot.FriendList.Remove("guestlist", e.Args[0]);
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " has been removed from the guestlist");
                break;
            }
        }
Example #28
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);
        }
Example #29
0
        private void OnRaidLogs(BotShell bot, CommandArgs e)
        {
            Dictionary <string, string> colors = new Dictionary <string, string>();

            colors.Add("raid", RichTextWindow.ColorOrange);
            colors.Add("raiders", "FF4500");
            colors.Add("credits", "ADFF2F");
            colors.Add("points", "00FFFF");
            colors.Add("auction", "A52A2A");

            int max = 250;

            RaidCore.LogEntry[] logs = new RaidCore.LogEntry[0];
            string title;

            if (e.Args.Length > 0)
            {
                try
                {
                    // Try if it's a raid ID
                    logs  = this._core.GetLogs(0, Convert.ToInt32(e.Args[0]));
                    title = logs.Length + " Log Entries on Raid #" + Convert.ToInt32(e.Args[0]);
                }
                catch
                {
                    // No raid ID, player maybe?
                    e.Args[0] = bot.Users.GetMain(e.Args[0]);
                    logs      = this._core.GetLogs(0, e.Args[0]);
                    title     = logs.Length + " Log Entries for " + Format.UppercaseFirst(e.Args[0]);
                }
            }
            else
            {
                // No arguments, let's just fetch the last entries
                logs  = this._core.GetLogs(max);
                title = logs.Length + " Last Log Entries";
            }
            if (logs.Length == 0)
            {
                bot.SendReply(e, "No log entries found");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle(title);
            foreach (RaidCore.LogEntry log in logs)
            {
                window.AppendHighlight("[" + log.Time.ToString("dd/MM/yyyy hh:mm:ss") + "] ");
                window.AppendNormalStart();

                if (log.RaidID > 0)
                {
                    window.AppendString("[");
                    window.AppendColorString(colors["raid"], "Raid #" + log.RaidID);
                    window.AppendString("] ");
                }

                window.AppendString("[");
                if (colors.ContainsKey(log.Type.ToLower()))
                {
                    window.AppendColorString(colors[log.Type.ToLower()], Format.UppercaseFirst(log.Type));
                }
                else
                {
                    window.AppendString(Format.UppercaseFirst(log.Type));
                }
                window.AppendString("] ");

                window.AppendString(log.Message);

                if (log.Admin != null && log.Admin != string.Empty)
                {
                    window.AppendString(" (Admin: " + log.Admin + ")");
                }

                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, title + " »» ", window);
        }