Пример #1
0
 private void Events_PrivateChannelMessageEvent(BotShell bot, PrivateChannelMessageArgs e)
 {
     if (this.AutoAFK)
     {
         if (e.Message.ToLower().StartsWith("afk"))
         {
             lock (this.Afk)
             {
                 if (this.Afk.ContainsKey(e.Sender))
                 {
                     this.Afk.Remove(e.Sender);
                     bot.SendPrivateChannelMessage(bot.ColorHighlight + e.Sender + " is back");
                 }
                 else
                 {
                     this.Afk.Add(e.Sender, "AFK");
                     bot.SendPrivateChannelMessage(bot.ColorHighlight + e.Sender + " is afk.");
                 }
             }
             return;
         }
     }
     if (e.Command)
     {
         return;
     }
     this.RemoveAfk(bot, e.Sender);
 }
Пример #2
0
 private void OnRaffleStopCommand(BotShell bot, CommandArgs e)
 {
     if (!this._running)
     {
         bot.SendReply(e, "There is no raffle to finish");
         return;
     }
     lock (this._joined)
     {
         bot.SendReply(e, "You have ended the raffle");
         if (this._joined.Count == 0)
         {
             bot.SendPrivateChannelMessage(bot.ColorHighlight + "The raffle has ended without any winners");
         }
         else
         {
             string[] keys = new string[this._joined.Keys.Count];
             this._joined.Keys.CopyTo(keys, 0);
             Random random = new Random();
             int    winner = random.Next(0, keys.Length);
             bot.SendPrivateChannelMessage(bot.ColorHeader + this._joined[keys[winner]] + bot.ColorHighlight + " has won the raffle for " + bot.ColorHeader + this._item);
         }
         this._running  = false;
         this._item     = null;
         this._realItem = null;
         this._admin    = null;
         this._joined.Clear();
     }
 }
Пример #3
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));
        }
Пример #4
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");
        }
Пример #5
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()));
        }
Пример #6
0
 public void OnPrivateChannelMessageEvent(BotShell bot, PrivateChannelMessageArgs e)
 {
     if (e.Items.Length < 1)
     {
         return;
     }
     if (e.Self)
     {
         return;
     }
     if (!e.Local)
     {
         return;
     }
     foreach (AoItem item in e.Items)
     {
         lock (this._items)
         {
             if (!this._items.ContainsKey(item.LowID))
             {
                 continue;
             }
             this._database.ExecuteNonQuery(String.Format("INSERT INTO glyphs SET item = {0}, looter = '{1}', time = {2}, visible = 'true'", item.LowID, e.Sender, TimeStamp.Now));
             bot.SendPrivateChannelMessage(bot.ColorHeader + this._items[item.LowID] + bot.ColorHighlight + " has been looted by " + bot.ColorHeader + e.Sender);
         }
     }
 }
Пример #7
0
        private void OnRaidCreditsCommand(BotShell bot, CommandArgs e)
        {
            int type = -1;

            if (e.Args.Length < 1 || !Int32.TryParse(e.Args[0], out type))
            {
                bot.SendReply(e, "Correct Usage: raid credits [type]");
                return;
            }
            lock (this._database.Connection)
            {
                using (IDbCommand command = this._database.Connection.CreateCommand())
                {
                    command.CommandText = "SELECT name, credits FROM credits_types WHERE type = " + type;
                    IDataReader reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        int    credits = reader.GetInt32(1);
                        string name    = reader.GetString(0);
                        this.CreditsType  = type;
                        this._core.Locked = false;
                        bot.SendReply(e, "The following raid credits type has been selected: " + HTML.CreateColorString(bot.ColorHeaderHex, name));
                        bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, name) + " credits have been selected and the raid has been " + HTML.CreateColorString(RichTextWindow.ColorGreen, "unlocked"));
                    }
                    else
                    {
                        bot.SendReply(e, "Invalid raid credits type");
                    }
                    reader.Close();
                }
            }
        }
