예제 #1
0
        private void OnAuctionStartCommand(BotShell bot, CommandArgs e)
        {
            // Special support for Loot Logger
            if (bot.Plugins.IsLoaded("RaidLootLog"))
            {
                bool         lootlog = false;
                ReplyMessage reply   = bot.SendPluginMessageAndWait(this.InternalName, "RaidLootLog", "started", 1000);
                if (reply != null)
                {
                    lootlog = (bool)reply.Args[0];
                }
                if (lootlog)
                {
                    bot.SendReply(e, "You can't start an auction while the Loot Logger is running.");
                    return;
                }
            }
            if (this._running)
            {
                bot.SendReply(e, "An auction has already been started");
                return;
            }
            if (e.Words.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: auction start [item]");
                return;
            }
            this._item     = e.Words[0];
            this._realItem = null;
            this._admin    = e.Sender;
            if (e.Items.Length > 0)
            {
                this._item     = e.Items[0].ToLink();
                this._realItem = e.Items[0];
            }
            else if (e.Args[0].StartsWith("item:") && e.Args.Length > 1)
            {
                string[] tmp = e.Args[0].Substring(5).Split(':');
                if (tmp.Length == 3)
                {
                    try
                    {
                        int    lowID  = Convert.ToInt32(tmp[0]);
                        int    highID = Convert.ToInt32(tmp[0]);
                        int    ql     = Convert.ToInt32(tmp[0]);
                        string name   = HTML.UnescapeString(e.Words[1]);
                        this._realItem = new AoItem(name, lowID, highID, ql, null);
                        this._item     = this._realItem.ToLink();
                    }
                    catch { }
                }
            }
            this._timeLeft   = this._auctionDuration;
            this._currentBid = 0;
            this._proxyBid   = 0;
            this._bidder     = null;
            this._running    = true;
            this._timer.Start();
            string output = string.Format("{0}\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n    {1}{2}{0} has started an auction for {1}{3}\n    {0}This auction will run for {1}{4}{0} seconds\n______________________________________________", bot.ColorHighlight, bot.ColorHeader, e.Sender, this._item, this._timeLeft);

            bot.SendPrivateChannelMessage(output);
            bot.SendReply(e, "You started an auction for " + bot.ColorHeader + this._item);
            this._core.Log(e.Sender, e.Sender, this.InternalName, "auction", e.Sender + " has started an auction for " + HTML.StripTags(this._item));
        }
예제 #2
0
파일: vh_Teams.cs 프로젝트: deathlef/VhaBot
        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);
        }
예제 #3
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;
            }
        }