Example #1
0
        private void OnAltsAdminAddCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Correct Usage: alts admin add [main] [alt]");
                return;
            }
            string main = Format.UppercaseFirst(e.Args[0]);
            string alt  = Format.UppercaseFirst(e.Args[1]);

            if (bot.GetUserID(main) < 1)
            {
                bot.SendReply(e, "No such user: "******"No such user: "******" is an alt of " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(bot.Users.GetMain(main))));
                return;
            }
            if (!bot.Users.UserExists(main))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, main) + " is not a member of this bot");
                return;
            }
            if (bot.Users.IsAlt(alt))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " already has been added as alt of " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(bot.Users.GetMain(alt))));
                return;
            }
            if (bot.Users.GetAlts(alt).Length > 0)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " is a main and has alts. You can't add a user with alts as alt!");
                return;
            }
            if (bot.Users.GetUser(main) > bot.Users.GetUser(e.Sender))
            {
                bot.SendReply(e, "You can't add alts to a user that outranks you!");
                return;
            }
            if (bot.Users.GetUser(main) < bot.Users.GetUser(alt))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " outranks " + HTML.CreateColorString(bot.ColorHeaderHex, main) + " and can't be added as alt");
                return;
            }
            if (bot.Users.GetUser(alt) > UserLevel.Guest)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " was a member of this bot and has been removed prior to being added as alt");
                bot.Users.RemoveUser(alt);
            }
            bot.Users.AddAlt(main, alt);
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " has been added as alt of " + HTML.CreateColorString(bot.ColorHeaderHex, main));
        }
Example #2
0
        private void OnAltsAdminRemoveCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: alts admin remove [alt]");
                return;
            }
            string alt = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(alt) < 1)
            {
                bot.SendReply(e, "No such user: "******" is not an alt");
            }
            if (bot.Users.GetUser(bot.Users.GetMain(alt)) > bot.Users.GetUser(e.Sender))
            {
                bot.SendReply(e, "You can't remove alts from a user that outranks you!");
                return;
            }
            bot.Users.RemoveAlt(alt);
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " has been removed as your alt");
        }
Example #3
0
        private void OnSecurityFixidCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: security fixid [username]");
                return;
            }
            string username = Config.EscapeString(Format.UppercaseFirst(e.Args[0]));
            UInt32 userID   = bot.GetUserID(username);

            if (userID < 1)
            {
                bot.SendReply(e, "No such user: "******"UPDATE alts SET altID = " + userID + " WHERE altname = '" + username + "'");
                bot.SendReply(e, "Updated " + HTML.CreateColorString(bot.ColorHeaderHex, username + "'s") + " character id to " + HTML.CreateColorString(bot.ColorHeaderHex, userID.ToString()));
                return;
            }
            if (this._host.IsMember(username))
            {
                this._database.ExecuteNonQuery("UPDATE members SET userID = " + userID + " WHERE username = '******'");
                bot.SendReply(e, "Updated " + HTML.CreateColorString(bot.ColorHeaderHex, username + "'s") + " character id to " + HTML.CreateColorString(bot.ColorHeaderHex, userID.ToString()));
                return;
            }
            bot.SendReply(e, "Unable to fix " + HTML.CreateColorString(bot.ColorHeaderHex, username));
        }
Example #4
0
        private void OnRaidUnbanCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: raid unban [username]");
                return;
            }
            string character = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(character) < 100)
            {
                bot.SendReply(e, "No such user: "******" is not banned from this raid");
                    return;
                }
                character = this._bans[main].Character;
                this._bans.Remove(main);
                bot.SendPrivateMessage(character, this._bot.ColorHighlight + "Your access to the raid has been restored by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender));
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character) + " has been unbanned from the raid");
                this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0} has been unbanned from the raid", character));
            }
        }