Пример #8
0
 public void SendEverywhere(string output)
 {
     _bot.SendPrivateChannelMessage(output);
     if (_bot.InOrganization)
     {
         _bot.SendOrganizationMessage(output);
     }
     return;
 }
Пример #9
0
        private void OnVoteStopCommand(BotShell bot, CommandArgs e)
        {
            if ((this._admin.IndexOf(e.Sender, 0) >= 0) ||
                (bot.Users.GetUser(e.Sender) >= UserLevel.Leader))
            {
                if (!this._running)
                {
                    bot.SendPrivateMessage(e.SenderID, "There is no election to stop");
                    return;
                }
                lock (this._joined)
                {
                    bot.SendPrivateMessage(e.SenderID, "You have ended the election");
                    if ((_quorum > 0) && (this._yes + this._no + this._abs < this._quorum))
                    {
                        bot.SendPrivateChannelMessage(bot.ColorHighlight + "The election has been aborted due to lack of quorum.");
                    }
                    else
                    {
                        string result  = "no";
                        int    require = (this._yes + this._no) * (this._percentage / 100);
                        if (this._yes >= require)
                        {
                            result = "yes";
                        }

                        bot.SendPrivateChannelMessage("The election has ended for: " + _description);
                        bot.SendPrivateChannelMessage("Election result is: " + result);
                    }

                    this._running = false;
                    this._admin   = null;
                    this._joined.Clear();
                    this._yes = 0;
                    this._no  = 0;
                    this._abs = 0;
                }
            }
            else
            {
                bot.SendPrivateMessage(e.SenderID, e.Sender + " was not the person who started the vote or does not have sufficient privileges to end the voting.");
                return;
            }
        }
Пример #10
0
        private void OnRaidAddCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: raid add [username]");
                return;
            }
            if (!this._core.Running)
            {
                bot.SendReply(e, "There is currently no raid active");
                return;
            }
            string raider = Format.UppercaseFirst(e.Args[0]);

            if (!bot.PrivateChannel.IsOn(raider))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is required to be on the private channel to join the raid");
                return;
            }
            if (this._core.IsRaider(raider))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is already in the raid");
                return;
            }
            lock (this._bans)
            {
                string main = bot.Users.GetMain(raider);
                if (this._bans.ContainsKey(main))
                {
                    bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is currently banned from the raid");
                    return;
                }
            }

            int  credits = 0;
            int  max     = 0;
            bool charged = false;

            if (this.CreditsEnabled && !this.WithdrawCredit(bot, raider, out credits, out max, out charged))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " doesn't have enough raid credits to join this raid");
                return;
            }

            this._core.AddRaider(raider, false);
            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has been manually added to the raid");
            bot.SendPrivateMessage(raider, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has added you to the raid");
            this._core.Log(raider, e.Sender, this.InternalName, "raiders", string.Format("{0} has been added the raid (Points: {1})", raider, this._core.GetPoints(raider)));
            if (charged)
            {
                bot.SendPrivateMessage(raider, bot.ColorHighlight + "You have been charged a raid credit for this raid. You have used " + HTML.CreateColorString(bot.ColorHeaderHex, credits + "/" + max) + " raid credits for this type of raid");
                this._core.Log(raider, e.Sender, this.InternalName, "credits", string.Format("{0} has been charged a raid credit (Credits Left: {1})", raider, credits));
            }
        }
Пример #11
0
 private void sendMessage(BotShell bot, string message)
 {
     if (this._sendpg)
     {
         bot.SendPrivateChannelMessage(bot.ColorHighlight + message);
     }
     if (this._sendgc)
     {
         bot.SendOrganizationMessage(bot.ColorHighlight + message);
     }
 }
Пример #12
0
 private void SendMessage(BotShell bot, string target, string message)
 {
     if (target == "gc")
     {
         bot.SendOrganizationMessage(message);
     }
     if (target == "pg")
     {
         bot.SendPrivateChannelMessage(message);
     }
 }
