Beispiel #1
0
 public CommandArgs(CommandType type, UInt32 channelID, UInt32 senderID, string sender, WhoisResult senderWhois, string command, string message, bool fromSlave, SlaveArgs slaveArgs)
 {
     this._senderWhois = senderWhois;
     this._type        = type;
     this._senderID    = senderID;
     this._channelID   = channelID;
     this._sender      = sender;
     this._message     = message.Trim();
     this._command     = command.Trim();
     this._fromSlave   = fromSlave;
     this._slaveArgs   = slaveArgs;
     this._self        = false;
 }
Beispiel #2
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!");
     }
 }
Beispiel #3
0
        private void OnPrivateMessageEvent(BotShell bot, PrivateMessageArgs e)
        {
            if (!this._enabled)
            {
                return;
            }
            if (bot.Users.Authorized(e.Sender, UserLevel.Member))
            {
                return;
            }
            WhoisResult whois = e.SenderWhois;

            if (whois == null || !whois.Success)
            {
                return;
            }

            if (this._factions.Count > 0 && !this._factions.Contains(whois.Stats.Faction))
            {
                return;
            }
            if (this._levels.Count > 0 && !this._levels.Contains(whois.Stats.Level))
            {
                return;
            }
            if (this._defenderRanks.Count > 0 && !this._defenderRanks.Contains(whois.Stats.DefenderLevel))
            {
                return;
            }
            if (this._professions.Count > 0 && !this._professions.Contains(whois.Stats.Profession))
            {
                return;
            }
            if (this._breeds.Count > 0 && !this._breeds.Contains(whois.Stats.Breed))
            {
                return;
            }
            if (this._genders.Count > 0 && !this._genders.Contains(whois.Stats.Gender))
            {
                return;
            }

            bot.Users.AddUser(e.Sender, UserLevel.Member);
            if (this._guestlist)
            {
                bot.FriendList.Add("guestlist", e.Sender);
            }
            bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "You have been automatically added as member of this bot");
        }
Beispiel #4
0
 public bool IsAutoBanned(WhoisResult whois)
 {
     if (this._levelRequirement > 0)
     {
         if (whois == null || !whois.Success)
         {
             return(true);
         }
         if (whois.Stats.Level < this._levelRequirement)
         {
             return(true);
         }
     }
     if (this.AllowedClan && this.AllowedNeutral && this.AllowedOmni)
     {
         return(false);
     }
     if (whois == null || !whois.Success)
     {
         return(true);
     }
     if (whois.Name.Nickname.Equals(this.Parent.Admin, StringComparison.CurrentCultureIgnoreCase))
     {
         return(false);
     }
     if (whois.Stats.Faction.ToLower() == "clan" && this.AllowedClan)
     {
         return(false);
     }
     else if (whois.Stats.Faction.ToLower() == "neutral" && this.AllowedNeutral)
     {
         return(false);
     }
     else if (whois.Stats.Faction.ToLower() == "omni" && this.AllowedOmni)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Beispiel #5
0
        private void OnRosterAddCommand(BotShell bot, CommandArgs e)
        {
            if (this._state != RosterState.Idle)
            {
                bot.SendReply(e, "Roster update is currently in progress. Please try again later");
                return;
            }

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM organizations";
                IDataReader reader = command.ExecuteReader();
                int         i      = 0;
                while (reader.Read())
                {
                    i++;
                }

                reader.Close();
                if (i > 4)
                {
                    bot.SendReply(e, "You can't add more than 5 guilds!");
                    return;
                }
            }

            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Correct Usage: roster add [username]");
                return;
            }
            WhoisResult whois = XML.GetWhois(e.Args[0], bot.Dimension, false, true);

            if (whois == null || whois.Organization == null || whois.Organization.Name == null || whois.Organization.ID < 1)
            {
                bot.SendReply(e, "Unable to add an organization based on that user");
                return;
            }
            this._database.ExecuteNonQuery(String.Format("INSERT INTO organizations VALUES ({0}, '{1}', 0)", whois.Organization.ID, Config.EscapeString(whois.Organization.Name)));
            bot.SendReply(e, "Added " + HTML.CreateColorString(bot.ColorHeaderHex, whois.Organization.Name) + " to the auto-update list");
        }
