Add pCampbot "show bot" console command to show more detailed information on a particular bot (e.g. what sims they are connected to)
parent
43940f6562
commit
a3e1b278a1
|
@ -97,11 +97,20 @@ namespace pCampBot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConnectionState ConnectionState { get; private set; }
|
public ConnectionState ConnectionState { get; private set; }
|
||||||
|
|
||||||
|
public List<Simulator> Simulators
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (Client.Network.Simulators)
|
||||||
|
return new List<Simulator>(Client.Network.Simulators);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of connections that this bot has to different simulators.
|
/// The number of connections that this bot has to different simulators.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Includes both root and child connections.</value>
|
/// <value>Includes both root and child connections.</value>
|
||||||
public int ConnectionsCount
|
public int SimulatorsCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -208,6 +208,10 @@ namespace pCampBot
|
||||||
m_console.Commands.AddCommand(
|
m_console.Commands.AddCommand(
|
||||||
"bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus);
|
"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>();
|
m_bots = new List<Bot>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +553,7 @@ namespace pCampBot
|
||||||
totals[pb.ConnectionState]++;
|
totals[pb.ConnectionState]++;
|
||||||
|
|
||||||
cdt.AddRow(
|
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());
|
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)
|
internal void Grid_GridRegion(object o, GridRegionEventArgs args)
|
||||||
{
|
{
|
||||||
lock (RegionsKnown)
|
lock (RegionsKnown)
|
||||||
|
|
Loading…
Reference in New Issue