Пример #13
0
 private void Events_BotStateChangedEvent(BotShell bot, BotStateChangedArgs e)
 {
     if (e.IsSlave)
     {
         return;
     }
     if (e.State == BotState.Connected)
     {
         bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Online");
     }
 }
Пример #14
0
 private void RemoveAfk(BotShell bot, string user)
 {
     lock (this.Afk)
     {
         if (!this.Afk.ContainsKey(user))
         {
             return;
         }
         this.Afk.Remove(user);
         bot.SendPrivateChannelMessage(bot.ColorHighlight + user + " is back");
         bot.SendOrganizationMessage(bot.ColorHighlight + user + " is back");
     }
 }
Пример #15
0
 private void Events_UserLeaveChannelEvent(BotShell bot, UserLeaveChannelArgs e)
 {
     lock (this.Shadowbreeds)
         if (this.Shadowbreeds.ContainsKey(e.Sender.ToLower()))
         {
             this.Shadowbreeds.Remove(e.Sender.ToLower());
         }
     lock (this.Callers)
         if (this.Callers.Contains(e.Sender.ToLower()))
         {
             this.Callers.Remove(e.Sender.ToLower());
             bot.SendPrivateChannelMessage(bot.ColorHighlight + "Removed " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " from the callers list");
         }
 }
Пример #16
0
        private void OnRaidKickCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: raid kick [username] [reason]");
                return;
            }
            if (!this._core.Running)
            {
                bot.SendReply(e, "There is currently no raid active");
                return;
            }
            string raider = Format.UppercaseFirst(e.Args[0]);

            if (!this._core.IsRaider(raider))
            {
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is not in the raid");
                return;
            }
            string reason = "No reason specified";

            if (e.Words.Length > 1)
            {
                reason = e.Words[1];
            }
            this._core.RemoveRaider(raider, false);
            if (this.KickedEvent != null)
            {
                this.KickedEvent(this, new RaidEventArgs(raider));
            }
            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has been kicked from the raid");
            bot.SendPrivateMessage(raider, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has kicked you to the raid with the following reason: " + HTML.CreateColorString(bot.ColorHeaderHex, reason));
            this._core.Log(raider, e.Sender, this.InternalName, "raiders", string.Format("{0} has been kicked from the raid (Points: {1})", raider, this._core.GetPoints(e.Sender)));
            if (bot.Configuration.GetBoolean(this.InternalName, "autoban", false))
            {
                string main   = bot.Users.GetMain(raider);
                Raider banned = new Raider();
                banned.Character = raider;
                banned.Duration  = bot.Configuration.GetInteger(this.InternalName, "banduration", 5);
                banned.Time      = DateTime.Now;
                lock (this._bans)
                {
                    this._bans.Add(main, banned);
                }
                bot.SendPrivateMessage(raider, bot.ColorHighlight + "Your access to the raid has been automatically suspended for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes");
                bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has automatically been banned from the raid for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes");
                this._core.Log(raider, e.Sender, this.InternalName, "bans", string.Format("{0} has automatically banned from the raid for {1} minutes", raider, banned.Duration));
            }
        }
Пример #17
0
        private void OnRaffleLeaveCommand(BotShell bot, CommandArgs e)
        {
            string main = bot.Users.GetMain(e.Sender);

            lock (this._joined)
            {
                if (!this._joined.ContainsKey(main))
                {
                    bot.SendReply(e, "You haven't joined the raffle");
                    return;
                }
                this._joined.Remove(main);
                bot.SendReply(e, "You have left the raffle");
                bot.SendPrivateChannelMessage(bot.ColorHeader + e.Sender + bot.ColorHighlight + " has left the raffle");
            }
        }
Пример #18
0
 private void OnRaffleAbortCommand(BotShell bot, CommandArgs e)
 {
     if (!this._running)
     {
         bot.SendReply(e, "There is no raffle to abort");
         return;
     }
     this._running  = false;
     this._item     = null;
     this._realItem = null;
     this._admin    = null;
     lock (this._joined)
         this._joined.Clear();
     bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has aborted the raffle");
     bot.SendReply(e, "You aborted the raffle");
 }