Beispiel #6
0
        public async Task Whois([Remainder] string playerName = "")
        {
            await Context.Message.DeleteAsync();

            if (playerName.Length < 1)
            {
                var registration = _registrationService.FindRegistration(Context.Message.Author);
                playerName = registration?.PlayerName ?? Context.Message.Author.Username;
            }
            else if (Context.Message.MentionedUsers.Any())
            {
                var registration = _registrationService.FindRegistration(Context.Message.MentionedUsers.First());
                playerName = registration?.PlayerName ?? Context.Message.MentionedUsers.First().Username;
            }
            else
            {
                var registration = _registrationService.FindRegistration(playerName);
                playerName = registration?.PlayerName ?? playerName;
            }

            try
            {
                var highscoreResult = await _highscoreService.GetHighscoreAsync(playerName);

                var clanMemberDetails = await _clanMemberService.GetClanMember(playerName);

                var whois = new WhoisResult
                {
                    PlayerName        = playerName,
                    Highscores        = highscoreResult.Highscores,
                    ClanMemberDetails = clanMemberDetails
                };
                await ReplyAsync(whois);
            }
            catch (Exception ex)
            {
                var userMessage = $"Sorry {Context.Message.Author.Username}, I don't know this {playerName}";
                await HandleErrorAsync(userMessage, ex);
            }
        }
Beispiel #7
0
 protected void OnWhoisResult(UserInfo userInfo)
 {
     WhoisResult?.Invoke(userInfo);
 }
Beispiel #8
0
        private void OnTeamsAdminCommand(BotShell bot, CommandArgs e)
        {
            List <string> seen  = new List <string>();
            List <int>    teams = new List <int>();

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT team FROM teams GROUP BY team";
                IDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    teams.Add((int)reader.GetInt64(0));
                }
                reader.Close();
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Teams Manager");
            window.AppendCommand("Display Teams", "/g " + bot.Character + " " + bot.CommandSyntax + "teams");
            window.AppendLineBreak();
            window.AppendBotCommand("Refresh Manager", "teams admin");
            window.AppendLineBreak();
            window.AppendBotCommand("Clear Teams", "teams clear");
            window.AppendLineBreak();

            int currentTeam   = -1;
            int currentMember = 0;

            using (IDbCommand command = this._database.Connection.CreateCommand())
            {
                command.CommandText = "SELECT username, team, leader FROM teams ORDER BY team, username";
                IDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    string username = Format.UppercaseFirst(reader.GetString(0));
                    seen.Add(username);
                    int  team   = (int)reader.GetInt64(1);
                    bool leader = (reader.GetInt64(2) > 0);
                    if (team != currentTeam)
                    {
                        currentMember = 0;
                        currentTeam   = team;
                        window.AppendLineBreak();
                        window.AppendHeader("Team " + team);
                    }
                    currentMember++;
                    WhoisResult whois = XML.GetWhois(username, bot.Dimension);
                    if (whois != null && whois.Success)
                    {
                        window.AppendHighlight(Format.Whois(whois, FormatStyle.Compact));
                    }
                    else
                    {
                        window.AppendHighlight(username);
                    }

                    window.AppendNormalStart();
                    if (leader)
                    {
                        window.AppendString(" (");
                        window.AppendColorString(RichTextWindow.ColorRed, "Leader");
                        window.AppendString(")");
                    }
                    foreach (int tm in teams)
                    {
                        if (tm == team)
                        {
                            continue;
                        }
                        window.AppendString(" [");
                        window.AppendBotCommand(tm.ToString(), "teams set " + username + " " + tm);
                        window.AppendString("]");
                    }
                    if (!leader)
                    {
                        window.AppendString(" [");
                        window.AppendBotCommand("Leader", "teams leader " + username + " " + team);
                        window.AppendString("]");
                    }
                    window.AppendString(" [");
                    window.AppendBotCommand("Remove", "teams remove " + username);
                    window.AppendString("]");
                    window.AppendString(" [");
                    window.AppendBotCommand("New Team", "teams start " + username);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                }
                reader.Close();
            }
            window.AppendLineBreak();

            window.AppendHeader("Looking for Team");
            int           lft  = 0;
            List <string> list = new List <string>();

            foreach (Friend user in bot.PrivateChannel.List().Values)
            {
                list.Add(user.User);
            }

            // If 'Raid :: Core' is loaded, fetch the lft list from there
            List <string> raiders = new List <string>();

            if (bot.Plugins.IsLoaded("raidcore"))
            {
                try
                {
                    ReplyMessage reply = bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "GetActiveRaiders", 100);
                    if (reply != null && reply.Args.Length > 0)
                    {
                        raiders = new List <string>((string[])reply.Args);
                    }
                }
                catch { }
            }

            // Sort LFT list
            SortedDictionary <string, SortedDictionary <string, WhoisResult> > sorted = new SortedDictionary <string, SortedDictionary <string, WhoisResult> >();

            foreach (string member in list)
            {
                WhoisResult whois = XML.GetWhois(member, bot.Dimension);
                if (whois == null || !whois.Success)
                {
                    whois = null;
                }
                if (!sorted.ContainsKey(whois.Stats.Profession))
                {
                    sorted.Add(whois.Stats.Profession, new SortedDictionary <string, WhoisResult>());
                }
                sorted[whois.Stats.Profession].Add(member, whois);
            }

            // Display LFT list
            foreach (KeyValuePair <string, SortedDictionary <string, WhoisResult> > kvp in sorted)
            {
                window.AppendHighlight(kvp.Key);
                window.AppendLineBreak();
                foreach (KeyValuePair <string, WhoisResult> member in kvp.Value)
                {
                    if (seen.Contains(member.Key))
                    {
                        continue;
                    }
                    window.AppendNormalStart();
                    window.AppendString("- ");
                    if (member.Value != null && member.Value.Success)
                    {
                        window.AppendString(Format.Whois(member.Value, FormatStyle.Compact));
                    }
                    else
                    {
                        window.AppendString(member.Key);
                    }
                    if (raiders.Contains(member.Key))
                    {
                        window.AppendString(" [");
                        window.AppendColorString(RichTextWindow.ColorGreen, "R");
                        window.AppendString("]");
                    }
                    foreach (int tm in teams)
                    {
                        window.AppendString(" [");
                        window.AppendBotCommand(tm.ToString(), "teams set " + member.Key + " " + tm);
                        window.AppendString("]");
                    }
                    window.AppendString(" [");
                    window.AppendBotCommand("New Team", "teams start " + member.Key);
                    window.AppendString("]");
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                    lft++;
                }
                window.AppendLineBreak();
            }
            if (lft == 0)
            {
                window.AppendHighlight("None");
            }
            bot.SendReply(e, "Teams Manager »» ", window);
        }