Example #5
0
 private void OnIsCommand(BotShell bot, CommandArgs e)
 {
     foreach (string username in e.Args)
     {
         UInt32      userid = bot.GetUserID(username);
         OnlineState state  = bot.FriendList.IsOnline(userid);
         if (state == OnlineState.Timeout)
         {
             bot.SendReply(e, "Request timed out. Please try again later");
             return;
         }
         if (state == OnlineState.Unknown)
         {
             bot.SendReply(e, "No such user: "******"Online");
         if (state == OnlineState.Offline)
         {
             append = HTML.CreateColorString(RichTextWindow.ColorRed, "Offline");
             Int64 seen = bot.FriendList.Seen(username);
             if (seen > 1)
             {
                 append += " and was last seen online at " + HTML.CreateColorString(bot.ColorHeaderHex, Format.DateTime(seen, FormatStyle.Large) + " GMT");
             }
         }
         bot.SendReply(e, String.Format("{0} is currently {1}", Format.UppercaseFirst(username), append));
     }
 }
Example #6
0
        private void OnTasksAddCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Correct Usage: tasks add [username] [task]");
                return;
            }
            string username = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(username) < 100)
            {
                bot.SendReply(e, "No such user: "******" isn't online right now");
                return;
            }
            string task = e.Words[1];

            this._database.ExecuteNonQuery("DELETE FROM tasks WHERE username = '******'");
            this._database.ExecuteNonQuery(string.Format("INSERT INTO tasks (username, task) VALUES ('{0}', '{1}')", username, Config.EscapeString(task)));
            bot.SendReply(e, "You have assigned a task to " + HTML.CreateColorString(bot.ColorHeaderHex, username));
            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has assigned " + HTML.CreateColorString(bot.ColorHeaderHex, username) + " the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, task));
            bot.SendPrivateMessage(username, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has assigned you the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, task));
        }
Example #7
0
        private void OnAltsCommand(BotShell bot, CommandArgs e)
        {
            string username = "";

            if (e.Args.Length < 1)
            {
                //{
                //     bot.SendReply(e, "Correct Usage: " + e.Command + " [username]");
                //     return;
                //}
                username = e.Sender;
            }
            else
            {
                username = e.Args[0];
            }
            if (bot.GetUserID(username) < 1)
            {
                bot.SendReply(e, "No such user: "******" doesn't have any alts");
                return;
            }
            bot.SendReply(e, main + "'s characters »» ", window);
        }
Example #8
0
        private void OnTeamsRemoveCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: teams remove [username]");
                return;
            }
            string username = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(username) < 100)
            {
                bot.SendReply(e, "No such user: "******"SELECT * FROM teams WHERE username = '******'";
                IDataReader reader = command.ExecuteReader();
                if (!reader.Read())
                {
                    reader.Close();
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, username) + " is not on any team");
                    return;
                }
                reader.Close();
            }
            this._database.ExecuteNonQuery("DELETE FROM teams WHERE username = '******'");
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, username) + " has been removed from the team");
            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, username) + " has been removed from the team");
        }
Example #9
0
        private void OnMassCommand(BotShell bot, CommandArgs e, bool invite)
        {
            if (e.Words.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: " + e.Command + " [message]");
                return;
            }
            string[] members = this.GetOnlineMembers();
            if (invite)
            {
                bot.SendReply(e, "Sending out an mass invite to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members");
            }
            else
            {
                bot.SendReply(e, "Sending out an announcement to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members");
            }
            string message = bot.ColorHighlight + "Message from " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " »» " + bot.ColorNormal + e.Words[0];

            foreach (string member in members)
            {
                if (invite && !bot.PrivateChannel.IsOn(member))
                {
                    bot.PrivateChannel.Invite(member);
                }
            }
            foreach (string member in members)
            {
                bot.SendPrivateMessage(bot.GetUserID(member), message, AoLib.Net.PacketQueue.Priority.Low, true);
            }
        }
Example #10
0
        private void OnTeamsLeaderCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Correct Usage: teams set [username] [team]");
                return;
            }
            string username = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(username) < 100)
            {
                bot.SendReply(e, "No such user: "******"Invalid Team: " + HTML.CreateColorString(bot.ColorHeaderHex, e.Args[1]));
                return;
            }
            this._database.ExecuteNonQuery("DELETE FROM teams WHERE username = '******'");
            this._database.ExecuteNonQuery("UPDATE teams SET leader = 0 WHERE team = " + team);
            this._database.ExecuteNonQuery(string.Format("INSERT INTO teams (username, team, leader) VALUES ('{0}', {1}, 1)", username, team));
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, username) + " is now the leader of team " + HTML.CreateColorString(bot.ColorHeaderHex, team.ToString()));
            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, username) + " is now leader of team " + HTML.CreateColorString(bot.ColorHeaderHex, team.ToString()));
        }