Пример #19
0
 private void OnAuctionAbortCommand(BotShell bot, CommandArgs e)
 {
     if (!this._running)
     {
         bot.SendReply(e, "There is no auction to abort");
         return;
     }
     this._timer.Stop();
     this._running    = false;
     this._item       = null;
     this._timeLeft   = 0;
     this._currentBid = 0;
     this._proxyBid   = 0;
     this._bidder     = null;
     bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has aborted the auction");
     bot.SendReply(e, "You aborted the auction");
     this._core.Log(e.Sender, e.Sender, this.InternalName, "auction", e.Sender + " has aborted the auction");
 }
Пример #20
0
 private void UserJoinChannelEvent(BotShell bot, UserJoinChannelArgs e)
 {
     if (!e.Local)
     {
         return;
     }
     lock (this._lds)
     {
         if (this._lds.ContainsKey(e.Sender))
         {
             if (this._core.AddRaider(e.Sender, false))
             {
                 bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rejoined the raid");
                 bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "Welcome back. You have automatically rejoined the raid");
                 this._core.Log(e.Sender, null, this.InternalName, "raiders", string.Format("{0} has automatically rejoined the raid (Points: {1})", e.Sender, this._core.GetPoints(e.Sender)));
             }
             this._lds.Remove(e.Sender);
         }
     }
 }
Пример #21
0
        private void OnRaffleJoinCommand(BotShell bot, CommandArgs e)
        {
            if (!this._running)
            {
                bot.SendReply(e, "There is no raffle to join");
                return;
            }
            string main = bot.Users.GetMain(e.Sender);

            lock (this._joined)
            {
                if (this._joined.ContainsKey(main))
                {
                    bot.SendReply(e, "You have already joined the raffle");
                    return;
                }
                this._joined.Add(main, e.Sender);
                bot.SendReply(e, "You have joined the raffle");
                bot.SendPrivateChannelMessage(bot.ColorHeader + e.Sender + bot.ColorHighlight + " has joined the raffle");
            }
        }
Пример #22
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");
        }
Пример #23
0
 private void OnVoteAbortCommand(BotShell bot, CommandArgs e)
 {
     if ((this._admin.IndexOf(e.Sender, 0) >= 0) ||
         (bot.Users.GetUser(e.Sender) >= UserLevel.Leader))
     {
         if (!this._running)
         {
             bot.SendPrivateMessage(e.SenderID, "There is election to abort");
             return;
         }
         this._running = false;
         this._admin   = null;
         lock (this._joined)
             this._joined.Clear();
         bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has aborted the election");
         bot.SendPrivateMessage(e.SenderID, "You aborted the election");
     }
     else
     {
         bot.SendPrivateMessage(e.SenderID, e.Sender + " was not the person who started the election and/or does not have sufficient privileges to stop the election.");
         return;
     }
 }
