Exemple #1
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());
        }