Example #11
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 #12
0
        private void OnRaidBanCommand(BotShell bot, CommandArgs e)
        {
            int duration = 0;

            try
            {
                if (e.Args.Length < 2)
                {
                    throw new Exception();
                }
                duration = Convert.ToInt32(e.Args[1]);
                if (duration < 1)
                {
                    throw new Exception();
                }
            }
            catch
            {
                bot.SendReply(e, "Correct Usage: raid ban [username] [minutes]");
                return;
            }
            string character = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(character) < 100)
            {
                bot.SendReply(e, "No such user: "******"The duration of your suspension has been set to " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender));
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character + "'s") + " raid ban duration has been updated to " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes");
                    this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0}'s raid ban duration has been updated to {1} minutes", character, banned.Duration));
                }
                else
                {
                    bot.SendPrivateMessage(character, bot.ColorHighlight + "Your access to the raid has been suspended for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender));
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character) + " has been banned from the raid for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes");
                    this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0} has banned from the raid for {1} minutes", character, banned.Duration));
                }
                this._bans.Add(main, banned);
            }
        }
Example #13
0
        public override void OnPluginMessage(BotShell bot, PluginMessage message)
        {
            try
            {
                if (message.Command != "announce")
                {
                    return;
                }
                if (message.Args.Length < 3)
                {
                    return;
                }

                string group = (string)message.Args[0];
                if (group == null || group == string.Empty)
                {
                    return;
                }
                string source = (string)message.Args[1];
                if (source == null || source == string.Empty)
                {
                    return;
                }
                string sender = (string)message.Args[2];
                if (sender == null || sender == string.Empty)
                {
                    return;
                }
                string msg = (string)message.Args[3];
                if (msg == null || msg == string.Empty)
                {
                    return;
                }

                string   formattedMessage = bot.ColorHighlight + "Message from " + HTML.CreateColorString(bot.ColorHeaderHex, sender) + " on " + HTML.CreateColorString(bot.ColorHeaderHex, source) + " »» " + bot.ColorNormal + msg;
                string[] members          = this._friendsList.GetOnlineMembers(group, true);
                bot.SendPrivateMessage(sender, bot.ColorHighlight + "Sending out an announcement to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members");
                foreach (string member in members)
                {
                    bot.SendPrivateMessage(bot.GetUserID(member), formattedMessage, AoLib.Net.PacketQueue.Priority.Low, true);
                }
                members = this._friendsList.GetOnlineMembers(group, false);
                bot.SendReplyMessage(this.InternalName, message, (object)members);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw new Exception("exception", ex);
            }
        }
Example #14
0
        private void OnCreditsRemoveCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 3)
            {
                bot.SendReply(e, "Correct Usage: credits remove [username] [type] [amount]");
                return;
            }
            string raider = Format.UppercaseFirst(bot.Users.GetMain(e.Args[0]));

            if (bot.GetUserID(raider) < 100)
            {
                bot.SendReply(e, "No such user: "******"You need to remove at least 1 raid credit");
                return;
            }
            int max = this.GetCreditsMax(type);

            if (max < 1)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, type.ToString()) + " is not a valid raid credit type");
                return;
            }
            int credits = this.GetCredits(raider, type);

            if (credits <= 0)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " already has 0 raid credits");
                return;
            }
            if (credits - amount < 0)
            {
                amount = credits;
            }
            credits -= amount;
            this._database.ExecuteNonQuery("INSERT INTO credits SET credits = " + credits + ", main = '" + Config.EscapeString(raider) + "', type = " + type + ", lastRaidID = 0 ON DUPLICATE KEY UPDATE credits = " + credits);
            bot.SendReply(e, "You have removed " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " raid credit(s). " + HTML.CreateColorString(bot.ColorHeaderHex, raider) + " now has " + HTML.CreateColorString(bot.ColorHeaderHex, credits.ToString()) + " raid credit(s)");
            this._core.Log(raider, e.Sender, this.InternalName, "credits", string.Format("{1} raid credits have been removed from {0}'s account. (Total Credits: {2})", raider, amount, credits));
        }