Пример #24
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            // make !status display various stats of the bot and the current state of all slaves and their friendslists, also include links to relog etc
            switch (e.Command)
            {
            case "shutdown":
                bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Shutting Down");
                bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Shutting Down", AoLib.Net.PacketQueue.Priority.Urgent, true);
                bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Shutting Down");
                System.Threading.Thread.Sleep(1000);
                bot.Shutdown();
                break;

            case "restart":
                if (!bot.CoreConnected)
                {
                    bot.SendReply(e, "Restart is not available");
                    return;
                }
                bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Rebooting");
                bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Rebooting", AoLib.Net.PacketQueue.Priority.Urgent, true);
                bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Rebooting");
                System.Threading.Thread.Sleep(1000);
                bot.Restart();
                break;

            case "core":
                this.OnCoreCommand(bot, e);
                break;

            case "core shutdown":
            case "core start":
            case "core restart":
                if (e.Args.Length < 1 || !e.Args[0].Contains("@"))
                {
                    bot.SendReply(e, "Usage: " + e.Command + " [bot@dimension]");
                    return;
                }
                if (!bot.Master)
                {
                    bot.SendReply(e, "This bot is not a master bot");
                    return;
                }
                CoreCommand command;
                if (e.Command == "core shutdown")
                {
                    command = CoreCommand.Shutdown;
                }
                else if (e.Command == "core start")
                {
                    command = CoreCommand.Start;
                }
                else
                {
                    command = CoreCommand.Restart;
                }
                MessageResult result = bot.SendCoreMessage(this.InternalName, e.Args[0].ToLower(), command);
                switch (result)
                {
                case MessageResult.Success:
                    bot.SendReply(e, "Your command has been relayed to the core and will be executed shortly");
                    break;

                case MessageResult.InvalidTarget:
                    bot.SendReply(e, "The target you specified appeared to be invalid");
                    break;

                case MessageResult.NotConnected:
                    bot.SendReply(e, "Unable to connect to the core in order to issue this command");
                    break;

                default:
                    bot.SendReply(e, "An unknown error prevented your command from being executed");
                    break;
                }
                break;

            case "core clean":
                bot.Clean();
                bot.SendReply(e, "Memory cleaning routines have been executed");
                break;
            }
        }
Пример #25
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));
        }
Пример #26
0
        private void Events_PrivateChannelMessageEvent(BotShell bot, PrivateChannelMessageArgs e)
        {
            if (e.Self == true)
            {
                return;
            }

            if (bot.Configuration.GetBoolean(this.InternalName, "inccommands", true) == false)
            {
                if (e.Command == true)
                {
                    return;
                }
            }
            if (bot.Configuration.GetBoolean(this.InternalName, "limmune", true) == true)
            {
                if (bot.Users.GetUser(e.Sender) == UserLevel.Leader)
                {
                    return;
                }
            }
            if (bot.Configuration.GetBoolean(this.InternalName, "aimmune", true) == true)
            {
                if (bot.Users.GetUser(e.Sender) == UserLevel.Admin)
                {
                    return;
                }
            }
            if (bot.Configuration.GetBoolean(this.InternalName, "saimmune", true) == true)
            {
                if (bot.Users.GetUser(e.Sender) == UserLevel.SuperAdmin)
                {
                    return;
                }
            }
            if (Flooder.ContainsKey(e.SenderID))
            {
                Flooder[e.SenderID].FloodCount += 1;
                Flooder[e.SenderID].LastSaid    = TimeStamp.Now;

                // Handles the Pure FloodPart
                long TimeDiff = Flooder[e.SenderID].LastSaid - Flooder[e.SenderID].FirstSaid;
                if (TimeDiff <= bot.Configuration.GetInteger(this.InternalName, "flooddelay", 5) && bot.Configuration.GetInteger(this.InternalName, "flooddelay", 5) != 0)
                {
                    if (bot.Configuration.GetInteger(this.InternalName, "floodkick", 7) != 0 && Flooder[e.SenderID].Kick == false && Flooder[e.SenderID].FloodCount >= bot.Configuration.GetInteger(this.InternalName, "floodkick", 7))
                    {
                        Flooder[e.SenderID].Kick = true;
                        if (bot.PrivateChannel.IsOn(e.SenderID))
                        {
                            bot.PrivateChannel.Kick(e.Sender);
                            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has been removed from the private channel for flooding");
                            bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have been removed from the private channel for flooding!", false);
                        }
                    }
                    else if (bot.Configuration.GetInteger(this.InternalName, "floodwarning", 5) != 0 && Flooder[e.SenderID].FloodCount >= bot.Configuration.GetInteger(this.InternalName, "floodwarning", 5) && Flooder[e.SenderID].Warning == false && Flooder[e.SenderID].Kick == false)
                    {
                        Flooder[e.SenderID].Warning = true;
                        bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "Warning! You're close to being kicked for flooding", false);
                    }
                }
                else
                {
                    Flooder[e.SenderID].FloodCount = 0;
                    Flooder[e.SenderID].FirstSaid  = TimeStamp.Now;
                    Flooder[e.SenderID].Warning    = false;
                }
                // End of flood part

                // Handles the Repeation part
                if (e.Message.ToLower() == Flooder[e.SenderID].LastLine.ToLower())
                {
                    Flooder[e.SenderID].RepeatCount += 1;
                    if (bot.Configuration.GetInteger(this.InternalName, "repeatkick", 4) != 0 && Flooder[e.SenderID].RepeatCount >= bot.Configuration.GetInteger(this.InternalName, "repeatkick", 4) && Flooder[e.SenderID].Kick == false)
                    {
                        Flooder[e.SenderID].Kick = true;
                        if (bot.PrivateChannel.IsOn(e.SenderID))
                        {
                            bot.PrivateChannel.Kick(e.Sender);
                            bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has been removed from the private channel for repeating");
                            bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have been removed from the private channel for repeating!", false);
                        }
                    }
                    else if (bot.Configuration.GetInteger(this.InternalName, "repeatwarning", 3) != 0 && Flooder[e.SenderID].RepeatCount >= bot.Configuration.GetInteger(this.InternalName, "repeatwarning", 3) && Flooder[e.SenderID].Warning == false && Flooder[e.SenderID].Kick == false)
                    {
                        Flooder[e.SenderID].Warning = true;
                        bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "Warning! You're close to being kicked for repeating", false);
                    }
                }
                else
                {
                    Flooder[e.SenderID].RepeatCount = 1;
                }
                Flooder[e.SenderID].LastLine = e.Message;
                // End of repeat part
            }
            else
            {
                Flooder.Add(e.SenderID, new Flooders(e.Sender, TimeStamp.Now, TimeStamp.Now, 1, false, false, e.Message, 1));
            }
        }
