예제 #1
0
 private void OnRaidBansCommand(BotShell bot, CommandArgs e)
 {
     if (!this._core.Running)
     {
         bot.SendReply(e, "There is currently no raid active");
         return;
     }
     lock (this._bans)
     {
         if (this._bans.Count < 1)
         {
             bot.SendReply(e, "Nobody is banned from the raid");
             return;
         }
         RichTextWindow window = new RichTextWindow(bot);
         window.AppendTitle("Raid Bans");
         foreach (KeyValuePair <string, Raider> kvp in this._bans)
         {
             TimeSpan ts = (new TimeSpan(0, kvp.Value.Duration, 0)) - (DateTime.Now - kvp.Value.Time);
             window.AppendHighlight(Math.Floor(ts.TotalMinutes).ToString("##00") + ":" + ts.Seconds.ToString("00"));
             window.AppendNormal(" - ");
             window.AppendHighlight(kvp.Value.Character + " ");
             if (kvp.Value.Character != kvp.Key)
             {
                 window.AppendNormal("(Main: " + kvp.Key + ") ");
             }
             window.AppendNormal("[");
             window.AppendBotCommand("Unban", "raid unban " + kvp.Key);
             window.AppendNormal("]");
             window.AppendLineBreak();
         }
         bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, this._bans.Count.ToString()) + " Raid Bans »» ", window);
     }
 }
예제 #2
0
        private void OnAuctionCommand(BotShell bot, CommandArgs e)
        {
            if (!this._running)
            {
                bot.SendReply(e, "There is currently no auction running");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

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

            if (points > this._core.MinimumPoints)
            {
                window.AppendHighlight("Your Points: ");
                if (points > this._currentBid)
                {
                    window.AppendColorString(RichTextWindow.ColorGreen, points.ToString());
                }
                else
                {
                    window.AppendColorString(RichTextWindow.ColorRed, points.ToString());
                }
                window.AppendLineBreak();
            }
            window.AppendHighlight("Time Left: ");
            window.AppendNormal(this._timeLeft.ToString() + " seconds");
            window.AppendLineBreak();
            bot.SendReply(e, "Auction »» ", window);
        }
예제 #3
0
 public void OnBattleCommand(BotShell bot, CommandArgs e)
 {
     try
     {
         using (IDbCommand command = this._database.Connection.CreateCommand())
         {
             RichTextWindow window = new RichTextWindow(bot);
             window.AppendTitle("Tower Battle History");
             window.AppendLineBreak();
             command.CommandText = "SELECT [time], [atkrSide] , [atkrOrg], [atkrName], [defSide], [defOrg], [zone], [xCoord], [yCoord], [LCA] FROM [towerhistory] WHERE victory = 0 ORDER BY [time] DESC LIMIT 10";
             IDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 window.AppendHeader(Format.DateTime(reader.GetInt64(0), FormatStyle.Compact) + " GMT");
                 if (!reader.IsDBNull(2))
                 {
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(3), reader.GetString(1)), reader.GetString(3));
                     window.AppendNormal(" - (");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(2), reader.GetString(1)), reader.GetString(2));
                     window.AppendNormal(")");
                     window.AppendLineBreak();
                 }
                 else
                 {
                     WhoisResult whois = XML.GetWhois(reader.GetString(3), bot.Dimension);
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(3), whois.Stats.Faction), reader.GetString(3));
                     window.AppendNormal(" - (Unguilded)");
                     window.AppendLineBreak();
                 }
                 window.AppendHighlight("Defender: ");
                 window.AppendColorString(this.sideColorWindow(reader.GetString(5), reader.GetString(4)), reader.GetString(5));
                 window.AppendLineBreak();
                 window.AppendHighlight("Location: ");
                 window.AppendNormal(reader.GetString(6) + " (x");
                 window.AppendColorString("FF0000", reader.GetInt64(9).ToString());
                 window.AppendNormal(" " + reader.GetInt64(7) + "x" + reader.GetInt64(8) + ")");
                 window.AppendLineBreak(2);
             }
             bot.SendReply(e, " Tower Battle Results »» ", window);
             return;
         }
     }
     catch
     {
         bot.SendReply(e, "Error retrieving battle history!");
     }
 }
예제 #4
0
        private void OnCommandsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

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

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

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

                window.AppendHighlight(loader.Name);
                window.AppendNormal(" (" + bot.Configuration.List(plugin).Length + " settings)");
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Configuration »» ", window);
        }