Example #15
0
        private void OnAltsAddCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: alts add [alt]");
                return;
            }
            string alt = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(alt) < 1)
            {
                bot.SendReply(e, "No such user: "******"This command can only be used by your main: " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(bot.Users.GetMain(e.Sender))));
                return;
            }
            if (bot.Users.IsAlt(alt))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " already has been added as alt of " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(bot.Users.GetMain(alt))));
                return;
            }
            if (bot.Users.GetUser(alt) > bot.Users.GetUser(e.Sender))
            {
                bot.SendReply(e, "You can't add alts that outrank you!");
                return;
            }
            if (bot.Users.GetAlts(alt).Length > 0)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " is a main with registered alts and can't be added as your alt");
                return;
            }
            if (bot.Users.GetUser(alt) > UserLevel.Guest)
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " was a member of this bot and has been removed prior to being added as alt");
                bot.Users.RemoveUser(alt);
            }
            bot.Users.AddAlt(e.Sender, alt);
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, alt) + " has been added as your alt");
        }
Example #16
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            if (e.Command != "broadcast")
            {
                return;
            }

            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: broadcast [message]");
                return;
            }
            string[] members          = this._friendsList.GetOnlineMembers();
            string   formattedMessage = bot.ColorHighlight + "Broadcast from " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " »» " + bot.ColorNormal + e.Words[0].Trim();

            bot.SendReply(e, "Sending out a broadcast to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members");
            foreach (string member in members)
            {
                bot.SendPrivateMessage(bot.GetUserID(member), formattedMessage, AoLib.Net.PacketQueue.Priority.Low, true);
            }
        }
Example #17
0
        private void OnTeamsStartCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: teams start [username]");
                return;
            }
            string username = Format.UppercaseFirst(e.Args[0]);

            if (bot.GetUserID(username) < 100)
            {
                bot.SendReply(e, "No such user: "******"DELETE FROM teams WHERE username = '******'");
            while (search)
            {
                using (IDbCommand command = this._database.Connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM teams WHERE team = " + team;
                    IDataReader reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        team++;
                    }
                    else
                    {
                        search = false;
                    }
                    reader.Close();
                }
            }
            this._database.ExecuteNonQuery(string.Format("INSERT INTO teams (username, team, leader) VALUES ('{0}', {1}, 1)", username, team));
            bot.SendReply(e, "You have created team " + HTML.CreateColorString(bot.ColorHeaderHex, team.ToString()) + " with " + HTML.CreateColorString(bot.ColorHeaderHex, username) + " as team leader");
            bot.SendPrivateChannelMessage(bot.ColorHighlight + "Team " + HTML.CreateColorString(bot.ColorHeaderHex, team.ToString()) + " has been started with " + HTML.CreateColorString(bot.ColorHeaderHex, username) + " as leader");
        }
Example #18
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 #19
0
        private void OnOrganizationCommand(BotShell bot, CommandArgs e)
        {
            if (bot.GetUserID(e.Args[0]) < 100)
            {
                bot.SendReply(e, "No such user: "******"Organization »» Gathering Data...");

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

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

                    window.AppendTitle(organization.Name);

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

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

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

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

                    membersWindow.AppendHeader("Members");

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

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

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

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

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

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

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

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

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

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

                    window.AppendRawString(membersWindow.Text);

                    bot.SendReply(e, organization.Name + " »» ", window);
                    return;
                }
            }
            bot.SendReply(e, "Unable to gather information on that organization " + this.TimeoutError);
        }