Пример #27
0
        private void OnPointsRewardCommand(BotShell bot, CommandArgs e)
        {
            if (!this._core.Running)
            {
                bot.SendReply(e, "There is currently no raid active");
                return;
            }
            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: points reward [amount]");
                return;
            }
            double amount = 0;

            try { amount = Convert.ToDouble(e.Args[0].Replace(".", ",")); }
            catch { }
            if (amount < 0.1)
            {
                bot.SendReply(e, "You need to reward at least 0,1 point");
                return;
            }
            if (e.Args.Length >= 2)
            {
                RaidCore.Raider[]           raiders = this._core.GetRaiders();
                Dictionary <string, double> points  = new Dictionary <string, double>();
                switch (e.Args[1])
                {
                case "activity":
                    foreach (RaidCore.Raider raider in raiders)
                    {
                        if (raider.Activity < 1)
                        {
                            continue;
                        }
                        double reward = (float)raider.Activity / ((float)this._core.TimeRunning.TotalSeconds - (float)this._core.TimePaused.TotalSeconds) * amount;
                        if (reward > amount)
                        {
                            reward = amount;
                        }
                        points.Add(raider.Character, Math.Round(reward, 1));
                    }
                    break;

                case "active":
                    foreach (RaidCore.Raider raider in raiders)
                    {
                        if (raider.OnRaid)
                        {
                            points.Add(raider.Character, amount);
                        }
                    }
                    break;

                case "all":
                    foreach (RaidCore.Raider raider in raiders)
                    {
                        points.Add(raider.Character, amount);
                    }
                    break;

                default:
                    bot.SendReply(e, "Invalid reward mode specified");
                    return;
                }
                double         total  = 0;
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Rewarded Points");
                foreach (KeyValuePair <string, double> kvp in points)
                {
                    window.AppendHighlight(kvp.Value.ToString("###0.0") + " ");
                    window.AppendNormal(kvp.Key);
                    window.AppendLineBreak();
                    this._core.AddPoints(kvp.Key, kvp.Value);
                    total += kvp.Value;
                    this._core.Log(kvp.Key, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + kvp.Value + " points to " + kvp.Key + " (Total Points: " + this._core.GetPoints(kvp.Key) + ")");
                }
                switch (e.Args[1])
                {
                case "activity":
                    bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " raiders based on their active time on the raid »» ", window);
                    bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all raiders based on their active time on the raid");
                    this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders based on their active time on the raid (Total Points: " + total + ")");
                    return;

                case "active":
                    bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " active raiders on the current raid »» ", window);
                    bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all active raiders on the current raid");
                    this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders active on the current raid (Total Points: " + total + ")");
                    return;

                case "all":
                    bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " raiders that participated in this raid »» ", window);
                    bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all raiders that participated on this raid");
                    this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders that have participated on this raid (Total Points: " + total + ")");
                    return;
                }
            }
            else
            {
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Reward Points");
                window.AppendNormal("You are about to reward ");
                window.AppendHighlight(amount.ToString());
                window.AppendNormal(" points.");
                window.AppendLineBreak();
                window.AppendNormal("Please select one of the following modes for rewarding points.");
                window.AppendLineBreak(2);

                window.AppendHighlight("Activity Based");
                window.AppendLineBreak();
                window.AppendNormal("This method will reward points to all raiders relative to the time they spent on the raid while it was unpaused.");
                window.AppendLineBreak();
                window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 3 points. Even if he wasn't at the raid at the moment the points were rewarded.");
                window.AppendLineBreak();
                window.AppendNormal("[");
                window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " activity");
                window.AppendNormal("]");
                window.AppendLineBreak(2);

                window.AppendHighlight("All Active Raiders");
                window.AppendLineBreak();
                window.AppendNormal("This method will reward points to all raiders that are currently active on this raid");
                window.AppendLineBreak();
                window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 6 points if he was on the raid at the moment these points were rewarded.");
                window.AppendLineBreak();
                window.AppendNormal("[");
                window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " active");
                window.AppendNormal("]");
                window.AppendLineBreak(2);

                window.AppendHighlight("All Raiders");
                window.AppendLineBreak();
                window.AppendNormal("This method will reward points to all raiders that attended this raid");
                window.AppendLineBreak();
                window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 6 points. Even if he wasn't at the raid at the moment the points were rewarded.");
                window.AppendLineBreak();
                window.AppendNormal("[");
                window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " all");
                window.AppendNormal("]");
                window.AppendLineBreak(2);

                bot.SendReply(e, "Reward Points »» ", window);
            }
        }