예제 #6
0
 private void StartedEvent(object sender, EventArgs e)
 {
     if (this.CreditsEnabled)
     {
         if (!this._core.Locked)
         {
             this._core.Locked = true;
             //this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "The raid has been " + HTML.CreateColorString(RichTextWindow.ColorRed, "locked") + " pending raid credits type selection");
         }
         this.CreditsType = -1;
         RichTextWindow window = new RichTextWindow(this._bot);
         window.AppendTitle("Raid Credits Selection");
         window.AppendHighlight("The raid credits system has been enabled.");
         window.AppendLineBreak();
         window.AppendHighlight("Please select which type of raid credits should be used for this raid.");
         window.AppendLineBreak(2);
         lock (this._database.Connection)
         {
             using (IDbCommand command = this._database.Connection.CreateCommand())
             {
                 command.CommandText = "SELECT type, name, description, credits FROM credits_types";
                 IDataReader reader = command.ExecuteReader();
                 while (reader.Read())
                 {
                     window.AppendHeader(reader.GetString(1));
                     window.AppendHighlight(reader.GetString(2));
                     window.AppendLineBreak();
                     window.AppendNormal("[");
                     window.AppendBotCommand("Select", "raid credits " + reader.GetInt32(0));
                     window.AppendNormal("]");
                     window.AppendLineBreak(2);
                 }
                 reader.Close();
             }
         }
         window.AppendHeader("No Credits");
         window.AppendHighlight("Selecting this option will cause no raid credits to be charged this raid.");
         window.AppendLineBreak();
         window.AppendHighlight("This option is useful for unannounced or unplanned raids.");
         window.AppendLineBreak();
         window.AppendNormal("[");
         window.AppendBotCommand("Select", "raid unlock");
         window.AppendNormal("]");
         window.AppendLineBreak(2);
         this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "Please select raid credits type »» " + window.ToString());
     }
 }
예제 #7
0
 public void OnVictoryCommand(BotShell bot, CommandArgs e)
 {
     try
     {
         using (IDbCommand command = this._database.Connection.CreateCommand())
         {
             RichTextWindow window = new RichTextWindow(bot);
             window.AppendTitle("Tower Victory History");
             window.AppendLineBreak();
             command.CommandText = "SELECT [time], [atkrSide], [atkrOrg], [defSide], [defOrg], [zone] FROM [towerhistory] WHERE victory = 1 ORDER BY [time] DESC LIMIT 10";
             IDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 window.AppendHeader(Format.DateTime(reader.GetInt64(0), FormatStyle.Compact) + " GMT");
                 if (!reader.IsDBNull(1))
                 {
                     window.AppendHighlight("Attacker: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(2), reader.GetString(1)), reader.GetString(2));
                     window.AppendLineBreak();
                     window.AppendHighlight("Defender: ");
                     window.AppendColorString(this.sideColorWindow(reader.GetString(4), reader.GetString(3)), reader.GetString(4));
                     window.AppendLineBreak();
                     window.AppendHighlight("Location: ");
                     window.AppendNormal(reader.GetString(5));
                     window.AppendLineBreak(2);
                 }
                 else
                 {
                     window.AppendColorString(this.sideColor(reader.GetString(4), reader.GetString(3)), reader.GetString(4));
                     window.AppendNormal(" lost their base in " + reader.GetString(5) + ".");
                     window.AppendLineBreak(2);
                 }
             }
             bot.SendReply(e, " Tower Victory Results »» ", window);
             return;
         }
     }
     catch
     {
         bot.SendReply(e, "Error retrieving battle victory history!");
     }
 }
예제 #8
0
        public void OnPluginsOverviewCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

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

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

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

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

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

                window.AppendLineBreak(2);
            }
            bot.SendReply(e, "Plugins Overview »» ", window);
        }
예제 #9
0
        private void OnGlyphsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

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

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

            if (!empty)
            {
                window.AppendHeader("Options");
                window.AppendBotCommand("Start Raffle", "glyphs raffle" + raffle);
                window.AppendLineBreak();
                window.AppendBotCommand("Clear List", "glyphs clear");
                bot.SendReply(e, "Glyphs List »» ", window);
            }
            else
            {
                bot.SendReply(e, "The glyphs list is current empty");
            }
        }