Example #20
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "callers":
                this.OnCallersCommand(bot, e);
                break;

            case "callers add":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: callers add [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"That user is already on the callers list");
                        break;
                    }
                    this.Callers.Add(e.Args[0].ToLower());
                }
                bot.SendReply(e, "Added " + HTML.CreateColorString(bot.ColorHeaderHex, e.Args[0]) + " to the callers list");
                this.OnCallersCommand(bot, e);
                break;

            case "callers remove":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: callers remove [username]");
                    break;
                }
                if (e.Args[0].ToLower() == "all")
                {
                    this.Callers.Clear();
                    bot.SendReply(e, "Clearing the callers list");
                    break;
                }
                lock (this.Callers)
                {
                    if (!this.Callers.Contains(e.Args[0].ToLower()))
                    {
                        bot.SendReply(e, "That user is not on the callers list");
                        break;
                    }
                    this.Callers.Remove(e.Args[0].ToLower());
                }
                bot.SendReply(e, "Removed " + HTML.CreateColorString(bot.ColorHeaderHex, e.Args[0]) + " from the callers list");
                break;

            case "assist":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: assist [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"Assist " + assist);
                assistWindow.AppendHighlight("Create Macro: ");
                assistWindow.AppendCommand("Click", "/macro " + assist + " /assist " + assist);
                assistWindow.AppendLineBreak();
                assistWindow.AppendHighlight("Assist: ");
                assistWindow.AppendCommand("Click", "/assist " + assist);
                assistWindow.AppendLineBreak();
                assistWindow.AppendHighlight("Manual Macro: ");
                assistWindow.AppendNormal("/macro assist /assist " + assist);
                assistWindow.AppendLineBreak();
                bot.SendReply(e, "Assist " + assist + " »» " + assistWindow.ToString());
                break;

            case "target":
                if (e.Words.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: target [target]");
                    break;
                }
                string target = string.Format("{0}::: {1}Assist {3} to Terminate {0}::: {2}{4}", bot.ColorHighlight, HTML.CreateColorStart(RichTextWindow.ColorRed), bot.ColorNormal, e.Sender, e.Words[0]);
                if (e.Type == CommandType.Organization)
                {
                    this.SendMessage(bot, "gc", target);
                }
                else
                {
                    this.SendMessage(bot, "pg", target);
                }
                break;

            case "command":
                if (e.Words.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: command [command]");
                    break;
                }
                string command = string.Format("{0}::: {1}Raid Command from {3} {0}:::\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n    {2}{4}{0}\n______________________________________________", bot.ColorHighlight, HTML.CreateColorStart(RichTextWindow.ColorOrange), bot.ColorNormal, e.Sender, e.Words[0]);
                if (e.Type == CommandType.Organization)
                {
                    this.SendMessage(bot, "gc", command);
                }
                else
                {
                    this.SendMessage(bot, "pg", command);
                }
                break;

            case "order":
                if (e.Words.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: order [order]");
                    break;
                }
                string order = string.Format("{0}::: {1}Raid Order from {3} {0}::: {2}{4}", bot.ColorHighlight, HTML.CreateColorStart(RichTextWindow.ColorOrange), bot.ColorNormal, e.Sender, e.Words[0]);
                if (e.Type == CommandType.Organization)
                {
                    this.SendMessage(bot, "gc", order);
                }
                else
                {
                    this.SendMessage(bot, "pg", order);
                }
                break;

            case "cd":
                string channel = "pg";
                if (e.Type == CommandType.Organization)
                {
                    channel = "gc";
                }

                if (e.Args.Length > 0)
                {
                    if (e.Args[0].ToLower() == "abort")
                    {
                        if (this.Counting)
                        {
                            this.Abort = true;
                            return;
                        }
                        bot.SendReply(e, "No countdown in progress");
                        return;
                    }
                }
                if (this.Counting)
                {
                    bot.SendReply(e, "Countdown already in progress");
                    return;
                }
                this.Counting = true;
                this.Abort    = false;
                string onThree = string.Empty;
                if (e.Words.Length > 0)
                {
                    onThree = e.Words[0];
                }

                for (int i = 5; i >= 0; i--)
                {
                    if (this.Abort == true)
                    {
                        this.SendMessage(bot, channel, bot.ColorHighlight + "Countdown aborted!");
                        break;
                    }
                    if (i == 0)
                    {
                        this.SendMessage(bot, channel, bot.ColorHighlight + "-- " + HTML.CreateColorString(bot.ColorHeaderHex, "GO") + " --");
                        break;
                    }
                    this.SendMessage(bot, channel, bot.ColorHighlight + "--- " + HTML.CreateColorString(bot.ColorHeaderHex, i.ToString()) + " ---");
                    if (i == 3 && onThree != string.Empty)
                    {
                        this.SendMessage(bot, channel, bot.ColorHighlight + "-- " + HTML.CreateColorString(bot.ColorHeaderHex, onThree));
                    }
                    Thread.Sleep(1000);
                }
                this.Counting = false;
                break;

            case "sb":
                this.OnSbCommand(bot, e);
                break;

            case "sb set":
                if (e.Args.Length < 2)
                {
                    bot.SendReply(e, "Correct Usage: sb adminset [username] [state]");
                    break;
                }
                lock (this.Shadowbreeds)
                {
                    if (!this.Shadowbreeds.ContainsKey(e.Args[0].ToLower()))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, e.Args[0]) + " is not on the Shadowbreed list");
                        break;
                    }
                }
                ShadowbreedState state = ShadowbreedState.Unknown;
                try
                {
                    state = (ShadowbreedState)Enum.Parse(typeof(ShadowbreedState), Format.UppercaseFirst(e.Args[1]));
                }
                catch
                {
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, e.Args[1]) + " is not a valid state.");
                    break;
                }
                lock (this.Shadowbreeds)
                    this.Shadowbreeds[e.Args[0].ToLower()] = state;
                bot.SendReply(e, "Shadowbreed state for " + HTML.CreateColorString(bot.ColorHeaderHex, e.Args[0]) + " has been set to " + this.ColorizeState(state));
                break;

            case "sb reset":
                lock (this.Shadowbreeds)
                {
                    this.Shadowbreeds.Clear();
                    bot.SendReply(e, "The Shadowbreed list has been reseted");
                }
                this.OnSbCommand(bot, e);
                break;

            case "sb get":
                List <string> list = new List <string>();
                lock (this.Shadowbreeds)
                {
                    if (this.Shadowbreeds.Count < 1)
                    {
                        bot.SendReply(e, "The Shadowbreeds list is empty");
                        return;
                    }

                    foreach (KeyValuePair <string, ShadowbreedState> kvp in this.Shadowbreeds)
                    {
                        if (kvp.Value == ShadowbreedState.Unknown)
                        {
                            list.Add(Format.UppercaseFirst(kvp.Key));
                        }
                    }
                }
                if (list.Count < 1)
                {
                    bot.SendReply(e, "All Shadowbreed states are known.");
                    return;
                }
                bot.SendReply(e, "Requesting Shadowbreed state from: " + HTML.CreateColorString(bot.ColorHeaderHex, string.Join(", ", list.ToArray())));
                foreach (string user in list)
                {
                    this.RequestSbState(bot, user);
                }
                break;
            }
        }