Beispiel #9
0
        public RichTextWindow GetAltsWindow(BotShell bot, string user)
        {
            string main = bot.Users.GetMain(user);

            string[] alts = bot.Users.GetAlts(main);
            if (alts.Length < 1)
            {
                return(null);
            }

            RichTextWindow window     = new RichTextWindow(bot);
            List <string>  characters = new List <string>();

            characters.Add(main);
            foreach (string alt in alts)
            {
                characters.Add(alt);
            }

            window.AppendTitle();
            foreach (string character in characters)
            {
                window.AppendHeader(Format.UppercaseFirst(character));
                window.AppendHighlight("Status: ");
                if (bot.FriendList.IsOnline(character) == OnlineState.Online)
                {
                    window.AppendColorString(RichTextWindow.ColorGreen, "Online");
                }
                else
                {
                    window.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    window.AppendLineBreak();
                    window.AppendHighlight("Last Seen: ");
                    Int64 seen = bot.FriendList.Seen(character);
                    if (seen > 1)
                    {
                        window.AppendNormal(Format.DateTime(seen, FormatStyle.Large) + " GMT");
                    }
                    else
                    {
                        window.AppendNormal("N/A");
                    }
                }
                window.AppendLineBreak();
                window.AppendHighlight("User Level: ");
                window.AppendNormal(bot.Users.GetUser(character).ToString());
                window.AppendLineBreak();

                WhoisResult whois = XML.GetWhois(character, bot.Dimension);
                if (whois != null && whois.Success)
                {
                    window.AppendHighlight("Profession: ");
                    window.AppendNormal(whois.Stats.Profession);
                    window.AppendLineBreak();
                    window.AppendHighlight("Level: ");
                    window.AppendNormal(whois.Stats.Level.ToString());
                    if (whois.Stats.DefenderLevel > 0)
                    {
                        window.AppendNormal(" / " + whois.Stats.DefenderLevel);
                    }
                    window.AppendLineBreak();
                    if (whois.InOrganization)
                    {
                        window.AppendHighlight("Organization: ");
                        window.AppendNormal(whois.Organization.Name);
                        window.AppendLineBreak();
                        window.AppendHighlight("Rank: ");
                        window.AppendNormal(whois.Organization.Rank);
                        window.AppendLineBreak();
                    }
                }
                window.AppendLineBreak();
            }
            return(window);
        }