Пример #28
0
 private void OnTeamsClearCommand(BotShell bot, CommandArgs e)
 {
     this._database.ExecuteNonQuery("DELETE FROM teams");
     bot.SendReply(e, "All teams have been cleared");
     bot.SendPrivateChannelMessage(bot.ColorHighlight + "All teams have been cleared");
 }
Пример #29
0
        private void OnBidCommand(BotShell bot, CommandArgs e)
        {
            if (!this._running)
            {
                bot.SendReply(e, "There is no auction you can bid on");
                return;
            }
            if (e.Words.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: bid [amount]");
                return;
            }
            int amount = 0;

            try { amount = Convert.ToInt32(e.Args[0]); }
            catch { }
            if (this._core.GetPoints(e.Sender) < amount)
            {
                bot.SendReply(e, "You don't have that many points");
                return;
            }
            if (this._bidder == e.Sender)
            {
                bot.SendReply(e, "You already have the leading bid");
                return;
            }
            if (this._currentBid >= amount)
            {
                bot.SendReply(e, "You need to bid at least " + HTML.CreateColorString(bot.ColorHeaderHex, ((int)(this._currentBid + 1)).ToString()) + " points");
                return;
            }
            if (this._proxyBid >= amount)
            {
                if (this._proxyBid == amount)
                {
                    this._currentBid = amount;
                }
                else
                {
                    this._currentBid = amount + 1;
                }
                bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " tried to outbid " + HTML.CreateColorString(bot.ColorHeaderHex, this._bidder) + ", but " + HTML.CreateColorString(bot.ColorHeaderHex, this._bidder) + " is still leading with " + HTML.CreateColorString(bot.ColorHeaderHex, this._currentBid.ToString()) + " points");
                bot.SendReply(e, "You failed to outbid " + HTML.CreateColorString(bot.ColorHeaderHex, this._bidder));
                this._core.Log(e.Sender, e.Sender, this.InternalName, "auction", e.Sender + " has failed to outbid with " + amount + " points");
                return;
            }
            else
            {
                this._currentBid = this._proxyBid + 1;
                this._bidder     = e.Sender;
                this._proxyBid   = amount;
                if (this._timeLeft < this._ninjaDuration)
                {
                    this._timeLeft = this._ninjaDuration;
                }
                bot.SendReply(e, "You are now leading the auction with " + HTML.CreateColorString(bot.ColorHeaderHex, this._currentBid.ToString()) + " points");
                bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " is now leading the auction with " + HTML.CreateColorString(bot.ColorHeaderHex, this._currentBid.ToString()) + " points");
                this._core.Log(e.Sender, e.Sender, this.InternalName, "auction", e.Sender + "'s bid of " + amount + " points is leading the auction with " + this._currentBid + " points");
                return;
            }
        }