예제 #10
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "gates":
                TimeSpan       time   = this.GetTimeLeft();
                DateTime       now    = DateTime.Now.ToUniversalTime();
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Outzone Gates Opening Times");
                DateTime next = now.AddSeconds(time.TotalSeconds);
                for (int i = 0; i < 14; i++)
                {
                    window.AppendHighlight(next.ToString("dd/MM/yyyy HH:mm:ss") + " GMT ");
                    TimeSpan span = next - now;
                    window.AppendNormal(string.Format("({0:00}:{1:00}:{2:00} from now)", Math.Floor(span.TotalHours), span.Minutes, span.Seconds));
                    window.AppendLineBreak();
                    next = next.AddSeconds(this.Cycle);
                }
                string result = string.Empty;
                int    last   = this.Cycle - (int)time.TotalSeconds;
                if (last < (60 * 2))
                {
                    result = "Unicorn Gatekeeper is currently opening the Outzones gates";
                }
                else if (last < (60 * 12))
                {
                    result = "The Outzones gates are currently open";
                }
                else
                {
                    result = "Unicorn Gatekeeper will open the Outzones gates in " + HTML.CreateColorString(bot.ColorHeaderHex, string.Format("{0} hours, {1} minutes and {2} seconds", time.Hours, time.Minutes, time.Seconds));
                }
                bot.SendReply(e, result + " »» " + window.ToString());
                break;

            case "gates get":
                if (this.FetchWebTime(bot))
                {
                    bot.SendReply(e, "Synchronized the Outzones gates timer");
                }
                else
                {
                    bot.SendReply(e, "Unable to synchronize the Outzones gates timer. Please try again later");
                }
                break;

            case "gates reset":
                bot.Configuration.SetInteger(this.InternalName, "gatetime", (Int32)TimeStamp.Now);
                this.LoadSettings(bot);
                bot.SendReply(e, "The Outzones gates timer has been reset");
                break;
            }
        }
예제 #11
0
        private void OnRosterResetCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length > 0)
            {
                if (e.Args[0].ToLower() == "confirm")
                {
                    this._database.ExecuteNonQuery("DELETE FROM members");
                    bot.SendReply(e, "Roster list cleared");
                    return;
                }
            }
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Clear Cached Roster List");
            window.AppendNormal("Warning! This will clear the local roster list!");
            window.AppendLineBreak();
            window.AppendNormal("This list is used to determine changes in the organization's member list.");
            window.AppendLineBreak();
            window.AppendNormal("Clearing this list will NOT remove any members from the bot!");
            window.AppendLineBreak();
            window.AppendNormal("After clearing this list, the next roster update will see every member of the organization as a new member.");
            window.AppendLineBreak();
            window.AppendNormal("Resetting the cached roster list can be used to resolve some sync issues but may also leave 'ghost' members behind.");
            window.AppendLineBreak();
            window.AppendNormal("Use this command with caution!");
            window.AppendLineBreak(2);
            window.AppendBotCommand("Reset List Now", "roster reset confirm");
            bot.SendReply(e, "Roster Reset »» " + window.ToString());
        }
예제 #12
0
        private void OnBansCommand(BotShell bot, CommandArgs e)
        {
            Ban[]          bans   = bot.Bans.List();
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Bans");
            foreach (Ban ban in bans)
            {
                window.AppendHighlight(ban.Character);
                window.AppendNormal(" (By " + ban.AddedBy + " on " + Format.DateTime(ban.AddedOn, FormatStyle.Compact) + ")");
                window.AppendLineBreak();
            }
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, bans.Length.ToString()) + " Bans »» ", window);
        }
예제 #13
0
        private void OnMembersCommand(BotShell bot, CommandArgs e)
        {
            SortedDictionary <string, UserLevel> members = bot.Users.GetUsers();
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Members");
            foreach (KeyValuePair <string, UserLevel> member in members)
            {
                window.AppendHighlight(member.Key);
                window.AppendNormal(" (" + member.Value + ")");
                window.AppendLineBreak();
            }
            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, members.Count.ToString()) + " Members »» ", window);
        }