Beispiel #10
0
        private void OnChannelMessageEvent(BotShell bot, ChannelMessageArgs e)
        {
            if (e.Channel == "All Towers" || e.Channel == "Tower Battle Outcome")
            {
                if (e.IsDescrambled)
                {
                    if (e.Descrambled.CategoryID == 506)
                    {
                        switch (e.Descrambled.EntryID)
                        {
                        case 12753364:     // The %s organization %s just entered a state of war! %s attacked the %s organization %s's tower in %s at location (%d, %d).
                            string atkrSide = e.Descrambled.Arguments[0].Message;
                            string atkrOrg  = e.Descrambled.Arguments[1].Message;
                            string atkrName = e.Descrambled.Arguments[2].Message;
                            string defSide  = e.Descrambled.Arguments[3].Message;
                            string defOrg   = e.Descrambled.Arguments[4].Message;
                            string zone     = e.Descrambled.Arguments[5].Message;
                            int    x_coord  = e.Descrambled.Arguments[6].Integer;
                            int    y_coord  = e.Descrambled.Arguments[7].Integer;
                            int    LCA      = this.grabLCA(zone, x_coord, y_coord);

                            WhoisResult whois     = XML.GetWhois(atkrName.ToLower(), bot.Dimension);
                            int         atkrLvl   = whois.Stats.Level;
                            int         atkrAiLvl = whois.Stats.DefenderLevel;
                            string      atkrProf  = whois.Stats.Profession;
                            string      message   = HTML.CreateColorString(bot.ColorHeaderHex, atkrOrg) + " " + HTML.CreateColorString(bot.ColorHeaderHex, "(") +
                                                    this.sideColor(atkrSide, atkrSide) + HTML.CreateColorString(bot.ColorHeaderHex, ")") + " has attacked " +
                                                    HTML.CreateColorString(bot.ColorHeaderHex, defOrg) + " " + HTML.CreateColorString(bot.ColorHeaderHex, "(") +
                                                    this.sideColor(defSide, defSide) + HTML.CreateColorString(bot.ColorHeaderHex, ")") + " in " + zone + " at " +
                                                    HTML.CreateColorString(bot.ColorHeaderHex, "(x" + LCA.ToString() + " " + x_coord.ToString() + "x" + y_coord.ToString() +
                                                                           ")") + ". Attacker: " + HTML.CreateColorString(bot.ColorHeaderHex, atkrName) +
                                                    " " + HTML.CreateColorString(bot.ColorHeaderHex, "(") + this.sideColor(atkrLvl + "/" + atkrAiLvl + " " + atkrProf, atkrSide) +
                                                    HTML.CreateColorString(bot.ColorHeaderHex, ")");
                            this.sendMessage(bot, message);
                            try
                            {
                                using (IDbCommand command = this._database.Connection.CreateCommand())
                                {
                                    command.CommandText = "INSERT INTO [towerhistory] (victory, time, atkrSide, atkrOrg, atkrName, defSide, defOrg, zone, xCoord, yCoord, LCA) VALUES (0," +
                                                          TimeStamp.Now + ", '" + atkrSide + "', '" + atkrOrg + "', '" + atkrName + "', '" + defSide + "', '" + defOrg + "', '" + zone + "', " + x_coord + ", " +
                                                          y_coord + ", " + LCA + ")";
                                    IDataReader reader = command.ExecuteReader();
                                }
                            }
                            catch
                            {
                                this.sendMessage(bot, "Error during tower history archiving!");
                            }
                            break;

                        case 147506468:     // Notum Wars Update: The %s organization %s lost their base in %s.
                            string lostSide = e.Descrambled.Arguments[0].Message;
                            string lostOrg  = e.Descrambled.Arguments[1].Message;
                            string lostZone = e.Descrambled.Arguments[2].Message;
                            try
                            {
                                using (IDbCommand command = this._database.Connection.CreateCommand())
                                {
                                    command.CommandText = "INSERT INTO [towerhistory] (victory, time, defSide, defOrg, zone) VALUES (1, " +
                                                          TimeStamp.Now + ", '" + lostSide + "', '" + lostOrg + "', '" + lostZone + "')";
                                    IDataReader reader = command.ExecuteReader();
                                }
                            }
                            catch
                            {
                                this.sendMessage(bot, "Error during tower history archiving!");
                            }
                            break;
                        }
                    }
                }
                else
                {
                    //%s just attacked the %s organization %s's tower in %s at location (%d, %d).
                    Regex soloAttack = new Regex(@"(.+)\sjust\sattacked\sthe\s([a-zA-Z]+)\sorganization\s(.+)'s\stower\sin\s(.+)\sat\slocation\s\(([0-9]+),\s([0-9]+)\)");
                    if (soloAttack.IsMatch(e.Message))
                    {
                        Match  m        = soloAttack.Match(e.Message);
                        string atkrName = m.Groups[1].Value;
                        string defSide  = m.Groups[2].Value;
                        string defOrg   = m.Groups[3].Value;
                        string zone     = m.Groups[4].Value;
                        int    x_coord;
                        int    y_coord;
                        int.TryParse(m.Groups[5].Value, out x_coord);
                        int.TryParse(m.Groups[6].Value, out y_coord);
                        int LCA = this.grabLCA(zone, x_coord, y_coord);

                        WhoisResult whois     = XML.GetWhois(atkrName.ToLower(), bot.Dimension);
                        int         atkrLvl   = whois.Stats.Level;
                        int         atkrAiLvl = whois.Stats.DefenderLevel;
                        string      atkrProf  = whois.Stats.Profession;
                        string      atkrSide  = whois.Stats.Faction;
                        string      message   = HTML.CreateColorString(bot.ColorHeaderHex, atkrName) + " " + HTML.CreateColorString(bot.ColorHeaderHex, "(") +
                                                this.sideColor(atkrLvl + "/" + atkrAiLvl + " " + atkrProf, atkrSide) + HTML.CreateColorString(bot.ColorHeaderHex, ")") +
                                                " has attacked " + HTML.CreateColorString(bot.ColorHeaderHex, defOrg) + " " + HTML.CreateColorString(bot.ColorHeaderHex, "(") +
                                                this.sideColor(defSide, defSide) + HTML.CreateColorString(bot.ColorHeaderHex, ")") + " in " + zone + " at " +
                                                HTML.CreateColorString(bot.ColorHeaderHex, "(x" + LCA.ToString() + " " + x_coord.ToString() + "x" + y_coord.ToString() + ")") +
                                                HTML.CreateColorString(bot.ColorHeaderHex, ")") + ".";
                        this.sendMessage(bot, message);
                        try
                        {
                            using (IDbCommand command = this._database.Connection.CreateCommand())
                            {
                                command.CommandText = "INSERT INTO [towerhistory] (victory, time, atkrSide, atkrName, defSide, defOrg, zone, xCoord, yCoord, LCA) VALUES (0," +
                                                      TimeStamp.Now + ", '" + atkrSide + "', '" + atkrName + "', '" + defSide + "', '" + defOrg + "', '" + zone + "', " + x_coord + ", " +
                                                      y_coord + ", " + LCA + ")";
                                IDataReader reader = command.ExecuteReader();
                            }
                        }
                        catch
                        {
                            this.sendMessage(bot, "Error during tower history archiving!");
                        }
                    }

                    //The %s organization %s attacked the %s %s at %s. The attackers won!!
                    Regex Victory = new Regex(@"The\s(.*)\sorganization\s(.*)\sattacked\sthe\s([a-zA-Z]+)\s(.*)\sat\stheir\sbase\sin\s(.*)\.\sThe\sattackers\swon!!");
                    if (Victory.IsMatch(e.Message))
                    {
                        Match  m        = Victory.Match(e.Message);
                        string atkrSide = m.Groups[1].Value;
                        string atkrOrg  = m.Groups[2].Value;
                        string defSide  = m.Groups[3].Value;
                        string defOrg   = m.Groups[4].Value;
                        string zone     = m.Groups[5].Value;
                        try
                        {
                            using (IDbCommand command = this._database.Connection.CreateCommand())
                            {
                                command.CommandText = "INSERT INTO [towerhistory] (victory, time, atkrSide, atkrOrg, defSide, defOrg, zone) VALUES (1, " +
                                                      TimeStamp.Now + ", '" + atkrSide + "', '" + atkrOrg + "', '" + defSide + "', '" + defOrg + "', '" + zone + "')";
                                IDataReader reader = command.ExecuteReader();
                            }
                        }
                        catch
                        {
                            this.sendMessage(bot, "Error during tower history archiving!");
                        }
                    }
                }
            }
        }
