Example #1
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle();
            lock (this._database.Connection)
            {
                using (IDbCommand command = this._database.Connection.CreateCommand())
                {
                    command.CommandText = "SELECT title, rule FROM rules WHERE visible = 'true'";
                    IDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        window.AppendHeader(reader.GetString(0));
                        string rule = reader.GetString(1);
                        rule = rule.Replace("[b]", bot.ColorNormal);
                        rule = rule.Replace("[/b]", HTML.CreateColorEnd());
                        window.AppendHighlightStart();
                        window.AppendRawString(rule);
                        window.AppendColorEnd();
                        window.AppendLineBreak(2);
                    }
                    reader.Close();
                }
            }
            bot.SendReply(e, "Rules »» ", window);
        }
Example #2
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);
        }
Example #3
0
        private void OnAdminsCommand(BotShell bot, CommandArgs e)
        {
            SortedDictionary <string, UserLevel> members = bot.Users.GetUsers();
            List <string> chars = new List <string>();

            RichTextWindow window      = new RichTextWindow(bot);
            RichTextWindow superadmins = new RichTextWindow(bot);
            RichTextWindow admins      = new RichTextWindow(bot);
            RichTextWindow leaders     = new RichTextWindow(bot);

            int adminCount = 0;

            foreach (KeyValuePair <string, UserLevel> member in members)
            {
                RichTextWindow tmp = null;
                switch (member.Value)
                {
                case UserLevel.SuperAdmin:
                    tmp = superadmins;
                    break;

                case UserLevel.Admin:
                    tmp = admins;
                    break;

                case UserLevel.Leader:
                    tmp = leaders;
                    break;

                default:
                    continue;
                }
                chars.Add(member.Key.ToLower());
                tmp.AppendHighlightStart();
                tmp.AppendString(member.Key);
                tmp.AppendString(" is ");
                if (bot.FriendList.IsOnline(member.Key) == OnlineState.Online)
                {
                    tmp.AppendColorString(RichTextWindow.ColorGreen, "Online");
                }
                else
                {
                    tmp.AppendColorString(RichTextWindow.ColorRed, "Offline");
                }
                tmp.AppendColorEnd();
                tmp.AppendLineBreak();
                if (!bot.FriendList.IsFriend(member.Key))
                {
                    bot.FriendList.Add(this.InternalName, member.Key);
                }
                foreach (string alt in bot.Users.GetAlts(member.Key))
                {
                    chars.Add(alt.ToLower());
                    tmp.AppendNormalStart();
                    tmp.AppendString("- " + Format.UppercaseFirst(alt));
                    tmp.AppendString(" is ");
                    if (bot.FriendList.IsOnline(alt) == OnlineState.Online)
                    {
                        tmp.AppendColorString(RichTextWindow.ColorGreen, "Online");
                    }
                    else
                    {
                        tmp.AppendColorString(RichTextWindow.ColorRed, "Offline");
                    }
                    tmp.AppendColorEnd();
                    tmp.AppendLineBreak();
                    if (!bot.FriendList.IsFriend(alt))
                    {
                        bot.FriendList.Add(this.InternalName, alt);
                    }
                }
                adminCount++;
            }
            foreach (string friend in bot.FriendList.List(this.InternalName))
            {
                if (!chars.Contains(friend.ToLower()))
                {
                    bot.FriendList.Remove(this.InternalName, friend);
                }
            }

            window.AppendTitle("Super Admins");
            window.AppendRawString(superadmins.Text);
            window.AppendLineBreak();

            window.AppendHeader("Admins");
            window.AppendRawString(admins.Text);
            window.AppendLineBreak();

            window.AppendHeader("Leaders");
            window.AppendRawString(leaders.Text);
            window.AppendLineBreak();

            bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, adminCount.ToString()) + " Admins »» ", window);
        }
Example #4
0
        private void OnHistoryCommand(BotShell bot, CommandArgs e)
        {
            if (bot.GetUserID(e.Args[0]) < 100)
            {
                bot.SendReply(e, "No such user: "******"'s History »» Gathering Data...");

            HistoryResult history = XML.GetHistory(e.Args[0].ToLower(), bot.Dimension);

            if (history == null || history.Items == null)
            {
                bot.SendReply(e, "Unable to gather information on that user " + this.TimeoutError);
                return;
            }

            RichTextWindow window = new RichTextWindow(bot);

            window.AppendTitle("Auno.org Player History");
            window.AppendHighlight("Character: ");
            window.AppendNormal(Format.UppercaseFirst(e.Args[0]));
            window.AppendLineBreak();
            window.AppendHighlight("Entries: ");
            window.AppendNormal(history.Items.Length.ToString());
            window.AppendLineBreak();
            window.AppendHighlight("URL: ");
            window.AppendNormal(string.Format(this.CharAunoWebsite, (int)bot.Dimension, e.Args[0].ToLower()));
            window.AppendLineBreak(2);

            window.AppendHighlightStart();
            window.AppendString("Date             ");
            window.AppendString("LVL   ");
            window.AppendString("DR   ");
            window.AppendColorString("000000", "'");
            window.AppendString("Faction   ");
            window.AppendString("Organization");
            window.AppendColorEnd();
            window.AppendLineBreak();

            foreach (HistoryResult_Entry entry in history.Items)
            {
                window.AppendNormalStart();
                window.AppendString(entry.Date);
                window.AppendHighlight(" | ");
                window.AppendString(entry.Level.ToString("000"));
                window.AppendHighlight(" | ");
                window.AppendString(entry.DefenderLevel.ToString("00"));
                window.AppendHighlight(" | ");
                switch (entry.Faction.ToLower())
                {
                case "clan":
                    window.AppendString("Clan    ");
                    break;

                case "omni":
                    window.AppendString("Omni   ");
                    break;

                case "neutral":
                    window.AppendString("Neutral");
                    break;

                default:
                    window.AppendString("Unknown");
                    break;
                }
                window.AppendHighlight(" | ");
                if (entry.Organization != null && entry.Organization != String.Empty)
                {
                    window.AppendString(entry.Rank);
                    window.AppendString(" of ");
                    window.AppendString(entry.Organization);
                }
                window.AppendColorEnd();
                window.AppendLineBreak();
            }
            bot.SendReply(e, Format.UppercaseFirst(e.Args[0]) + "'s History »» ", window);
        }