예제 #14
0
파일: vh_Bio.cs 프로젝트: deathlef/VhaBot
 public override void OnCommand(BotShell bot, CommandArgs e)
 {
     if (e.Items.Length < 1)
     {
         bot.SendReply(e, "Correct Usage: bio [bio material]");
         return;
     }
     foreach (AoItem match in e.Items)
     {
         if (this._clumps.ContainsKey(match.HighID))
         {
             string name = "QL " + match.QL + " " + this._clumps[match.HighID].Clump;
             if (this._clumps[match.HighID].Weapons.Count > 0)
             {
                 double hql = Math.Floor((match.QL * 1.1));
                 if (hql > 300)
                 {
                     hql = 300;
                 }
                 RichTextWindow window = new RichTextWindow(bot);
                 window.AppendTitle("Kyr'Ozch Weapons");
                 window.AppendHighlight("The following weapons can be created using your " + name + ":");
                 window.AppendLineBreak();
                 foreach (VhBioWeapon weapon in this._clumps[match.HighID].Weapons)
                 {
                     if (weapon.HighQL >= hql && weapon.LowQL <= hql)
                     {
                         window.AppendNormal("- ");
                         window.AppendItem("Kyr'Ozch " + weapon.Name + " - Type " + this._clumps[match.HighID].Type, weapon.LowID, weapon.HighID, Convert.ToInt32(hql));
                         window.AppendLineBreak();
                     }
                 }
                 bot.SendReply(e, name + " (" + this._clumps[match.HighID].Description + ")" + " »» ", window);
             }
             else
             {
                 bot.SendReply(e, name + " (" + this._clumps[match.HighID].Description + ")");
             }
         }
         else if (match.Name == "Solid Clump of Kyr'Ozch Bio-Material")
         {
             bot.SendReply(e, "Unable to identify your " + HTML.CreateColorString(bot.ColorHeaderHex, match.Name));
         }
         else
         {
             bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, match.Name) + " doesn't look like a " + HTML.CreateColorString(bot.ColorHeaderHex, "Solid Clump of Kyr'Ozch Bio-Material"));
         }
     }
 }
예제 #15
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            RaidCore.Raider[] raiders = this._core.GetActiveRaiders();
            int    i      = 0;
            int    ii     = 0;
            string assist = string.Empty;

            if (raiders.Length == 0)
            {
                bot.SendReply(e, "There's nobody on the raid to check");
                return;
            }
            foreach (RaidCore.Raider raider in raiders)
            {
                assist += "/assist " + raider.Character + " \\n ";
                i++;
                ii++;
                if (i == 100 || raiders.Length == ii)
                {
                    RichTextWindow window = new RichTextWindow(bot);
                    window.AppendTitle("Raid Check");
                    window.AppendHighlight("This command will execute a /assist command on all raiders currently present in the raid");
                    window.AppendLineBreak();
                    window.AppendHighlight("If the player is present it won't display anything if they are in combat and if they're not in combat it will display 'Target is not in a fight'");
                    window.AppendLineBreak();
                    window.AppendHighlight("If the player isn't present it will display 'Can't find target >player<'");
                    window.AppendLineBreak(2);
                    window.AppendNormal("[");
                    window.AppendCommand("Check all Raiders", assist);
                    window.AppendNormal("]");
                    i      = 0;
                    assist = string.Empty;
                    bot.SendReply(e, "Raid Check »» ", window);
                }
            }
        }
예제 #16
0
파일: vh_Tasks.cs 프로젝트: deathlef/VhaBot
        private void OnTasksCommand(BotShell bot, CommandArgs e)
        {
            string         message = "Tasks";
            RichTextWindow window  = new RichTextWindow(bot);

            window.AppendTitle("Tasks");
            bool found = false;

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT username, task FROM tasks ORDER BY username";
                IDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    found = true;
                    window.AppendHighlight(reader.GetString(0) + ": ");
                    window.AppendNormal(reader.GetString(1).Trim() + " [");
                    window.AppendBotCommand("Remove", "tasks remove " + reader.GetString(0));
                    window.AppendNormal("]");
                    window.AppendLineBreak();
                    if (e.Sender == reader.GetString(0))
                    {
                        message = "You have been assigned the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, reader.GetString(1));
                    }
                }
                reader.Close();
            }
            if (!found)
            {
                bot.SendReply(e, "No tasks assigned");
            }
            else
            {
                bot.SendReply(e, message + " »» ", window);
            }
        }