Example #21
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "notify":
                string[]       notifyList = bot.FriendList.List("notify");
                RichTextWindow window     = new RichTextWindow(bot);
                window.AppendTitle("Notify List");
                foreach (string user in notifyList)
                {
                    UserLevel userLevel = bot.Users.GetUser(user);
                    window.AppendHighlight(Format.UppercaseFirst(user));
                    window.AppendNormal(" (" + userLevel + ")");
                    window.AppendLineBreak();
                }
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, notifyList.Length.ToString()) + " Users »» ", window);
                break;

            case "notify sync":
                bot.SendReply(e, "Notify »» Synchronizing Friendslist...");
                bot.FriendList.Sync();
                bot.SendReply(e, "Notify »» Synchronized Friendslist");
                break;

            case "notify clean":
                if (e.Args.Length == 0 || e.Args[0] != "confirm")
                {
                    bot.SendReply(e, "This command will remove ALL non-members from the notify list. If you wish to continue use: /tell " +
                                  bot.Character + " notify clean confirm");
                    break;
                }
                string[] notifyList1 = bot.FriendList.List("notify");
                foreach (string user1 in notifyList1)
                {
                    UserLevel userLevel1 = bot.Users.GetUser(user1);
                    if (userLevel1 < UserLevel.Member)
                    {
                        bot.FriendList.Remove("notify", user1);
                    }
                }
                bot.SendReply(e, "All non-members on notify list have been removed");
                break;

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

                case "notify remove":
                    if (!bot.FriendList.IsFriend("notify", username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not on the notify list");
                        break;
                    }
                    bot.FriendList.Remove("notify", username);
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been removed from the notify list");
                    break;
                }
                break;
            }
        }