Beispiel #11
0
        private void OnGlyphsJoinCommand(BotShell bot, CommandArgs e)
        {
            if (!this._raffleActive)
            {
                bot.SendReply(e, "There's no glyph raffle active");
                return;
            }

            if (e.Args.Length < 1)
            {
                bot.SendReply(e, "Glyph Raffle »» ", this._raffleWindow);
                return;
            }
            int    id       = 0;
            string username = bot.Users.GetMain(e.Sender);

            try { id = Convert.ToInt32(e.Args[0]); }
            catch
            {
                bot.SendReply(e, "Invalid ID");
                return;
            }
            lock (this._raffleMains)
            {
                if (this._raffleMains.Contains(username))
                {
                    bot.SendReply(e, "You can only join 1 raffle");
                    return;
                }
            }
            lock (this._raffleJoined)
            {
                if (!this._raffleJoined.ContainsKey(id))
                {
                    bot.SendReply(e, "There's no item with that ID in the current glyph raffle");
                    return;
                }
                if (this._raffleJoined[id].Contains(e.Sender))
                {
                    bot.SendReply(e, "You already joined this raffle");
                    return;
                }
                lock (this._professions)
                {
                    if (this._professions.ContainsValue(id))
                    {
                        WhoisResult whois = XML.GetWhois(e.Sender, bot.Dimension);
                        if (whois == null || !whois.Success)
                        {
                            bot.SendReply(e, "Unable to get your profession. This is required to join this raffle. Please try again later");
                            return;
                        }
                        if (!this._professions.ContainsKey(whois.Stats.Profession.ToLower()))
                        {
                            bot.SendReply(e, "Your profession was not found in our database. Please contact an administrator if you feel this is an error");
                            return;
                        }
                        if (this._professions[whois.Stats.Profession.ToLower()] != id)
                        {
                            bot.SendReply(e, "Profession restrictions prevent you from joining this raffle");
                            return;
                        }
                    }
                }
                this._raffleJoined[id].Add(e.Sender);
                lock (this._raffleMains)
                    this._raffleMains.Add(username);
            }
            bot.SendReply(e, "You have joined the raffle");
            return;
        }
