Open sourced NatiBot
This commit is contained in:
53
SLBot/bot/Commands/Estate/DilationCommand.cs
Normal file
53
SLBot/bot/Commands/Estate/DilationCommand.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DilationCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public class DilationCommand : Command
|
||||
{
|
||||
public DilationCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "dilation";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Dilation.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Dilation.Dilation"), Client.Network.CurrentSim.Stats.Dilation.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
135
SLBot/bot/Commands/Estate/DownloadTerrainCommand.cs
Normal file
135
SLBot/bot/Commands/Estate/DownloadTerrainCommand.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DownloadTerrainCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
|
||||
public class DownloadTerrainCommand : Command
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a Synchronization event object
|
||||
/// </summary>
|
||||
private static AutoResetEvent xferTimeout = new AutoResetEvent(false);
|
||||
|
||||
/// <summary>A string we use to report the result of the request with.</summary>
|
||||
private static System.Text.StringBuilder result = new System.Text.StringBuilder();
|
||||
|
||||
private static string fileName;
|
||||
|
||||
/// <summary>
|
||||
/// Download a simulators raw terrain data and save it to a file
|
||||
/// </summary>
|
||||
/// <param name="testClient"></param>
|
||||
public DownloadTerrainCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Name = "downloadterrain";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.DownloadTerrain.Description") + " " + bot.Localization.clResourceManager.getText("Commands.DownloadTerrain.Usage");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the application
|
||||
/// </summary>
|
||||
/// <param name="args">arguments passed to this module</param>
|
||||
/// <param name="fromAgentID">The ID of the avatar sending the request</param>
|
||||
/// <returns></returns>
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
int timeout = 120000; // default the timeout to 2 minutes
|
||||
fileName = "terrain/" + Client.Network.CurrentSim.Name + ".raw";
|
||||
|
||||
if (args.Length > 0 && int.TryParse(args[0], out timeout) != true)
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTerrain.Usage");
|
||||
|
||||
// Create a delegate which will be fired when the simulator receives our download request
|
||||
// Starts the actual transfer request
|
||||
AssetManager.InitiateDownloadCallback initiateDownloadDelegate = delegate(string simFilename, string viewerFileName)
|
||||
{
|
||||
Client.Assets.RequestAssetXfer(simFilename, false, false, UUID.Zero, AssetType.Unknown, false);
|
||||
};
|
||||
|
||||
// Subscribe to the event that will tell us the status of the download
|
||||
Client.Assets.OnXferReceived += new AssetManager.XferReceivedCallback(Assets_OnXferReceived);
|
||||
|
||||
// subscribe to the event which tells us when the simulator has received our request
|
||||
Client.Assets.OnInitiateDownload += initiateDownloadDelegate;
|
||||
|
||||
// configure request to tell the simulator to send us the file
|
||||
List<string> parameters = new List<string>();
|
||||
parameters.Add("download filename");
|
||||
parameters.Add(fileName);
|
||||
// send the request
|
||||
Client.Estate.EstateOwnerMessage("terrain", parameters);
|
||||
|
||||
// wait for (timeout) seconds for the request to complete (defaults 2 minutes)
|
||||
if (!xferTimeout.WaitOne(timeout, false))
|
||||
{
|
||||
result.Append(bot.Localization.clResourceManager.getText("Commands.DownloadTerrain.Timeout"));
|
||||
}
|
||||
|
||||
// unsubscribe from events
|
||||
Client.Assets.OnInitiateDownload -= initiateDownloadDelegate;
|
||||
Client.Assets.OnXferReceived -= new AssetManager.XferReceivedCallback(Assets_OnXferReceived);
|
||||
|
||||
// return the result
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the reply to the OnXferReceived event
|
||||
/// </summary>
|
||||
/// <param name="xfer"></param>
|
||||
private void Assets_OnXferReceived(XferDownload xfer)
|
||||
{
|
||||
if (xfer.Success)
|
||||
{
|
||||
// set the result message
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.DownloadTerrain.Success"), xfer.Filename, xfer.Size, fileName);
|
||||
|
||||
// write the file to disk
|
||||
FileStream stream = new FileStream(fileName, FileMode.Create);
|
||||
BinaryWriter w = new BinaryWriter(stream);
|
||||
w.Write(xfer.AssetData);
|
||||
w.Close();
|
||||
|
||||
// tell the application we've gotten the file
|
||||
xferTimeout.Set();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
SLBot/bot/Commands/Estate/RegionInfoCommand.cs
Normal file
84
SLBot/bot/Commands/Estate/RegionInfoCommand.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : RegionInfoCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
public class RegionInfoCommand : Command
|
||||
{
|
||||
public RegionInfoCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "regioninfo";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.RegionInfo.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.AppendLine(Client.Network.CurrentSim.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.UUID"));
|
||||
output.AppendLine(Client.Network.CurrentSim.ID.ToString());
|
||||
uint x, y;
|
||||
Utils.LongToUInts(Client.Network.CurrentSim.Handle, out x, out y);
|
||||
output.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.RegionInfo.Handle"), Client.Network.CurrentSim.Handle, x, y));
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.Access"));
|
||||
output.AppendLine(Client.Network.CurrentSim.Access.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.Flags"));
|
||||
output.AppendLine(Client.Network.CurrentSim.Flags.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainBase0"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainBase0.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainBase1"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainBase1.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainBase2"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainBase2.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainBase3"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainBase3.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainDetail0"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainDetail0.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainDetail1"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainDetail1.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainDetail2"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainDetail2.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.TerrainDetail3"));
|
||||
output.AppendLine(Client.Network.CurrentSim.TerrainDetail3.ToString());
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.RegionInfo.WaterHeight"));
|
||||
output.AppendLine(Client.Network.CurrentSim.WaterHeight.ToString());
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
79
SLBot/bot/Commands/Estate/StatsCommand.cs
Normal file
79
SLBot/bot/Commands/Estate/StatsCommand.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : StatsCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
public class StatsCommand : Command
|
||||
{
|
||||
public StatsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "stats";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Stats.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Simulator sim = Client.Network.Simulators[i];
|
||||
|
||||
output.AppendLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Stats.Info1"),
|
||||
sim.ToString(), sim.Stats.Dilation, sim.Stats.IncomingBPS, sim.Stats.OutgoingBPS,
|
||||
sim.Stats.ResentPackets, sim.Stats.ReceivedResends));
|
||||
}
|
||||
}
|
||||
|
||||
Simulator csim = Client.Network.CurrentSim;
|
||||
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Stats.Packets"), Client.Network.InboxCount);
|
||||
output.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Stats.Info2"),
|
||||
csim.Stats.FPS, csim.Stats.PhysicsFPS, csim.Stats.AgentUpdates, csim.Stats.Objects, csim.Stats.ScriptedObjects));
|
||||
output.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Stats.Info3"),
|
||||
csim.Stats.FrameTime, csim.Stats.NetTime, csim.Stats.ImageTime, csim.Stats.PhysicsTime, csim.Stats.ScriptTime, csim.Stats.OtherTime));
|
||||
output.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Stats.Info4"),
|
||||
csim.Stats.Agents, csim.Stats.ChildAgents, csim.Stats.ActiveScripts));
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
118
SLBot/bot/Commands/Estate/UploadRawTerrainCommand.cs
Normal file
118
SLBot/bot/Commands/Estate/UploadRawTerrainCommand.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : UploadRawTerrainCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
|
||||
public class UploadRawTerrainCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent WaitForUploadComplete = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
/// <summary>
|
||||
/// Download a simulators raw terrain data and save it to a file
|
||||
/// </summary>
|
||||
/// <param name="testClient"></param>
|
||||
public UploadRawTerrainCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Name = "uploadterrain";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.Description") + " " + bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string fileName = String.Empty;
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.Usage");
|
||||
|
||||
|
||||
fileName = args[0];
|
||||
|
||||
if (!System.IO.File.Exists(fileName))
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.FileNotFound"), fileName);
|
||||
}
|
||||
|
||||
// Setup callbacks for upload request reply and progress indicator
|
||||
// so we can detect when the upload is complete
|
||||
Client.Assets.OnUploadProgress += new AssetManager.UploadProgressCallback(Assets_OnUploadProgress);
|
||||
|
||||
byte[] fileData = File.ReadAllBytes(fileName);
|
||||
|
||||
Client.Estate.UploadTerrain(fileData, fileName);
|
||||
|
||||
// Wait for upload to complete. Upload request is fired in callback from first request
|
||||
if (!WaitForUploadComplete.WaitOne(120000, false))
|
||||
{
|
||||
Cleanup();
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
Cleanup();
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadRawTerrain.Success");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister previously subscribed event handlers
|
||||
/// </summary>
|
||||
private void Cleanup()
|
||||
{
|
||||
Client.Assets.OnUploadProgress -= new AssetManager.UploadProgressCallback(Assets_OnUploadProgress);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="upload"></param>
|
||||
void Assets_OnUploadProgress(AssetUpload upload)
|
||||
{
|
||||
if (upload.Transferred == upload.Size)
|
||||
{
|
||||
WaitForUploadComplete.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Console.WriteLine("Progress: {0}/{1} {2}/{3} {4}", upload.XferID, upload.ID, upload.Transferred, upload.Size, upload.Success);
|
||||
bot.Console.WriteLine(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user