Example #22
0
        private void OnWhoisCommand(BotShell bot, CommandArgs e, AoLib.Net.Server dimension, Boolean showDimension)
        {
            if (!showDimension && dimension == AoLib.Net.Server.Test)
            {
                bot.SendReply(e, "The whois command is not available on the test server.");
                return;
            }
            if (dimension == bot.Dimension)
            {
                if (bot.GetUserID(e.Args[0]) < 100)
                {
                    bot.SendReply(e, "No such user: "******": ");
                }
                error += "Unable to gather information on that user " + this.TimeoutError;
                bot.SendReply(e, error);
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            builder.Append(" »» " + window.ToString("More Information"));
            bot.SendReply(e, builder.ToString());
        }
Example #23
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 #24
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "members clear":
                if (e.Args.Length == 0 || e.Args[0] != "confirm")
                {
                    bot.SendReply(e, "This command will remove ALL members. If you wish to continue use: /tell " + bot.Character + " members clear confirm");
                    break;
                }
                bot.Users.RemoveAll();
                bot.SendReply(e, "All members have been removed");
                break;

            case "members add":
            case "members remove":
            case "members promote":
            case "members demote":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: " + e.Command + " [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"members add":
                    if (bot.Users.UserExists(username, bot.GetUserID(username)))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is already a member of this bot");
                        break;
                    }
                    if (bot.Users.IsAlt(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is register as alt on this bot");
                        break;
                    }
                    if (bot.Users.AddUser(username, UserLevel.Member, e.Sender))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been added to this bot");
                    }
                    else
                    {
                        bot.SendReply(e, "An unknown error has occurred");
                    }
                    break;

                case "members remove":
                    if (bot.Users.IsAlt(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is alt and can't be removed using this command");
                        break;
                    }
                    if (!bot.Users.UserExists(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot");
                        break;
                    }
                    bot.Users.RemoveUser(username);
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been removed from this bot");
                    break;

                case "members promote":
                    if (!bot.Users.UserExists(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot");
                        break;
                    }
                    UserLevel promotelevel = bot.Users.GetUser(username);
                    if (promotelevel >= bot.Users.GetUser(e.Sender))
                    {
                        bot.SendReply(e, "You can't promote a user to a higher rank than your own rank!");
                        break;
                    }
                    try
                    {
                        promotelevel = (UserLevel)((int)promotelevel * 2);
                        if (promotelevel != UserLevel.Disabled)
                        {
                            if (bot.Users.SetUser(username, promotelevel))
                            {
                                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been promoted to " + HTML.CreateColorString(bot.ColorHeaderHex, promotelevel.ToString()));
                                break;
                            }
                        }
                    }
                    catch { }
                    bot.SendReply(e, "An unknown error has occurred");
                    break;

                case "members demote":
                    if (!bot.Users.UserExists(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot");
                        break;
                    }
                    UserLevel demotelevel = bot.Users.GetUser(username);
                    if (demotelevel > bot.Users.GetUser(e.Sender))
                    {
                        bot.SendReply(e, "You can't demote a user that outranks you!");
                        break;
                    }
                    if (bot.Admin.ToLower() == username.ToLower())
                    {
                        bot.SendReply(e, "You can't demote the main bot administrator!");
                        bot.SendPrivateMessage(bot.Admin, bot.ColorHeader + e.Sender + bot.ColorHighlight + " attempted to demote you!");
                        break;
                    }
                    try
                    {
                        demotelevel = (UserLevel)((int)demotelevel / 2);
                        if (demotelevel != UserLevel.Guest)
                        {
                            if (bot.Users.SetUser(username, demotelevel))
                            {
                                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been demoted to " + HTML.CreateColorString(bot.ColorHeaderHex, demotelevel.ToString()));
                                break;
                            }
                        }
                        else
                        {
                            bot.SendReply(e, "You can't demote a user to a rank below member!");
                            break;
                        }
                    }
                    catch { }
                    bot.SendReply(e, "An unknown error has occurred");
                    break;
                }
                break;

            case "alts add":
                this.OnAltsAddCommand(bot, e);
                break;

            case "alts remove":
                this.OnAltsRemoveCommand(bot, e);
                break;

            case "alts admin add":
                this.OnAltsAdminAddCommand(bot, e);
                break;

            case "alts admin remove":
                this.OnAltsAdminRemoveCommand(bot, e);
                break;
            }
        }
Example #25
0
        private void OnConfigurationSetCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 3)
            {
                bot.SendReply(e, "Usage: configuration set [plugin] [key] [value]");
                return;
            }
            if (!bot.Configuration.IsRegistered(e.Args[0], e.Args[1]))
            {
                bot.SendReply(e, "No such configuration entry");
                return;
            }
            string     section = e.Args[0].ToLower();
            string     key     = e.Args[1].ToLower();
            string     value   = e.Words[2];
            ConfigType type    = bot.Configuration.GetType(section, key);

            bot.Configuration.Exists(section, key);
            object objValue = null;
            bool   error    = false;

            switch (type)
            {
            case ConfigType.Boolean:
                if (value.ToLower() == "on")
                {
                    objValue = true;
                    break;
                }
                if (value.ToLower() == "off")
                {
                    objValue = false;
                    break;
                }
                error = true;
                break;

            case ConfigType.Color:
                if (!Regex.Match(value, "^[#]?[0-9a-f]{6}$", RegexOptions.IgnoreCase).Success)
                {
                    error = true;
                }
                objValue = value;
                break;

            case ConfigType.Date:
                Match dateMatch = Regex.Match(value, "^([0-2][0-9]|3[0-1])/([0]?[0-9]|1[0-2])/([0-9]{4})$", RegexOptions.IgnoreCase);
                if (!dateMatch.Success)
                {
                    error = true;
                    break;
                }
                try
                {
                    int day   = Convert.ToInt32(dateMatch.Groups[1].Value);
                    int month = Convert.ToInt32(dateMatch.Groups[2].Value);
                    int year  = Convert.ToInt32(dateMatch.Groups[3].Value);
                    objValue = new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc);
                }
                catch { error = true; }
                break;

            case ConfigType.Dimension:
                try { objValue = (Server)Enum.Parse(typeof(Server), Format.UppercaseFirst(value)); }
                catch { error = true; }
                break;

            case ConfigType.Integer:
                try { objValue = Convert.ToInt32(value); }
                catch { error = true; }
                break;

            case ConfigType.String:
            case ConfigType.Password:
                objValue = value;
                break;

            case ConfigType.Time:
                Match timeMatch = Regex.Match(value, "^([0-9]+):([0-5][0-9]|60):([0-5][0-9]|60)$", RegexOptions.IgnoreCase);
                if (!timeMatch.Success)
                {
                    error = true;
                    break;
                }
                try
                {
                    int hours   = Convert.ToInt32(timeMatch.Groups[1].Value);
                    int minutes = Convert.ToInt32(timeMatch.Groups[2].Value);
                    int seconds = Convert.ToInt32(timeMatch.Groups[3].Value);
                    objValue = new TimeSpan(hours, minutes, seconds);
                }
                catch { error = true; }
                break;

            case ConfigType.Username:
                if (bot.GetUserID(value) < 10)
                {
                    error = true;
                }
                else
                {
                    objValue = Format.UppercaseFirst(value);
                }
                break;
            }
            if (error)
            {
                bot.SendReply(e, "Invalid Value: " + HTML.CreateColorString(bot.ColorHeaderHex, value));
                return;
            }
            if (bot.Configuration.Set(type, section, key, objValue))
            {
                bot.SendReply(e, "Configuration entry " + HTML.CreateColorString(bot.ColorHeaderHex, section + "::" + key) + " has been set to: " + HTML.CreateColorString(bot.ColorHeaderHex, value));
            }
            else
            {
                bot.SendReply(e, "Unknown error while storing settings!");
            }
        }