Beispiel #12
0
        public void BuildList(BotShell bot, string[] users, ref RichTextWindow window, ref int results, string profs)
        {
            if (window == null)
            {
                return;
            }
            if (users.Length == 0)
            {
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

                    // Afk
                    if (this.DisplayAfk)
                    {
                        lock (this.Afk)
                        {
                            if (this.Afk.ContainsKey(name))
                            {
                                window.AppendString(" :: ");
                                window.AppendColorString(RichTextWindow.ColorRed, "AFK");
                            }
                        }
                    }
                    window.AppendColorEnd();
                    window.AppendLineBreak();
                    results++;
                }
                if (this.DisplayHeaders == "Text" || this.DisplayHeaders == "Icons")
                {
                    window.AppendLineBreak();
                }
            }
            if (this.DisplayHeaders == "Off")
            {
                window.AppendLineBreak();
            }
        }
Beispiel #13
0
        private void OnWhoisCommand(BotShell bot, CommandArgs e, AoLib.Net.Server dimension, Boolean showDimension)
        {
            if (!showDimension && dimension == AoLib.Net.Server.Test)
            {
                bot.SendReply(e, "The whois command is not available on the test server.");
                return;
            }
            if (dimension == bot.Dimension)
            {
                if (bot.GetUserID(e.Args[0]) < 100)
                {
                    bot.SendReply(e, "No such user: "******": ");
                }
                error += "Unable to gather information on that user " + this.TimeoutError;
                bot.SendReply(e, error);
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            builder.Append(" »» " + window.ToString("More Information"));
            bot.SendReply(e, builder.ToString());
        }
Beispiel #14
0
        private void OnOrganizationCommand(BotShell bot, CommandArgs e)
        {
            if (bot.GetUserID(e.Args[0]) < 100)
            {
                bot.SendReply(e, "No such user: "******"Organization »» Gathering Data...");

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

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

                    window.AppendTitle(organization.Name);

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

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

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

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

                    membersWindow.AppendHeader("Members");

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

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

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

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

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

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

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

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

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

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

                    window.AppendRawString(membersWindow.Text);

                    bot.SendReply(e, organization.Name + " »» ", window);
                    return;
                }
            }
            bot.SendReply(e, "Unable to gather information on that organization " + this.TimeoutError);
        }
