Add pCampbot "show bot" console command to show more detailed information on a particular bot (e.g. what sims they are connected to)

0.7.6-extended
Justin Clark-Casey (justincc) 2013-08-20 18:41:09 +01:00
parent 43940f6562
commit a3e1b278a1
2 changed files with 58 additions and 2 deletions

View File

@ -97,11 +97,20 @@ namespace pCampBot
/// </summary>
public ConnectionState ConnectionState { get; private set; }
public List<Simulator> Simulators
{
get
{
lock (Client.Network.Simulators)
return new List<Simulator>(Client.Network.Simulators);
}
}
/// <summary>
/// The number of connections that this bot has to different simulators.
/// </summary>
/// <value>Includes both root and child connections.</value>
public int ConnectionsCount
public int SimulatorsCount
{
get
{

View File

@ -208,6 +208,10 @@ namespace pCampBot
m_console.Commands.AddCommand(
"bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus);
m_console.Commands.AddCommand(
"bot", false, "show bot", "show bot <first-name> <last-name>",
"Shows the detailed status and settings of a particular bot.", HandleShowBotStatus);
m_bots = new List<Bot>();
}
@ -549,7 +553,7 @@ namespace pCampBot
totals[pb.ConnectionState]++;
cdt.AddRow(
pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.ConnectionsCount);
pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.SimulatorsCount);
}
}
@ -563,6 +567,49 @@ namespace pCampBot
MainConsole.Instance.Output(cdl.ToString());
}
private void HandleShowBotStatus(string module, string[] cmd)
{
if (cmd.Length != 4)
{
MainConsole.Instance.Output("Usage: show bot <first-name> <last-name>");
return;
}
string name = string.Format("{0} {1}", cmd[2], cmd[3]);
Bot bot;
lock (m_bots)
bot = m_bots.Find(b => b.Name == name);
if (bot == null)
{
MainConsole.Instance.Output("No bot found with name {0}", name);
return;
}
ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("Name", bot.Name);
cdl.AddRow("Status", bot.ConnectionState);
Simulator currentSim = bot.Client.Network.CurrentSim;
cdl.AddRow("Region", currentSim != null ? currentSim.Name : "(none)");
List<Simulator> connectedSimulators = bot.Simulators;
List<string> simulatorNames = connectedSimulators.ConvertAll<string>(cs => cs.Name);
cdl.AddRow("Connections", string.Join(", ", simulatorNames));
MainConsole.Instance.Output(cdl.ToString());
MainConsole.Instance.Output("Settings");
ConsoleDisplayList statusCdl = new ConsoleDisplayList();
GridClient botClient = bot.Client;
statusCdl.AddRow("SEND_AGENT_UPDATES", botClient.Settings.SEND_AGENT_UPDATES);
MainConsole.Instance.Output(statusCdl.ToString());
}
internal void Grid_GridRegion(object o, GridRegionEventArgs args)
{
lock (RegionsKnown)