Example #26
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "bans":
                this.OnBansCommand(bot, e);
                break;

            case "bans add":
            case "bans remove":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: " + e.Command + " [username]");
                    break;
                }
                if (bot.GetUserID(e.Args[0]) < 1)
                {
                    bot.SendReply(e, "No such user: "******"bans add")
                {
                    if (bot.Bans.IsBanned(username))
                    {
                        bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, username) + " is already banned");
                        break;
                    }
                    if (bot.Bans.Add(username, e.Sender))
                    {
                        bot.SendReply(e, "You have banned " + HTML.CreateColorString(bot.ColorHeaderHex, username));
                    }
                    else
                    {
                        bot.SendReply(e, "Unable to ban " + HTML.CreateColorString(bot.ColorHeaderHex, username));
                    }
                }
                else
                {
                    if (bot.Bans.Remove(username) || bot.Bans.Remove(bot.GetUserID(username)))
                    {
                        bot.SendReply(e, "You have removed " + HTML.CreateColorString(bot.ColorHeaderHex, username + "'s") + " ban");
                    }
                    else
                    {
                        bot.SendReply(e, "No ban found for " + HTML.CreateColorString(bot.ColorHeaderHex, username));
                    }
                }
                break;

            case "bans clear":
                if (e.Args.Length == 0 || e.Args[0] != "confirm")
                {
                    bot.SendReply(e, "This command will remove ALL bans. If you wish to continue use: /tell " + bot.Character + " bans clear confirm");
                    break;
                }
                bot.Bans.RemoveAll();
                bot.SendReply(e, "All bans have been removed");
                break;
            }
        }