Beispiel #15
0
        private void OnRaidJoinCommand(BotShell bot, CommandArgs e)
        {
            if (!bot.PrivateChannel.IsOn(e.Sender))
            {
                bot.SendReply(e, "You're required to be on the private channel to join the raid");
                return;
            }
            if (!this._core.Running)
            {
                bot.SendReply(e, "There is currently no raid active");
                return;
            }
            if (this._core.IsRaider(e.Sender))
            {
                bot.SendReply(e, "You're already in the raid");
                return;
            }
            if (this._core.Locked)
            {
                bot.SendReply(e, "The raid is currently locked");
                return;
            }
            string username = bot.Users.GetMain(e.Sender);

            if (this._core.IsRaider(username))
            {
                bot.SendReply(e, "You already have a character on this raid");
                return;
            }
            lock (this._bans)
            {
                if (this._bans.ContainsKey(username))
                {
                    bot.SendReply(e, "Your access to the raid has been temporarily disabled");
                    return;
                }
            }
            if (this.AltsLevelReq > 0 || this.MainsLevelReq > 0)
            {
                int         level = 0;
                WhoisResult whois = XML.GetWhois(e.Sender, bot.Dimension);
                if (whois != null && whois.Success)
                {
                    level = whois.Stats.Level;
                }
                if (bot.Users.IsAlt(e.Sender))
                {
                    if (level < this.AltsLevelReq)
                    {
                        bot.SendReply(e, "Alts are required to be at least level " + HTML.CreateColorString(bot.ColorHeaderHex, this.AltsLevelReq.ToString()) + " in order to join the raid");
                        return;
                    }
                }
                else
                {
                    if (level < this.MainsLevelReq)
                    {
                        bot.SendReply(e, "Mains are required to be at least level " + HTML.CreateColorString(bot.ColorHeaderHex, this.MainsLevelReq.ToString()) + " in order to join the raid");
                        return;
                    }
                }
            }
            int  credits = 0;
            int  max     = 0;
            bool charged = false;

            if (this.CreditsEnabled && !this.WithdrawCredit(bot, username, out credits, out max, out charged))
            {
                bot.SendReply(e, "You don't have enough raid credits to join this raid");
                return;
            }
            this._core.AddRaider(e.Sender, true);
            if (charged)
            {
                bot.SendPrivateMessage(e.Sender, 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(e.Sender, null, this.InternalName, "credits", string.Format("{0} has been charged a raid credit (Credits Left: {1})", e.Sender, credits));
            }
        }
Beispiel #16
0
        private void OnSbCommand(BotShell bot, CommandArgs e)
        {
            List <string> atrox    = new List <string>();
            List <string> nanomage = new List <string>();
            List <string> opifex   = new List <string>();
            List <string> solitus  = new List <string>();

            foreach (KeyValuePair <UInt32, Friend> kvp in bot.PrivateChannel.List())
            {
                WhoisResult whois = XML.GetWhois(kvp.Value.User, bot.Dimension);
                if (whois == null || whois.Stats == null || whois.Stats.Breed == null)
                {
                    continue;
                }

                lock (this.Shadowbreeds)
                    if (!this.Shadowbreeds.ContainsKey(kvp.Value.User.ToLower()))
                    {
                        if (whois.Stats.Level >= 205)
                        {
                            this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unknown);
                        }
                        else
                        {
                            this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unavailable);
                        }
                    }

                switch (whois.Stats.Breed.ToLower())
                {
                case "atrox":
                    atrox.Add(whois.Name.Nickname.ToLower());
                    break;

                case "nano":
                    nanomage.Add(whois.Name.Nickname.ToLower());
                    break;

                case "opifex":
                    opifex.Add(whois.Name.Nickname.ToLower());
                    break;

                case "solitus":
                    solitus.Add(whois.Name.Nickname.ToLower());
                    break;
                }
            }

            lock (this.Shadowbreeds)
            {
                List <string> remove = new List <string>();
                foreach (KeyValuePair <string, ShadowbreedState> shadowbreed in this.Shadowbreeds)
                {
                    if (atrox.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (nanomage.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (opifex.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    if (solitus.Contains(shadowbreed.Key.ToLower()))
                    {
                        continue;
                    }
                    remove.Add(shadowbreed.Key);
                }
                foreach (string shadowbreed in remove)
                {
                    this.Shadowbreeds.Remove(shadowbreed);
                }

                if (this.Shadowbreeds.Count < 1)
                {
                    bot.SendReply(e, "The Shadowbreeds list is empty");
                    return;
                }
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            if (atrox.Count > 0)
            {
                window.AppendHeader("Atrox");
                this.CreateSbList(bot, ref window, atrox);
                window.AppendLineBreak();
            }
            if (nanomage.Count > 0)
            {
                window.AppendHeader("Nanomage");
                this.CreateSbList(bot, ref window, nanomage);
                window.AppendLineBreak();
            }
            if (opifex.Count > 0)
            {
                window.AppendHeader("Opifex");
                this.CreateSbList(bot, ref window, opifex);
                window.AppendLineBreak();
            }
            if (solitus.Count > 0)
            {
                window.AppendHeader("Solitus");
                this.CreateSbList(bot, ref window, solitus);
                window.AppendLineBreak();
            }

            window.AppendHeader("Options");
            window.AppendBotCommand("Request Shadowbreed State", "sb get");
            window.AppendLineBreak();
            window.AppendBotCommand("Reset Shadowbreed List", "sb reset");

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

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

            foreach (RaidCore.Raider raider in raiders)
            {
                WhoisResult whois = XML.GetWhois(raider.Character, bot.Dimension);
                if (whois == null || !whois.Success)
                {
                    whois                     = new WhoisResult();
                    whois.Name                = new WhoisResult_Name();
                    whois.Name.Nickname       = raider.Character;
                    whois.Stats               = new WhoisResult_Stats();
                    whois.Stats.Level         = 0;
                    whois.Stats.Profession    = "Unknown";
                    whois.Stats.DefenderLevel = 0;
                }
                if (!sorted.ContainsKey(whois.Stats.Profession))
                {
                    sorted.Add(whois.Stats.Profession, new Dictionary <RaidCore.Raider, WhoisResult>());
                }
                sorted[whois.Stats.Profession].Add(raider, whois);
            }
            foreach (KeyValuePair <string, Dictionary <RaidCore.Raider, WhoisResult> > kvp in sorted)
            {
                window.AppendHighlight(kvp.Key);
                window.AppendLineBreak();
                foreach (KeyValuePair <RaidCore.Raider, WhoisResult> raider in kvp.Value)
                {
                    window.AppendNormalStart();
                    window.AppendString("- " + raider.Key.Character);
                    if (raider.Key.Main != raider.Key.Character)
                    {
                        window.AppendString(" (" + raider.Key.Main + ")");
                    }
                    if (raider.Value.Stats.Profession != "Unknown")
                    {
                        window.AppendString(" (L " + raider.Value.Stats.Level + "/" + raider.Value.Stats.DefenderLevel + ")");
                    }
                    if (!raider.Key.OnRaid)
                    {
                        window.AppendString(" (");
                        window.AppendColorString(RichTextWindow.ColorRed, "Inactive");
                        window.AppendString(")");
                    }
                    window.AppendString(" [");
                    window.AppendCommand("Check", "/assist " + raider.Key.Character);
                    window.AppendString("] [");
                    window.AppendBotCommand("Kick", "raid kick " + raider.Key.Character);
                    window.AppendString("] ");
                    window.AppendColorEnd();
                    window.AppendLineBreak(true);
                }
                window.AppendLineBreak();
            }
            bot.SendReply(e, "Raiders List »» ", window);
        }
Beispiel #18
0
        private bool Listener_OnCommand(UserInfo user, string message)
        {
            // !online
            if (message.ToLower() == "!online")
            {
                string   reply  = string.Empty;
                string[] online = this.Bot.FriendList.Online("notify");
                if (online.Length == 0)
                {
                    reply += "No users online.";
                }
                else
                {
                    reply += "Online: " + string.Join(", ", online) + ".";
                }

                if (this.RelayMode == "guest" || this.RelayMode == "both")
                {
                    Dictionary <UInt32, Friend> list = this.Bot.PrivateChannel.List();
                    List <string> guests             = new List <string>();
                    foreach (KeyValuePair <UInt32, Friend> guest in list)
                    {
                        guests.Add(Format.UppercaseFirst(guest.Value.User));
                    }
                    if (guests.Count > 0)
                    {
                        reply += " Guests: " + string.Join(", ", guests.ToArray());
                    }
                }
                IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, reply));
                return(true);
            }

            // !is and !whois
            if (message.Trim().Contains(" "))
            {
                string[] parts    = message.Trim().Split(' ');
                string   command  = parts[0];
                string   username = parts[1];
                switch (command)
                {
                case "!is":
                    UInt32      userid = this.Bot.GetUserID(username);
                    OnlineState state  = this.Bot.FriendList.IsOnline(userid);
                    if (state == OnlineState.Timeout)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "Request timed out. Please try again later"));
                        return(true);
                    }
                    if (state == OnlineState.Unknown)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "No such user: "******"Online";
                    if (state == OnlineState.Offline)
                    {
                        append = "Offline";
                        Int64 seen = this.Bot.FriendList.Seen(username);
                        if (seen > 1)
                        {
                            append += " and was last seen online at " + Format.DateTime(seen, FormatStyle.Large) + " GMT";
                        }
                    }
                    IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, String.Format("{0} is currently {1}", Format.UppercaseFirst(username), append)));
                    break;

                case "!whois":
                    if (this.Bot.GetUserID(username) < 100)
                    {
                        IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, "No such user: "******"Unable to gather information on that user"));
                        return(true);
                    }
                    IRCQueue.Enqueue(Plugins.IRCQueue.Priority.High, new Plugins.IRCQueue.IRCQueueItem(user.Nick, Format.Whois(whois, FormatStyle.Large)));
                    break;
                }
            }
            return(false);
        }