Пример #30
0
        private void OnGlyphsRaffleCommand(BotShell bot, CommandArgs e)
        {
            if (this._raffleActive)
            {
                bot.SendReply(e, "There's currently already a glyph raffle active");
                return;
            }
            Dictionary <int, int> items  = new Dictionary <int, int>();
            RichTextWindow        window = new RichTextWindow(bot);

            window.AppendTitle("Glyph Raffle");
            lock (this._items)
            {
                if (e.Args.Length != this._items.Count)
                {
                    bot.SendReply(e, "You need to specify " + this._items.Count + " numbers");
                    return;
                }
                if (this._items.Count == 0)
                {
                    bot.SendReply(e, "This plugin hasn't been properly configured for raffling");
                    return;
                }

                int i = 0;
                this._raffleJoined.Clear();
                foreach (KeyValuePair <int, string> kvp in this._items)
                {
                    try
                    {
                        items.Add(kvp.Key, Convert.ToInt32(e.Args[i]));
                        if (items[kvp.Key] > 0)
                        {
                            window.AppendHighlight(kvp.Value + " ");
                            window.AppendNormal("(" + items[kvp.Key].ToString() + " total) [");
                            window.AppendBotCommand("Join", "glyphs join " + kvp.Key);
                            window.AppendNormal("]");
                            window.AppendLineBreak();
                            this._raffleJoined.Add(kvp.Key, new List <string>());
                        }
                    }
                    catch
                    {
                        this._raffleJoined.Clear();
                        bot.SendReply(e, "Invalid value specified: " + e.Args[i]);
                        return;
                    }
                    i++;
                }
            }
            this._raffleTime   = 60;
            this._raffleItems  = items;
            this._raffleJoined = new Dictionary <int, List <string> >();
            this._raffleActive = true;
            this._raffleTimer.Start();
            this._raffleWindow = window;
            string output = bot.ColorHighlight + "\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n    " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has started a glyph raffle »» " + window.ToString();

            lock (this._items)
            {
                foreach (KeyValuePair <int, string> kvp in this._items)
                {
                    if (items[kvp.Key] > 0)
                    {
                        lock (this._raffleJoined)
                            this._raffleJoined.Add(kvp.Key, new List <string>());
                        output += "\n    " + HTML.CreateColorString(bot.ColorHeaderHex, items[kvp.Key].ToString()) + " " + kvp.Value;
                    }
                }
            }
            output += "\n______________________________________________";
            bot.SendPrivateChannelMessage(output);
            bot.SendReply(e, "You have started the glyph raffle");
        }