예제 #17
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            Int32              cycle  = 7 + 7 + 7;
            string             today  = string.Empty;
            DateTimeFormatInfo dtfi   = new CultureInfo("en-US", false).DateTimeFormat;
            RichTextWindow     window = new RichTextWindow(bot);

            window.AppendTitle("Beast Days");

            for (int i = 0; i < cycle; i++)
            {
                Int64 current           = TimeStamp.Now + ((24 * 60 * 60) * i);
                Int64 secondsSinceStart = current - TimeStamp.FromDateTime(new DateTime(2006, 10, 23));
                Int64 seconds           = secondsSinceStart % (cycle * (24 * 60 * 60));
                Int64 day = (seconds / (24 * 60 * 60)) + 1;

                string type = string.Empty;
                if (day <= 7)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorBlue, "Omni");
                }
                else if (day > 7 && day <= 14)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorGreen, "FFA");
                }
                else if (day > 14)
                {
                    type = HTML.CreateColorString(RichTextWindow.ColorOrange, "Clan");
                }

                if (type == string.Empty)
                {
                    continue;
                }

                if (i == 0)
                {
                    today = type;
                }

                window.AppendHighlight(TimeStamp.ToDateTime(current).ToString("[dd/MM/yyyy]", dtfi));
                window.AppendNormal(TimeStamp.ToDateTime(current).ToString(" dddd: ", dtfi));
                window.AppendRawString(type);
                window.AppendLineBreak();
            }

            bot.SendReply(e, "Today is " + today + " day »» " + window.ToString());
        }
예제 #18
0
        private void OnConfigurationColorCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 2)
            {
                bot.SendReply(e, "Usage: configuration color [plugin] [key]");
                return;
            }
            if (!bot.Configuration.IsRegistered(e.Args[0], e.Args[1]))
            {
                bot.SendReply(e, "No such configuration entry");
                return;
            }
            RichTextWindow window = new RichTextWindow(bot);

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

            foreach (KeyValuePair <string, string> color in this.Colors)
            {
                if (color.Value != string.Empty)
                {
                    window.AppendString("  ");
                    window.AppendBotCommandStart(command + color.Value, true);
                    window.AppendColorString(color.Value, color.Key);
                    window.AppendCommandEnd();
                    window.AppendLineBreak();
                }
                else
                {
                    if (!first)
                    {
                        window.AppendLineBreak();
                    }
                    window.AppendHeader(color.Key);
                    first = false;
                }
            }
            window.AppendLineBreak();
            window.AppendHeader("Other");
            window.AppendHighlight("To select a different color not listed above use: ");
            window.AppendLineBreak();
            window.AppendNormal("/tell " + bot.Character + " " + command + "<color hex>");
            bot.SendReply(e, "Color Selection »» ", window);
        }
예제 #19
0
        private void OnCallersCommand(BotShell bot, CommandArgs e)
        {
            if (this.Callers.Count < 1)
            {
                bot.SendReply(e, "There are no assigned callers");
                return;
            }
            RichTextWindow callersWindow = new RichTextWindow(bot);

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

            lock (this.Callers)
            {
                foreach (string caller in this.Callers)
                {
                    callersWindow.AppendHighlight(Format.UppercaseFirst(caller));
                    callersWindow.AppendNormalStart();
                    callersWindow.AppendString(" [");
                    callersWindow.AppendCommand("Assist", "/assist " + caller);
                    callersWindow.AppendString("] [");
                    callersWindow.AppendCommand("Macro", "/macro " + caller + " /assist " + caller);
                    callersWindow.AppendString("] [");
                    callersWindow.AppendBotCommand("Remove", "callers remove " + caller);
                    callersWindow.AppendString("]");
                    callersWindow.AppendColorEnd();
                    callersWindow.AppendLineBreak();
                    assistAll += "/assist " + caller + "\\n ";
                }
            }
            callersWindow.AppendLineBreak();
            callersWindow.AppendHeader("Options");
            callersWindow.AppendHighlight("Assist All: ");
            callersWindow.AppendCommand("Click", assistAll.Substring(0, assistAll.Length - 3));
            callersWindow.AppendLineBreak();
            callersWindow.AppendHighlight("Assist All Macro: ");
            callersWindow.AppendNormal("/macro assist " + assistAll.Substring(0, assistAll.Length - 3));
            callersWindow.AppendLineBreak();
            callersWindow.AppendHighlight("Clear List: ");
            callersWindow.AppendBotCommand("Click", "callers remove all");
            bot.SendReply(e, "Callers »» ", callersWindow);
        }
예제 #20
0
        private void OnPointsTopCommand(BotShell bot, CommandArgs e)
        {
            Dictionary <string, double> points = this._core.GetAllPoints();
            int            i      = 1;
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Top 20 Raid Points");
            foreach (KeyValuePair <string, double> kvp in points)
            {
                if (i > 20)
                {
                    break;
                }
                window.AppendHighlight(Math.Floor(kvp.Value) + " ");
                window.AppendNormal(Format.UppercaseFirst(kvp.Key));
                window.AppendLineBreak();
                i++;
            }
            bot.SendReply(e, "Top 20 Raid Points »» ", window);
        }
예제 #21
0
        public void OnTimersCommand(BotShell bot, CommandArgs e)
        {
            lock (this._timers)
            {
                // If the user's level is higher than the required level he can see all timers
                bool all = false;
                if (bot.Users.GetUser(bot.Users.GetMain(e.Sender)) > bot.Commands.GetRight("timers", e.Type))
                {
                    all = true;
                }

                // Format output
                int            count  = 0;
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Active Timers");
                foreach (CachedTimer timer in this._timers.Values)
                {
                    if (!all)
                    {
                        if (timer.Owner != e.Sender && timer.Source != "pg" && timer.Source != "gc")
                        {
                            continue;
                        }
                    }
                    count++;
                    TimeSpan remaining = timer.End - DateTime.UtcNow;
                    window.AppendHighlight(Format.Time(remaining, FormatStyle.Medium));
                    window.AppendNormal(" #" + timer.ID + " - " + timer.Description + " (" + timer.Owner + ")");
                    window.AppendLineBreak();
                }
                if (count > 0)
                {
                    bot.SendReply(e, "Timers »» ", window);
                }
                else
                {
                    bot.SendReply(e, "There are currently no timers active");
                }
            }
        }
예제 #22
0
        public void OnTokensCommand(BotShell bot, CommandArgs e)
        {
            if (e.Args.Length < 1)
            {
                // Tokens overview
                RichTextWindow window = new RichTextWindow(bot);
                window.AppendTitle("Tokens Overview");
                window.AppendHighlight("Level 1-14: ");
                window.AppendNormal("1 token");
                window.AppendLineBreak();
                window.AppendHighlight("Level 15-49: ");
                window.AppendNormal("2 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 50-74: ");
                window.AppendNormal("3 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 75-99: ");
                window.AppendNormal("4 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 100-124: ");
                window.AppendNormal("5 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 125-149: ");
                window.AppendNormal("6 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 150-174: ");
                window.AppendNormal("7 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 175-189: ");
                window.AppendNormal("8 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Level 190-220: ");
                window.AppendNormal("9 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("Veteran tokens (7 veteran points): ");
                window.AppendNormal("50 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("OFAB tokens (1.000 victory points): ");
                window.AppendNormal("10 tokens");
                window.AppendLineBreak();
                window.AppendHighlight("OFAB tokens (10.000 victory points): ");
                window.AppendNormal("100 tokens");
                window.AppendLineBreak();

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

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

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

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

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

                bot.SendReply(e, "Tokens »» ", window);
            }
        }
예제 #23
0
        public void OnPluginsCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window          = new RichTextWindow(bot);
            RichTextWindow windowCore      = new RichTextWindow(bot);
            RichTextWindow windowLoaded    = new RichTextWindow(bot);
            RichTextWindow windowInstalled = new RichTextWindow(bot);
            RichTextWindow windowDisabled  = new RichTextWindow(bot);

            window.AppendTitle("Plugins");
            window.AppendNormal("Plugins provide functionality and features for your bot. You can load different plugins based on your needs.");
            window.AppendLineBreak();
            window.AppendNormal("After loading plugins it's wise to open the ");
            window.AppendBotCommand("configuration interface", "configuration");
            window.AppendNormal(" to futher configure the loaded plugins.");
            window.AppendLineBreak();
            window.AppendNormal("If you're unsure about which plugin you need, ");
            window.AppendBotCommand("click here", "plugins overview");
            window.AppendNormal(" to get an overview of all available plugins.");
            window.AppendLineBreak(2);

            string[] plugins = bot.Plugins.GetPlugins();
            foreach (string plugin in plugins)
            {
                RichTextWindow tmpWindow;
                PluginState    state = bot.Plugins.GetState(plugin);
                switch (state)
                {
                case PluginState.Core:
                    tmpWindow = windowCore;
                    tmpWindow.AppendNormalStart();
                    break;

                case PluginState.Loaded:
                    tmpWindow = windowLoaded;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Unload", "plugins unload " + plugin);
                    tmpWindow.AppendString("] ");
                    break;

                case PluginState.Installed:
                    tmpWindow = windowInstalled;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Load", "plugins load " + plugin);
                    tmpWindow.AppendString("] [");
                    tmpWindow.AppendBotCommand("Uninstall", "plugins uninstall " + plugin);
                    tmpWindow.AppendString("] ");
                    break;

                default:
                    tmpWindow = windowDisabled;
                    tmpWindow.AppendNormalStart();
                    tmpWindow.AppendString("[");
                    tmpWindow.AppendBotCommand("Install", "plugins install " + plugin);
                    tmpWindow.AppendString("] ");
                    break;
                }
                tmpWindow.AppendString("[");
                tmpWindow.AppendBotCommand("Info", "plugins info " + plugin);
                tmpWindow.AppendString("] ");
                tmpWindow.AppendColorEnd();

                PluginLoader info = bot.Plugins.GetLoader(plugin);
                tmpWindow.AppendHighlight(info.Name);
                tmpWindow.AppendLineBreak();
            }

            window.AppendHeader("Core Plugins");
            if (windowCore.Text != string.Empty)
            {
                window.AppendRawString(windowCore.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Loaded");
            if (windowLoaded.Text != string.Empty)
            {
                window.AppendRawString(windowLoaded.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Installed");
            if (windowInstalled.Text != string.Empty)
            {
                window.AppendRawString(windowInstalled.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }
            window.AppendLineBreak();

            window.AppendHeader("Disabled");
            if (windowDisabled.Text != string.Empty)
            {
                window.AppendRawString(windowDisabled.Text);
            }
            else
            {
                window.AppendHighlight("None");
                window.AppendLineBreak();
            }

            bot.SendReply(e, "Plugins »» ", window);
        }
예제 #24
0
        public void OnPluginsInfoCommand(BotShell bot, CommandArgs e)
        {
            PluginLoader info = bot.Plugins.GetLoader(e.Args[1]);

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

            infoWindow.AppendTitle("Plugin Information");
            infoWindow.AppendHighlight("Name: ");
            infoWindow.AppendNormal(info.Name);
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Version: ");
            infoWindow.AppendNormal(info.Version.ToString());
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Author: ");
            infoWindow.AppendNormal(info.Author);
            infoWindow.AppendLineBreak();
            infoWindow.AppendHighlight("Internal Name: ");
            infoWindow.AppendNormal(info.InternalName);
            infoWindow.AppendLineBreak();
            if (info.Description != null)
            {
                infoWindow.AppendHighlight("Description: ");
                infoWindow.AppendNormal(info.Description);
                infoWindow.AppendLineBreak();
            }
            infoWindow.AppendHighlight("State: ");
            infoWindow.AppendNormal(bot.Plugins.GetState(info.InternalName).ToString());
            infoWindow.AppendLineBreak();
            if (info.Commands.Length > 0)
            {
                infoWindow.AppendHighlight("Commands: ");
                infoWindow.AppendLineBreak();
                bool isLoaded = bot.Plugins.IsLoaded(info.InternalName);
                lock (info)
                {
                    foreach (Command command in info.Commands)
                    {
                        infoWindow.AppendNormalStart();
                        infoWindow.AppendString("  " + Format.UppercaseFirst(command.CommandName));
                        if (!isLoaded && bot.Commands.Exists(command.CommandName))
                        {
                            infoWindow.AppendString(" (");
                            infoWindow.AppendColorString(RichTextWindow.ColorRed, "Conflict with " + bot.Plugins.GetName(bot.Commands.GetInternalName(command.CommandName)));
                            infoWindow.AppendString(")");
                        }
                        infoWindow.AppendColorEnd();
                        infoWindow.AppendLineBreak();
                    }
                }
            }
            if (info.Dependencies.Length > 0)
            {
                infoWindow.AppendHighlight("Dependencies: ");
                infoWindow.AppendLineBreak();
                lock (info)
                {
                    foreach (string dependency in info.Dependencies)
                    {
                        infoWindow.AppendNormalStart();
                        infoWindow.AppendString("  ");
                        if (bot.Plugins.Exists(dependency))
                        {
                            infoWindow.AppendString(bot.Plugins.GetName(dependency));
                            infoWindow.AppendString(" (");
                            if (bot.Plugins.IsLoaded(dependency))
                            {
                                infoWindow.AppendColorString(RichTextWindow.ColorGreen, "Loaded");
                            }
                            else
                            {
                                infoWindow.AppendColorString(RichTextWindow.ColorOrange, "Not Loaded");
                            }
                            infoWindow.AppendString(") [");
                            infoWindow.AppendCommand("Info", "plugins info " + dependency);
                            infoWindow.AppendString("]");
                        }
                        else
                        {
                            infoWindow.AppendString(dependency + " (");
                            infoWindow.AppendColorString(RichTextWindow.ColorRed, "Not Found");
                            infoWindow.AppendString(")");
                        }
                        infoWindow.AppendColorEnd();
                        infoWindow.AppendLineBreak();
                    }
                }
            }
            bot.SendReply(e, "Plugin Information »» " + infoWindow.ToString());
        }
예제 #25
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);
            }
        }
예제 #26
0
        private void OnForumCommand(BotShell bot, CommandArgs e)
        {
            string username = e.Sender;

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

            ForumAccount account = this.GetAccount(username);

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

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

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

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

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

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

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

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

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

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

            if (account.Groups.Count > 0)
            {
                window.AppendLineBreak();
                window.AppendHeader("Additional Groups");
                foreach (string group in account.Groups.Values)
                {
                    window.AppendHighlight(group);
                    window.AppendLineBreak();
                }
            }
            bot.SendReply(e, username + "'s Forum Account »» " + window.ToString());
        }
예제 #27
0
파일: vh_uMob.cs 프로젝트: deathlef/VhaBot
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "umob":
                if (e.Args.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: umob [search string]");
                    return;
                }
                string search = string.Empty;
                search = e.Words[0];
                search = search.ToLower();

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

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

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

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

            command = bot.Commands.GetMainCommand(command);
            if (!bot.Commands.Exists(command) || !bot.Commands.GetRights(command).Help)
            {
                bot.SendReply(e, "No such help topic");
                return;
            }

            PluginLoader  loader = bot.Plugins.GetLoader(bot.Commands.GetInternalName(command));
            CommandRights rights = bot.Commands.GetRights(command);
            UserLevel     level  = bot.Users.GetUser(e.Sender);

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Information");
            window.AppendHighlight("Command: ");
            window.AppendNormal(Format.UppercaseFirst(command));
            window.AppendLineBreak();
            window.AppendHighlight("Plugin: ");
            window.AppendNormal(loader.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("Private Message Access: ");
            if (level >= rights.PrivateMessage)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.PrivateMessage.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.PrivateMessage.ToString());
            }
            window.AppendLineBreak();
            window.AppendHighlight("Private Channel Access: ");
            if (level >= rights.PrivateChannel)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.PrivateChannel.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.PrivateChannel.ToString());
            }
            window.AppendLineBreak();
            window.AppendHighlight("Organization Access: ");
            if (level >= rights.Organization)
            {
                window.AppendColorString(RichTextWindow.ColorGreen, rights.Organization.ToString());
            }
            else
            {
                window.AppendColorString(RichTextWindow.ColorRed, rights.Organization.ToString());
            }
            window.AppendLineBreak(2);

            window.AppendHeader("Help");
            window.AppendHighlightStart();
            string help = bot.Commands.GetHelp(command);

            if (help == null || help.Trim() == string.Empty)
            {
                window.AppendString("No additional help available for this command");
            }
            else
            {
                window.AppendRawString(help);
            }
            window.AppendColorEnd();

            bot.SendReply(e, "VhaBot Help »» " + Format.UppercaseFirst(command) + " »» ", window);
        }
예제 #30
0
        private void OnCoreCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

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

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

            chats.Add(bot.GetMainBot());
            for (int i = 1; i <= bot.GetSlavesCount(); i++)
            {
                Chat slave = bot.GetSlaveBot(i);
                if (slave != null)
                {
                    chats.Add(slave);
                }
            }
            foreach (Chat chat in chats)
            {
                window.AppendHeader(chat.Character);
                window.AppendHighlight("Status: ");
                window.AppendNormal(chat.State.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Fast Queue Count: ");
                window.AppendNormal(chat.FastQueueCount.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Slow Queue Count: ");
                window.AppendNormal(chat.SlowQueueCount.ToString());
                window.AppendLineBreak();
                window.AppendHighlight("Friends: ");
                window.AppendNormal(chat.GetTotalFriends().ToString());
                window.AppendLineBreak();
                window.AppendHighlight("ID: ");
                window.AppendNormal(chat.ID.ToString());
                window.AppendLineBreak();
                if (chat.Organization != null && chat.Organization != string.Empty)
                {
                    window.AppendHighlight("Organization: ");
                    window.AppendNormal(chat.Organization);
                    window.AppendLineBreak();
                    window.AppendHighlight("Organization Channel: ");
                    window.AppendNormal(chat.OrganizationID.IntValue().ToString());
                    window.AppendLineBreak();
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "BotShell Status »» " + window.ToString());
        }