Open sourced NatiBot
This commit is contained in:
BIN
SLBot/bot/.DS_Store
vendored
Normal file
BIN
SLBot/bot/.DS_Store
vendored
Normal file
Binary file not shown.
125
SLBot/bot/AccountFile.cs
Normal file
125
SLBot/bot/AccountFile.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AccountFile.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
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
public class AccountFile
|
||||
{
|
||||
private string m_file;
|
||||
|
||||
public AccountFile(string file)
|
||||
{
|
||||
this.m_file = file;
|
||||
}
|
||||
|
||||
public List<LoginDetails> Load()
|
||||
{
|
||||
return this.LoadXML();
|
||||
}
|
||||
|
||||
public List<LoginDetails> LoadXML()
|
||||
{
|
||||
List<LoginDetails> list = new List<LoginDetails>();
|
||||
if (!File.Exists(this.m_file))
|
||||
{
|
||||
MessageBox.Show("The file " + this.m_file + " was not found");
|
||||
return list;
|
||||
}
|
||||
XmlDocument document = new XmlDocument();
|
||||
document.Load(this.m_file);
|
||||
foreach (XmlNode node in document.DocumentElement.ChildNodes)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoginDetails item = new LoginDetails();
|
||||
item.FirstName = node.Attributes["Firstname"].InnerText;
|
||||
item.LastName = node.Attributes["Lastname"].InnerText;
|
||||
item.Password = node.Attributes["Password"].InnerText;
|
||||
item.MasterName = node.Attributes["MasterName"].InnerText;
|
||||
item.MasterKey = (OpenMetaverse.UUID)node.Attributes["MasterKey"].InnerText;
|
||||
item.StartLocation = node.Attributes["StartLocation"].InnerText;
|
||||
list.Add(item);
|
||||
continue;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
bot.Console.WriteLine(exception.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void Save(List<LoginDetails> accounts)
|
||||
{
|
||||
this.SaveXML(accounts);
|
||||
}
|
||||
|
||||
public void SaveXML(List<LoginDetails> accounts)
|
||||
{
|
||||
XmlDocument document = new XmlDocument();
|
||||
XmlNode newChild = document.CreateElement("Accounts");
|
||||
document.AppendChild(newChild);
|
||||
foreach (LoginDetails details in accounts)
|
||||
{
|
||||
XmlNode node2 = document.CreateElement(string.Format("Account", details.FirstName, details.LastName));
|
||||
XmlAttribute node = document.CreateAttribute("Firstname");
|
||||
node.InnerText = details.FirstName;
|
||||
node2.Attributes.Append(node);
|
||||
node = document.CreateAttribute("Lastname");
|
||||
node.InnerText = details.LastName;
|
||||
node2.Attributes.Append(node);
|
||||
node = document.CreateAttribute("Password");
|
||||
node.InnerText = details.Password;
|
||||
node2.Attributes.Append(node);
|
||||
node = document.CreateAttribute("MasterName");
|
||||
node.InnerText = details.MasterName;
|
||||
node2.Attributes.Append(node);
|
||||
node = document.CreateAttribute("MasterKey");
|
||||
node.InnerText = details.MasterKey.ToString();
|
||||
node2.Attributes.Append(node);
|
||||
node = document.CreateAttribute("StartLocation");
|
||||
node.InnerText = details.StartLocation;
|
||||
node2.Attributes.Append(node);
|
||||
newChild.AppendChild(node2);
|
||||
}
|
||||
document.Save(this.m_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
92
SLBot/bot/AttachmentCollection.cs
Normal file
92
SLBot/bot/AttachmentCollection.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AttachmentCollection.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
namespace bot
|
||||
{
|
||||
[XmlRoot("Attachment")]
|
||||
class AttachmentCollection
|
||||
{
|
||||
private Dictionary<UUID, Array> prims;
|
||||
|
||||
public AttachmentCollection()
|
||||
{
|
||||
prims = new Dictionary<UUID, Array>();
|
||||
}
|
||||
|
||||
public void Add(List<Primitive> Niggers)
|
||||
{
|
||||
foreach (Primitive prim in Niggers)
|
||||
{
|
||||
Array arr = new object[2]
|
||||
{
|
||||
StateToAttachmentPoint(prim.PrimData.State),
|
||||
OSDParser.SerializeLLSDXmlString(prim.GetOSD())
|
||||
};
|
||||
this.prims.Add(prim.ID, arr);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(UUID uuid)
|
||||
{
|
||||
prims.Remove(uuid);
|
||||
}
|
||||
|
||||
public static NBAttachmentPoint StateToAttachmentPoint(uint state)
|
||||
{
|
||||
const uint ATTACHMENT_MASK = 0xF0;
|
||||
uint fixedState = (((byte)state & ATTACHMENT_MASK) >> 4) | (((byte)state & ~ATTACHMENT_MASK) << 4);
|
||||
return (NBAttachmentPoint)fixedState;
|
||||
}
|
||||
|
||||
public Dictionary<UUID, Array> Prims
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.prims;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.prims = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
260
SLBot/bot/BotAccount.cs
Normal file
260
SLBot/bot/BotAccount.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BotAccount.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
|
||||
{
|
||||
using bot.NetCom;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
public class BotAccount
|
||||
{
|
||||
private SecondLifeBot client;
|
||||
private bool connecting;
|
||||
private bool deleted;
|
||||
//private DataGridViewClientRow gridViewRow;
|
||||
private ListViewItem listItem;
|
||||
private bot.LoginDetails loginDetails;
|
||||
|
||||
public delegate void OnDialogScriptReceivedCallback(SecondLifeBot bot,ScriptDialogEventArgs args);
|
||||
|
||||
public event OnDialogScriptReceivedCallback OnDialogScriptReceived;
|
||||
|
||||
public delegate void StatusChangeCallback(string newStatus,System.Drawing.Color color,ListViewItem item);
|
||||
|
||||
public event StatusChangeCallback OnStatusChange;
|
||||
|
||||
public delegate void MasterChangeCallback(string newMaster,ListViewItem item);
|
||||
|
||||
public event MasterChangeCallback OnMasterChange;
|
||||
|
||||
public delegate void AccountRemovedCallback(ListViewItem item);
|
||||
|
||||
public event AccountRemovedCallback OnAccountRemoved;
|
||||
|
||||
public delegate void LocationChangeCallback(string newLocation,ListViewItem item);
|
||||
|
||||
public event LocationChangeCallback OnLocationChanged;
|
||||
|
||||
public BotAccount(bot.LoginDetails loginDetails)
|
||||
{
|
||||
this.loginDetails = loginDetails;
|
||||
}
|
||||
|
||||
public void LocationChange(string newLocation)
|
||||
{
|
||||
if (OnLocationChanged != null)
|
||||
OnLocationChanged(newLocation, this.listItem);
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
if (this.client != null)
|
||||
{
|
||||
this.Disconnect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connecting = true;
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.Connecting"),
|
||||
System.Drawing.Color.Green, this.listItem);
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.Connecting");
|
||||
this.client = new SecondLifeBot(this);
|
||||
this.client.Netcom.ClientLoginStatus += new EventHandler<ClientLoginEventArgs>(this.Netcom_ClientLoginStatus);
|
||||
this.client.Netcom.ClientLoggedOut += new EventHandler(this.Netcom_ClientLoggedOut);
|
||||
this.client.OnDialogScriptReceived += new SecondLifeBot.OnDialogScriptReceivedCallback(this.client_OnDialogScriptReceived);
|
||||
}
|
||||
}
|
||||
|
||||
void client_OnDialogScriptReceived(SecondLifeBot bot, ScriptDialogEventArgs args)
|
||||
{
|
||||
if (OnDialogScriptReceived != null)
|
||||
OnDialogScriptReceived(bot, args);
|
||||
}
|
||||
|
||||
public bool Delete()
|
||||
{
|
||||
this.deleted = true;
|
||||
if (!this.connecting)
|
||||
{
|
||||
this.Disconnect(false);
|
||||
if (OnAccountRemoved != null)
|
||||
OnAccountRemoved(this.listItem);
|
||||
//this.GridViewRow.Delete();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Disconnect(bool reconnect)
|
||||
{
|
||||
if (this.client != null)
|
||||
{
|
||||
this.client.Dispose();
|
||||
this.client = null;
|
||||
if (reconnect)
|
||||
{
|
||||
this.Connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Netcom_ClientLoggedOut(object sender, EventArgs e)
|
||||
{
|
||||
SecondLifeBot client = ((NetCommunication)sender).Client;
|
||||
if (!this.deleted)
|
||||
{
|
||||
bot.Console.WriteLine(client, bot.Localization.clResourceManager.getText("botAccount.Offline"));
|
||||
}
|
||||
if (client == this.client)
|
||||
{
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.Offline"),
|
||||
System.Drawing.Color.Red, this.listItem);
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.Offline");
|
||||
}
|
||||
}
|
||||
|
||||
private void Netcom_ClientLoginStatus(object sender, ClientLoginEventArgs e)
|
||||
{
|
||||
//THREADING
|
||||
if (((NetCommunication)sender).Client == this.client)
|
||||
{
|
||||
switch (e.Status)
|
||||
{
|
||||
case LoginStatus.Failed:
|
||||
this.connecting = false;
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(e.Message, Color.Red, this.listItem);
|
||||
//this.gridViewRow.Status = e.Message;
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.LoginFailed"), e.Message);
|
||||
return;
|
||||
|
||||
case LoginStatus.None:
|
||||
return;
|
||||
|
||||
case LoginStatus.ConnectingToLogin:
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.ConnectingLogin");
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.ConnectingLogin"),
|
||||
Color.White, this.listItem);
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.ConnectingLogin"));
|
||||
return;
|
||||
|
||||
case LoginStatus.ReadingResponse:
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.ReadingResponse");
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.ReadingResponse"),
|
||||
Color.White, this.listItem);
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.ReadingResponse"));
|
||||
return;
|
||||
|
||||
case LoginStatus.ConnectingToSim:
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.ConnectingRegion");
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.ConnectingRegion"),
|
||||
Color.White, this.listItem);
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.ConnectingRegion"));
|
||||
return;
|
||||
|
||||
case LoginStatus.Redirecting:
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.Redirecting");
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.Redirecting"),
|
||||
Color.White, this.listItem);
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.Redirecting"));
|
||||
return;
|
||||
|
||||
case LoginStatus.Success:
|
||||
this.connecting = false;
|
||||
//this.gridViewRow.Status = bot.Localization.clResourceManager.getText("botAccount.Online");
|
||||
if (OnStatusChange != null)
|
||||
OnStatusChange(bot.Localization.clResourceManager.getText("botAccount.Online"),
|
||||
Color.Green, this.listItem);
|
||||
bot.Console.WriteLine(this.client, bot.Localization.clResourceManager.getText("botAccount.Online"));
|
||||
if (this.deleted)
|
||||
{
|
||||
this.Delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMaster(string masterName)
|
||||
{
|
||||
SetMaster(masterName, false);
|
||||
}
|
||||
|
||||
public void SetMaster(string masterName, bool save)
|
||||
{
|
||||
if (save)
|
||||
this.LoginDetails.MasterName = masterName;
|
||||
|
||||
if (OnMasterChange != null)
|
||||
OnMasterChange(masterName, this.listItem);
|
||||
//this.gridViewRow.MasterName = masterName;
|
||||
}
|
||||
|
||||
public SecondLifeBot Client
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.client;
|
||||
}
|
||||
}
|
||||
|
||||
public ListViewItem ListItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.listItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.listItem = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bot.LoginDetails LoginDetails
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.loginDetails;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
161
SLBot/bot/BotConfig.cs
Normal file
161
SLBot/bot/BotConfig.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BotConfig.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
|
||||
{
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
[XmlRoot("BotConfig")]
|
||||
public class BotConfig
|
||||
{
|
||||
private CampChair lastSitposition;
|
||||
private bool saveSitPosition;
|
||||
|
||||
private bool getTextures;
|
||||
private bool getSounds;
|
||||
private bool getAnimations;
|
||||
private bool informFriends;
|
||||
private bool touchMidnightMania;
|
||||
private bool haveLuck;
|
||||
private bool acceptInventoryOffers;
|
||||
|
||||
public CampChair LastSitposition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lastSitposition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lastSitposition = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveSitPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.saveSitPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.saveSitPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetTextures
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.getTextures;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.getTextures = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetSounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.getSounds;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.getSounds = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetAnimations
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.getAnimations;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.getAnimations = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool InformFriends
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.informFriends;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.informFriends = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TouchMidnightMania
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.touchMidnightMania;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.touchMidnightMania = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HaveLuck
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.haveLuck;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.haveLuck = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AcceptInventoryOffers
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.acceptInventoryOffers;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.acceptInventoryOffers = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
SLBot/bot/CampChair.cs
Normal file
46
SLBot/bot/CampChair.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CampChair.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
|
||||
{
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
[XmlRoot("CampPosition")]
|
||||
public class CampChair
|
||||
{
|
||||
private string location = string.Empty;
|
||||
private UUID prim = UUID.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
102
SLBot/bot/Chat.cs
Normal file
102
SLBot/bot/Chat.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : Chat.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
|
||||
{
|
||||
using bot.GUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
||||
public static class Chat
|
||||
{
|
||||
public struct structInstantMessage
|
||||
{
|
||||
public SecondLifeBot client;
|
||||
public InstantMessage message;
|
||||
public Simulator simulator;
|
||||
public DateTime timestamp;
|
||||
public bool isReceived;
|
||||
}
|
||||
|
||||
public struct structGeneralChat
|
||||
{
|
||||
public SecondLifeBot client;
|
||||
public string message;
|
||||
public ChatAudibleLevel audible;
|
||||
public ChatType type;
|
||||
public ChatSourceType sourceType;
|
||||
public string fromName;
|
||||
public UUID id;
|
||||
public UUID ownerid;
|
||||
public Vector3 position;
|
||||
public DateTime timestamp;
|
||||
}
|
||||
|
||||
public delegate void OnIMReceivedCallback(bot.Chat.structInstantMessage message);
|
||||
|
||||
public delegate void OnChatReceivedCallback(bot.Chat.structGeneralChat chat);
|
||||
|
||||
public static event OnIMReceivedCallback OnIMReceived;
|
||||
public static event OnChatReceivedCallback OnChatReceived;
|
||||
|
||||
private static void BotForm_OnInputSend(SecondLifeBot client, InstantMessage im, Simulator simulator, DateTime timestamp)
|
||||
{
|
||||
structInstantMessage preBuffer = new structInstantMessage();
|
||||
|
||||
preBuffer.client = client;
|
||||
preBuffer.message = im;
|
||||
preBuffer.simulator = simulator;
|
||||
preBuffer.timestamp = timestamp;
|
||||
preBuffer.isReceived = false;
|
||||
|
||||
receivedIM(preBuffer);
|
||||
}
|
||||
|
||||
public static void Initialize(frmChat mainForm)
|
||||
{
|
||||
mainForm.OnInputSend += new frmChat.InputSendCallback(bot.Chat.BotForm_OnInputSend);
|
||||
}
|
||||
|
||||
public static void receivedIM(structInstantMessage preBuffer)
|
||||
{
|
||||
if (OnIMReceived != null)
|
||||
OnIMReceived(preBuffer);
|
||||
}
|
||||
|
||||
public static void receivedChat(structGeneralChat preBuffer)
|
||||
{
|
||||
if (OnChatReceived != null)
|
||||
OnChatReceived(preBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
103
SLBot/bot/ClientTags.cs
Normal file
103
SLBot/bot/ClientTags.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ClientTags.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot
|
||||
{
|
||||
public struct ClientTag
|
||||
{
|
||||
public UUID _ClientID;
|
||||
public string _ClientName;
|
||||
|
||||
public ClientTag(UUID ClientID, string ClientName)
|
||||
{
|
||||
_ClientID = ClientID;
|
||||
_ClientName = ClientName;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClientTags
|
||||
{
|
||||
public readonly static ClientTag MOYMIX = new ClientTag(UUID.Parse("0bcd5f5d-a4ce-9ea4-f9e8-15132653b3d8"), "MoyMix");
|
||||
public readonly static ClientTag CRYOLIFE = new ClientTag(UUID.Parse("0f6723d2-5b23-6b58-08ab-308112b33786"), "CryoLife");
|
||||
public readonly static ClientTag VERTICALLIFE = new ClientTag(UUID.Parse("11ad2452-ce54-8d65-7c23-05589b59f516"), "VerticalLife");
|
||||
public readonly static ClientTag GEMINI = new ClientTag(UUID.Parse("1c29480c-c608-df87-28bb-964fb64c5366"), "Gemini");
|
||||
public readonly static ClientTag MEERKAT = new ClientTag(UUID.Parse("2a9a406c-f448-68f2-4e38-878f8c46c190"), "Meerkat");
|
||||
public readonly static ClientTag PHOXSL = new ClientTag(UUID.Parse("2c9c1e0b-e5d1-263e-16b1-7fc6d169f3d6"), "PhoxSL");
|
||||
public readonly static ClientTag VERTICALLIFE2 = new ClientTag(UUID.Parse("3ab7e2fa-9572-ef36-1a30-d855dbea4f92"), "VerticalLife");
|
||||
public readonly static ClientTag SAPPHIRE = new ClientTag(UUID.Parse("4e8dcf80-336b-b1d8-ef3e-08dacf015a0f"), "Sapphire");
|
||||
public readonly static ClientTag VERTICALLIFE3 = new ClientTag(UUID.Parse("58a8b7ec-1455-7162-5d96-d3c3ead2ed71"), "VerticalLife");
|
||||
public readonly static ClientTag LGG = new ClientTag(UUID.Parse("5aa5c70d-d787-571b-0495-4fc1bdef1500"), "LGG proxy");
|
||||
public readonly static ClientTag PSL = new ClientTag(UUID.Parse("77662f23-c77a-9b4d-5558-26b757b2144c"), "PSL");
|
||||
public readonly static ClientTag KUNGFU = new ClientTag(UUID.Parse("7c4d47a3-0c51-04d1-fa47-e4f3ac12f59b"), "Kung Fu");
|
||||
public readonly static ClientTag DAYOH = new ClientTag(UUID.Parse("8183e823-c443-2142-6eb6-2ab763d4f81c"), "Day Oh proxy");
|
||||
public readonly static ClientTag INFINITY = new ClientTag(UUID.Parse("81b3e921-ee31-aa57-ff9b-ec1f28e41da1"), "Infinity");
|
||||
public readonly static ClientTag VERTICALLIFE4 = new ClientTag(UUID.Parse("841ef25b-3b90-caf9-ea3d-5649e755db65"), "VerticalLife");
|
||||
public readonly static ClientTag FAG = new ClientTag(UUID.Parse("872c0005-3095-0967-866d-11cd71115c22"), "<-- Fag");
|
||||
public readonly static ClientTag BETALIFE = new ClientTag(UUID.Parse("9422e9d7-7b11-83e4-6262-4a8db4716a3b"), "BetaLife");
|
||||
public readonly static ClientTag TYK3N = new ClientTag(UUID.Parse("adcbe893-7643-fd12-f61c-0b39717e2e32"), "tyk3n");
|
||||
public readonly static ClientTag MERKAT2 = new ClientTag(UUID.Parse("b6820989-bf42-ff59-ddde-fd3fd3a74fe4"), "Meerkat");
|
||||
public readonly static ClientTag VLIFE = new ClientTag(UUID.Parse("c252d89d-6f7c-7d90-f430-d140d2e3fbbe"), "VLife");
|
||||
public readonly static ClientTag KUNGFU2 = new ClientTag(UUID.Parse("c5b570ca-bb7e-3c81-afd1-f62646b20014"), "Kung Fu");
|
||||
public readonly static ClientTag RUBY = new ClientTag(UUID.Parse("ccb509cf-cc69-e569-38f1-5086c687afd1"), "Ruby");
|
||||
public readonly static ClientTag EMERALD = new ClientTag(UUID.Parse("ccda2b3b-e72c-a112-e126-fee238b67218"), "Emerald");
|
||||
public readonly static ClientTag RIVLIFE = new ClientTag(UUID.Parse("d3eb4a5f-aec5-4bcb-b007-cce9efe89d37"), "rivlife");
|
||||
public readonly static ClientTag CRYOLIFE2 = new ClientTag(UUID.Parse("e52d21f7-3c8b-819f-a3db-65c432295dac"), "CryoLife");
|
||||
public readonly static ClientTag VERTICALLIFE5 = new ClientTag(UUID.Parse("e734563e-1c31-2a35-3ed5-8552c807439f"), "VerticalLife");
|
||||
public readonly static ClientTag PSL2 = new ClientTag(UUID.Parse("f3fd74a6-fee7-4b2f-93ae-ddcb5991da04"), "PSL");
|
||||
public readonly static ClientTag NEILLIFE = new ClientTag(UUID.Parse("f5a48821-9a98-d09e-8d6a-50cc08ba9a47"), "NeilLife");
|
||||
public readonly static ClientTag CORGI = new ClientTag(UUID.Parse("ffce04ff-5303-4909-a044-d37af7ab0b0e"), "Corgi");
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary containing all known client tags
|
||||
/// </summary>
|
||||
/// <returns>A dictionary containing the known client tags,
|
||||
/// where the key is the tag ID, and the value is a string
|
||||
/// containing the client name</returns>
|
||||
public static Dictionary<UUID, string> ToDictionary()
|
||||
{
|
||||
Dictionary<UUID, string> dict = new Dictionary<UUID, string>();
|
||||
Type type = typeof(ClientTags);
|
||||
foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
ClientTag _Tag = (ClientTag)field.GetValue(type);
|
||||
|
||||
dict.Add(_Tag._ClientID, _Tag._ClientName);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
140
SLBot/bot/Commands/Agent/AnimateCommand.cs
Normal file
140
SLBot/bot/Commands/Agent/AnimateCommand.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AnimateCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Core.Commands
|
||||
{
|
||||
public class AnimateCommand : bot.Commands.Command
|
||||
{
|
||||
private Dictionary<UUID, string> m_BuiltInAnimations = new Dictionary<UUID, string>(Animations.ToDictionary());
|
||||
|
||||
public AnimateCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Client = SecondLifeBot;
|
||||
Name = "animate";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.Animate.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Animate.Usage");
|
||||
}
|
||||
|
||||
private UUID animID;
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool from_SL)
|
||||
{
|
||||
string arg;
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
arg = args[0].Trim();
|
||||
|
||||
if (UUID.TryParse(args[0], out animID))
|
||||
{
|
||||
Client.Self.AnimationStart(animID, true);
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.Starting"), animID);
|
||||
}
|
||||
else if (arg.ToLower().Equals("list"))
|
||||
{
|
||||
foreach (string key in m_BuiltInAnimations.Values)
|
||||
{
|
||||
result.AppendLine(key);
|
||||
}
|
||||
}
|
||||
else if (arg.ToLower().Equals("show"))
|
||||
{
|
||||
Client.Self.SignaledAnimations.ForEach(delegate(KeyValuePair<UUID, int> kvp)
|
||||
{
|
||||
if (m_BuiltInAnimations.ContainsKey(kvp.Key))
|
||||
{
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.SystemAnimation"), m_BuiltInAnimations[kvp.Key], kvp.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.AssetAnimation"), kvp.Key, kvp.Value);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (args[0].ToLower() == "stop")
|
||||
{
|
||||
Client.Self.SignaledAnimations.ForEach(delegate(KeyValuePair<UUID, int> kvp)
|
||||
{
|
||||
Client.Self.AnimationStop(kvp.Key, true);
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.Stopping"), kvp.Key);
|
||||
});
|
||||
}
|
||||
else if (m_BuiltInAnimations.ContainsValue(args[0].Trim().ToUpper()))
|
||||
{
|
||||
foreach (var kvp in m_BuiltInAnimations)
|
||||
{
|
||||
if (kvp.Value.Equals(arg.ToUpper()))
|
||||
{
|
||||
Client.Self.AnimationStart(kvp.Key, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (args[0].ToLower() == "stop" && UUID.TryParse(args[1], out animID))
|
||||
{
|
||||
Client.Self.AnimationStop(animID, true);
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.Stopping"), animID);
|
||||
}
|
||||
else if (m_BuiltInAnimations.ContainsValue(args[0].Trim().ToUpper()))
|
||||
{
|
||||
foreach (var kvp in m_BuiltInAnimations)
|
||||
{
|
||||
if (kvp.Value.Equals(args[1].ToUpper()))
|
||||
{
|
||||
Client.Self.AnimationStop(kvp.Key, true);
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Animate.Stopping"), kvp.Key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animate.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animate.Usage");
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
SLBot/bot/Commands/Agent/AppearanceCommand.cs
Normal file
55
SLBot/bot/Commands/Agent/AppearanceCommand.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AppearanceCommand.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.Threading;
|
||||
|
||||
public class AppearanceCommand : Command
|
||||
{
|
||||
public AppearanceCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "appearance";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Appearance.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.Appearance.RequestSetAppearance((args.Length > 0 && args[0].Equals("rebake")));
|
||||
return bot.Localization.clResourceManager.getText("Commands.Appearance.Thread");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
89
SLBot/bot/Commands/Agent/AttachCommand.cs
Normal file
89
SLBot/bot/Commands/Agent/AttachCommand.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AttachCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public class AttachCommand : Command
|
||||
{
|
||||
private InventoryManager Manager;
|
||||
private OpenMetaverse.Inventory Inventory;
|
||||
|
||||
public AttachCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "attach";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Attach.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Attach.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Attach.Usage");
|
||||
}
|
||||
UUID dest;
|
||||
if (!UUID.TryParse(args[0], out dest))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Attach.ExpectedID");
|
||||
}
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Manager.Store;
|
||||
|
||||
string inventoryName = args[0];
|
||||
// WARNING: Uses local copy of inventory contents, need to download them first.
|
||||
List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
|
||||
foreach (InventoryBase b in contents)
|
||||
{
|
||||
if (inventoryName == b.Name || inventoryName.ToLower() == b.UUID.ToString())
|
||||
{
|
||||
if (b is InventoryItem)
|
||||
{
|
||||
InventoryItem item = b as InventoryItem;
|
||||
|
||||
Client.Appearance.Attach(item, AttachmentPoint.Default);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Attach.Attaching"), item.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Attach.NotFolder"), b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Attach.NotFound"), inventoryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
89
SLBot/bot/Commands/Agent/AttachmentsCommand.cs
Normal file
89
SLBot/bot/Commands/Agent/AttachmentsCommand.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AttachmentsCommand.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;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AttachmentsCommand : Command
|
||||
{
|
||||
public AttachmentsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Client = SecondLifeBot;
|
||||
base.Name = "attachments";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Attachments.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
List<Primitive> attachments = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ParentID == Client.Self.LocalID;
|
||||
}
|
||||
);
|
||||
|
||||
for (int i = 0; i < attachments.Count; i++)
|
||||
{
|
||||
Primitive prim = attachments[i];
|
||||
NBAttachmentPoint point = StateToAttachmentPoint(prim.PrimData.State);
|
||||
|
||||
// TODO: Fetch properties for the objects with missing property sets so we can show names
|
||||
//Logger.Log(String.Format("[Attachment @ {0}] LocalID: {1} UUID: {2} Offset: {3}",
|
||||
// point, prim.LocalID, prim.ID, prim.Position), Helpers.LogLevel.Info, Client);
|
||||
|
||||
builder.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Attachments.Attachment"),
|
||||
point, prim.LocalID, prim.ID, prim.Position);
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Attachments.Found"), attachments.Count));
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static NBAttachmentPoint StateToAttachmentPoint(uint state)
|
||||
{
|
||||
const uint ATTACHMENT_MASK = 0xF0;
|
||||
uint fixedState = (((byte)state & ATTACHMENT_MASK) >> 4) | (((byte)state & ~ATTACHMENT_MASK) << 4);
|
||||
return (NBAttachmentPoint)fixedState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
SLBot/bot/Commands/Agent/AwayCommand.cs
Normal file
80
SLBot/bot/Commands/Agent/AwayCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AwayCommand.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 OpenMetaverse;
|
||||
|
||||
public class AwayCommand : Command
|
||||
{
|
||||
private static readonly UUID AWAYID = new UUID("FD037134-85D4-F241-72C6-4F42164FEDEE");
|
||||
|
||||
public AwayCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "away";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Away.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Away.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
if (Client.isAway)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.Afk");
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.NotAfk");
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
Client.isAway = true;
|
||||
Client.Self.AnimationStart(AWAYID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.WillAfk");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
Client.isAway = false;
|
||||
Client.Self.AnimationStop(AWAYID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.WontAfk");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Away.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
SLBot/bot/Commands/Agent/BalanceCommand.cs
Normal file
67
SLBot/bot/Commands/Agent/BalanceCommand.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BalanceCommand.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 BalanceCommand : Command
|
||||
{
|
||||
public BalanceCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "balance";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Balance.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
System.Threading.AutoResetEvent waitBalance = new System.Threading.AutoResetEvent(false);
|
||||
EventHandler<BalanceEventArgs> del = delegate(object sender, BalanceEventArgs e)
|
||||
{
|
||||
waitBalance.Set();
|
||||
};
|
||||
Client.Self.MoneyBalance += del;
|
||||
Client.Self.RequestBalance();
|
||||
String result = bot.Localization.clResourceManager.getText("Commands.Balance.Timeout");
|
||||
if (waitBalance.WaitOne(10000, false))
|
||||
{
|
||||
result = String.Format(bot.Localization.clResourceManager.getText("Commands.Balance.Balance"), Client.ToString(),
|
||||
Client.Self.Balance);
|
||||
}
|
||||
Client.Self.MoneyBalance -= del;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
140
SLBot/bot/Commands/Agent/BeamCommand.cs
Normal file
140
SLBot/bot/Commands/Agent/BeamCommand.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BeamCommand.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 OpenMetaverse;
|
||||
using System.Timers;
|
||||
|
||||
public class BeamCommand : Command
|
||||
{
|
||||
private Timer b = new Timer();
|
||||
private bool doBeam;
|
||||
|
||||
public BeamCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "beam";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Beam.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Beam.Usage");
|
||||
|
||||
b.Elapsed += new ElapsedEventHandler(b_Elapsed);
|
||||
}
|
||||
|
||||
void b_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
doBeam = false;
|
||||
b.Enabled = false;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID targetID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
bool isGroupKey = false;
|
||||
Avatar foundAv = null;
|
||||
Primitive foundPrim;
|
||||
Vector3d targetPosition;
|
||||
doBeam = true;
|
||||
b.Interval = 5000;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Beam.Usage");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
if (!Client.FindOneAvatar(avatarName, out targetID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Beam.AvNotFound"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Beam.Usage");
|
||||
}
|
||||
|
||||
if (targetID != UUID.Zero)
|
||||
{
|
||||
Client.key2Name(targetID, out avatarName, out isGroupKey);
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Beam.CannotGroup");
|
||||
|
||||
if (avatarName != "")
|
||||
{
|
||||
foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return (avatar.Name == avatarName);
|
||||
}
|
||||
);
|
||||
|
||||
if (foundAv == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Beam.AvNotInSim"), avatarName);
|
||||
|
||||
targetPosition = new Vector3d(foundAv.Position);
|
||||
}
|
||||
else
|
||||
{
|
||||
foundPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == targetID;
|
||||
}
|
||||
);
|
||||
|
||||
if (foundPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Beam.ObjNotInSim"), targetID);
|
||||
|
||||
targetPosition = new Vector3d(foundPrim.Position);
|
||||
}
|
||||
|
||||
b.Enabled = true;
|
||||
while (doBeam)
|
||||
{
|
||||
Client.Self.BeamEffect(Client.Self.AgentID, targetID, targetPosition, new Color4(0, 0, 0, 255), 5000.0f,
|
||||
new UUID("aec29773-c421-364e-4f29-e3f633222188"));
|
||||
}
|
||||
|
||||
if (avatarName == "")
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Beam.BeamObj"), targetID);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Beam.BeamAv"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Beam.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
SLBot/bot/Commands/Agent/BusyCommand.cs
Normal file
80
SLBot/bot/Commands/Agent/BusyCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BusyCommand.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 OpenMetaverse;
|
||||
|
||||
public class BusyCommand : Command
|
||||
{
|
||||
private static readonly UUID BUSYID = new UUID("EFCF670C-2D18-8128-973A-034EBC806B67");
|
||||
|
||||
public BusyCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "busy";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Busy.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Busy.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
if (Client.isBusy)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.Busy");
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.NotBusy");
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
Client.isBusy = true;
|
||||
Client.Self.AnimationStart(BUSYID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.WillBusy");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
Client.isBusy = false;
|
||||
Client.Self.AnimationStop(BUSYID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.WontBusy");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Busy.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
SLBot/bot/Commands/Agent/GestureCommand.cs
Normal file
76
SLBot/bot/Commands/Agent/GestureCommand.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GestureCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Core.Commands
|
||||
{
|
||||
public class GestureCommand : bot.Commands.Command
|
||||
{
|
||||
private Dictionary<UUID, string> m_BuiltInAnimations = new Dictionary<UUID, string>(Animations.ToDictionary());
|
||||
|
||||
public GestureCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Client = SecondLifeBot;
|
||||
Name = "gesture";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.Gesture.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Gesture.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool from_SL)
|
||||
{
|
||||
UUID gestureID = UUID.Zero;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out gestureID))
|
||||
{
|
||||
if (gestureID == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Gesture.Usage");
|
||||
|
||||
Client.Self.PlayGesture(gestureID);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Gesture.Playing"), gestureID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Gesture.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Gesture.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
54
SLBot/bot/Commands/Agent/GroundSitCommand.cs
Normal file
54
SLBot/bot/Commands/Agent/GroundSitCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroundSitCommand.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 OpenMetaverse;
|
||||
|
||||
public class GroundSitCommand : Command
|
||||
{
|
||||
public GroundSitCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "gsit";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GroundSit.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.Self.SitOnGround();
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroundSit.Sitting");
|
||||
}
|
||||
}
|
||||
}
|
||||
53
SLBot/bot/Commands/Agent/HealthCommand.cs
Normal file
53
SLBot/bot/Commands/Agent/HealthCommand.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : HealthComand.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 HealthComand : Command
|
||||
{
|
||||
public HealthComand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "health";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Health.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Health.Health"), Client.Self.Health);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
SLBot/bot/Commands/Agent/LocationCommand.cs
Normal file
54
SLBot/bot/Commands/Agent/LocationCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : LocationCommand.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 LocationCommand : Command
|
||||
{
|
||||
public LocationCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "location";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Location.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Location.Location"), Client.Network.CurrentSim.ToString(),
|
||||
Client.Self.SimPosition.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
122
SLBot/bot/Commands/Agent/LookAtCommand.cs
Normal file
122
SLBot/bot/Commands/Agent/LookAtCommand.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : LookAtCommand.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 OpenMetaverse;
|
||||
using System.Timers;
|
||||
|
||||
public class LookAtCommand : Command
|
||||
{
|
||||
public LookAtCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "lookat";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.LookAt.Description") + " " + bot.Localization.clResourceManager.getText("Commands.LookAt.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID targetID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
bool isGroupKey = false;
|
||||
Avatar foundAv = null;
|
||||
Primitive foundPrim;
|
||||
Vector3d targetPosition;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.LookAt.Usage");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
if (!Client.FindOneAvatar(avatarName, out targetID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LookAt.AvNotFound"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.LookAt.Usage");
|
||||
}
|
||||
|
||||
if (targetID != UUID.Zero)
|
||||
{
|
||||
Client.key2Name(targetID, out avatarName, out isGroupKey);
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.LookAt.CannotGroup");
|
||||
|
||||
if (avatarName != "")
|
||||
{
|
||||
foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return (avatar.Name == avatarName);
|
||||
}
|
||||
);
|
||||
|
||||
if (foundAv == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LookAt.AvNotInSim"), avatarName);
|
||||
|
||||
targetPosition = new Vector3d(foundAv.Position);
|
||||
}
|
||||
else
|
||||
{
|
||||
foundPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == targetID;
|
||||
}
|
||||
);
|
||||
|
||||
if (foundPrim == null)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LookAt.ObjNotInSim"), targetID);
|
||||
|
||||
targetPosition = new Vector3d(foundPrim.Position);
|
||||
}
|
||||
|
||||
Client.Self.LookAtEffect(Client.Self.AgentID, targetID, targetPosition, LookAtType.Focus, UUID.Zero);
|
||||
|
||||
if (avatarName == "")
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LookAt.LookObj"), targetID);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LookAt.LookAv"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.LookAt.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
SLBot/bot/Commands/Agent/NaduCommand.cs
Normal file
80
SLBot/bot/Commands/Agent/NaduCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : NaduCommand.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 OpenMetaverse;
|
||||
|
||||
public class NaduCommand : Command
|
||||
{
|
||||
private static readonly UUID NADUID = new UUID("6C83A33E-90E4-A350-91FF-E10209BDEC97");
|
||||
|
||||
public NaduCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "nadu";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Nadu.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Nadu.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
if (Client.isNadu)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.Nadu");
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.NotNadu");
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
Client.isNadu = true;
|
||||
Client.Self.AnimationStart(NADUID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.WillNadu");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
Client.isNadu = false;
|
||||
Client.Self.AnimationStop(NADUID, true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.WontNadu");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Nadu.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
SLBot/bot/Commands/Agent/PayCommand.cs
Normal file
86
SLBot/bot/Commands/Agent/PayCommand.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : PayCommand.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 PayCommand : Command
|
||||
{
|
||||
public PayCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "pay";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Pay.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Pay.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int amount;
|
||||
UUID avatarID;
|
||||
string avatarName;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
avatarID = Client.MasterKey;
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (!UUID.TryParse(args[1], out avatarID))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Pay.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Pay.Usage");
|
||||
}
|
||||
|
||||
if (!Int32.TryParse(args[0], out amount))
|
||||
if (args[0].ToLower().Equals("all"))
|
||||
amount = Client.Self.Balance;
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.Pay.Usage");
|
||||
|
||||
if (!Client.key2Name(avatarID, out avatarName))
|
||||
avatarName = avatarID.ToString();
|
||||
|
||||
if (amount > Client.Self.Balance)
|
||||
amount = Client.Self.Balance;
|
||||
|
||||
Client.Self.GiveAvatarMoney(avatarID, amount, String.Format(bot.Localization.clResourceManager.getText("Commands.Pay.Message"), amount));
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Pay.Gave"), amount, avatarName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
65
SLBot/bot/Commands/Agent/PickCommand.cs
Normal file
65
SLBot/bot/Commands/Agent/PickCommand.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : PickCommand.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 OpenMetaverse;
|
||||
|
||||
public class PickCommand : Command
|
||||
{
|
||||
public PickCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "pick";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Pick.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Pick.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
string description = "";
|
||||
|
||||
if (args.Length == 0)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Pick.Usage");
|
||||
|
||||
foreach (string arg in args)
|
||||
{
|
||||
description += arg;
|
||||
description += " ";
|
||||
}
|
||||
|
||||
Client.Self.PickInfoUpdate(UUID.Random(), false, UUID.Zero, bot.Localization.clResourceManager.getText("Commands.Pick.PickName"), Client.Self.GlobalPosition, UUID.Zero, description);
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Pick.Picking");
|
||||
}
|
||||
}
|
||||
}
|
||||
76
SLBot/bot/Commands/Agent/PlaySoundCommand.cs
Normal file
76
SLBot/bot/Commands/Agent/PlaySoundCommand.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : PlaySoundCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Core.Commands
|
||||
{
|
||||
public class PlaySoundCommand : bot.Commands.Command
|
||||
{
|
||||
private Dictionary<UUID, string> m_BuiltInAnimations = new Dictionary<UUID, string>(Animations.ToDictionary());
|
||||
|
||||
public PlaySoundCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Client = SecondLifeBot;
|
||||
Name = "playsound";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.PlaySound.Description") + " " + bot.Localization.clResourceManager.getText("Commands.PlaySound.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool from_SL)
|
||||
{
|
||||
UUID soundID = UUID.Zero;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (UUID.TryParse(args[0], out soundID))
|
||||
{
|
||||
if (soundID == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.PlaySound.Usage");
|
||||
|
||||
Client.Sound.PlaySound(soundID);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.PlaySound.Playing"), soundID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.PlaySound.Usage");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.PlaySound.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
54
SLBot/bot/Commands/Agent/SetHomeCommand.cs
Normal file
54
SLBot/bot/Commands/Agent/SetHomeCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SetHomeCommand.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 SetHomeCommand : Command
|
||||
{
|
||||
public SetHomeCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "sethome";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.SetHome.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.Self.SetHome();
|
||||
return bot.Localization.clResourceManager.getText("Commands.SetHome.Set");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
SLBot/bot/Commands/Agent/WearCommand.cs
Normal file
90
SLBot/bot/Commands/Agent/WearCommand.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : WearCommand.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.Collections.Generic;
|
||||
|
||||
public class WearCommand : Command
|
||||
{
|
||||
public WearCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Client = SecondLifeBot;
|
||||
base.Name = "wear";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Wear.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Wear.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Wear.Usage");
|
||||
|
||||
string target = String.Empty;
|
||||
bool bake = true;
|
||||
|
||||
for (int ct = 0; ct < args.Length; ct++)
|
||||
{
|
||||
target += args[ct] + " ";
|
||||
}
|
||||
|
||||
target = target.TrimEnd();
|
||||
|
||||
UUID folder = Client.Inventory.FindObjectByPath(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID, target, 20 * 1000);
|
||||
|
||||
if (folder == UUID.Zero)
|
||||
{
|
||||
return "Outfit path " + target + " not found";
|
||||
}
|
||||
|
||||
List<InventoryBase> contents = Client.Inventory.FolderContents(folder, Client.Self.AgentID, true, true, InventorySortOrder.ByName, 20 * 1000);
|
||||
List<InventoryItem> items = new List<InventoryItem>();
|
||||
|
||||
if (contents == null)
|
||||
{
|
||||
return "Failed to get contents of " + target;
|
||||
}
|
||||
|
||||
foreach (InventoryBase item in contents)
|
||||
{
|
||||
if (item is InventoryItem)
|
||||
items.Add((InventoryItem)item);
|
||||
}
|
||||
|
||||
Client.Appearance.ReplaceOutfit(items);
|
||||
|
||||
return "Starting to change outfit to " + target;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
SLBot/bot/Commands/Avatars/AttachmentsUUID.cs
Normal file
101
SLBot/bot/Commands/Avatars/AttachmentsUUID.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AttachmentsUUIDCommand.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 OpenMetaverse.Utilities;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AttachmentsUUIDCommand : Command
|
||||
{
|
||||
public AttachmentsUUIDCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Client = SecondLifeBot;
|
||||
base.Name = "attachmentsuuid";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.AttachmentsUUID.Description") + " " + bot.Localization.clResourceManager.getText("Commands.AttachmentsUUID.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.AttachmentsUUID.Usage");
|
||||
}
|
||||
|
||||
List<Avatar> avatars = Client.Network.Simulators[0].ObjectsAvatars.FindAll(
|
||||
delegate(Avatar av)
|
||||
{
|
||||
return av.ID == (UUID)args[0];
|
||||
}
|
||||
);
|
||||
|
||||
List<Primitive> attachments = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ParentID == avatars[0].LocalID;
|
||||
}
|
||||
);
|
||||
|
||||
for (int i = 0; i < attachments.Count; i++)
|
||||
{
|
||||
Primitive prim = attachments[i];
|
||||
AttachmentPoint point = StateToAttachmentPoint(prim.PrimData.State);
|
||||
|
||||
// TODO: Fetch properties for the objects with missing property sets so we can show names
|
||||
//Logger.Log(String.Format("[Attachment @ {0}] LocalID: {1} UUID: {2} Offset: {3}",
|
||||
// point, prim.LocalID, prim.ID, prim.Position), Helpers.LogLevel.Info, Client);
|
||||
|
||||
builder.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Attachments.Attachment"),
|
||||
point, prim.LocalID, prim.ID, prim.Position);
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Attachments.Found"), attachments.Count));
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public static AttachmentPoint StateToAttachmentPoint(uint state)
|
||||
{
|
||||
const uint ATTACHMENT_MASK = 0xF0;
|
||||
uint fixedState = (((byte)state & ATTACHMENT_MASK) >> 4) | (((byte)state & ~ATTACHMENT_MASK) << 4);
|
||||
return (AttachmentPoint)fixedState;
|
||||
}
|
||||
}
|
||||
}
|
||||
313
SLBot/bot/Commands/Avatars/AvatarInfoCommand.cs
Normal file
313
SLBot/bot/Commands/Avatars/AvatarInfoCommand.cs
Normal file
@@ -0,0 +1,313 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AvatarInfoCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
public class AvatarInfoCommand : Command
|
||||
{
|
||||
ManualResetEvent WaitforAvatar = new ManualResetEvent(false);
|
||||
Avatar.AvatarProperties foundAvProperties;
|
||||
Avatar.Interests foundAvInterests;
|
||||
List<AvatarGroup> foundAvGroups = new List<AvatarGroup>();
|
||||
UUID foundAvUUID;
|
||||
bool foundAvPropertiesCorrectlyGot = false;
|
||||
bool foundAvInterestsCorrectlyGot = false;
|
||||
bool foundAvGroupsCorrectlyGot = false;
|
||||
bool moreThanOneAvFound = false;
|
||||
|
||||
public AvatarInfoCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
Name = "avatarinfo";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Description") + " " + bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Usage");
|
||||
}
|
||||
|
||||
void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs e)
|
||||
{
|
||||
if (e.AvatarID == foundAvUUID)
|
||||
{
|
||||
foundAvPropertiesCorrectlyGot = true;
|
||||
foundAvProperties = e.Properties;
|
||||
}
|
||||
else
|
||||
{
|
||||
foundAvPropertiesCorrectlyGot = false;
|
||||
}
|
||||
|
||||
WaitforAvatar.Set();
|
||||
return;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
Client.Avatars.AvatarPropertiesReply += new EventHandler<AvatarPropertiesReplyEventArgs>(Avatars_AvatarPropertiesReply);
|
||||
|
||||
moreThanOneAvFound = false;
|
||||
|
||||
foundAvUUID = UUID.Zero;
|
||||
|
||||
Avatar foundAv = null;
|
||||
|
||||
foundAvProperties = new Avatar.AvatarProperties();
|
||||
foundAvInterests = new Avatar.Interests();
|
||||
foundAvGroups = new List<AvatarGroup>();
|
||||
WaitforAvatar = new ManualResetEvent(false);
|
||||
|
||||
if (args.Length != 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Usage");
|
||||
|
||||
string targetName = String.Format("{0} {1}", args[0], args[1]);
|
||||
|
||||
Client.FindOneAvatar(targetName, out foundAvUUID, out moreThanOneAvFound);
|
||||
|
||||
foundAv = Client.Network.CurrentSim.ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return (avatar.Name == targetName);
|
||||
}
|
||||
);
|
||||
|
||||
if (foundAvUUID != UUID.Zero)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
if (moreThanOneAvFound)
|
||||
{
|
||||
output.AppendFormat("More than one avatar found with that search terms.");
|
||||
output.AppendLine();
|
||||
output.AppendFormat("{0} ({1})", targetName, foundAvUUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.AppendFormat("{0} ({1})", targetName, foundAvUUID);
|
||||
}
|
||||
|
||||
output.AppendLine();
|
||||
|
||||
Client.Avatars.RequestAvatarProperties(foundAvUUID);
|
||||
|
||||
if (!WaitforAvatar.WaitOne(10000, false))
|
||||
{
|
||||
Client.Avatars.AvatarPropertiesReply -= Avatars_AvatarPropertiesReply;
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.NotProfile"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Avatars.AvatarPropertiesReply -= Avatars_AvatarPropertiesReply;
|
||||
if (foundAvPropertiesCorrectlyGot == true)
|
||||
{
|
||||
// CLAUNIA
|
||||
// For some reason it is getting offline
|
||||
/*
|
||||
switch (foundAvProperties.Online)
|
||||
{
|
||||
case true:
|
||||
output.AppendFormat("Avatar conectado");
|
||||
output.AppendLine();
|
||||
break;
|
||||
case false:
|
||||
output.AppendFormat("Avatar NO conectado");
|
||||
output.AppendLine();
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.SecondLife"));
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Born"), foundAvProperties.BornOn);
|
||||
output.AppendLine();
|
||||
//output.AppendFormat(" Flags: {0}", foundAvProperties.Flags.ToString()); output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.SecondPhoto"), foundAvProperties.ProfileImage.ToString());
|
||||
output.AppendLine();
|
||||
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Account"));
|
||||
if (foundAvProperties.Identified)
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Identified"));
|
||||
if (foundAvProperties.MaturePublish)
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Adult"));
|
||||
if (foundAvProperties.Transacted)
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Payment"));
|
||||
if (foundAvProperties.AllowPublish)
|
||||
output.Append(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Public"));
|
||||
output.AppendLine(".");
|
||||
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Partner"), foundAvProperties.Partner.ToString());
|
||||
output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Charter"), foundAvProperties.CharterMember);
|
||||
output.AppendLine();
|
||||
|
||||
WaitforAvatar.Reset();
|
||||
Client.Avatars.AvatarGroupsReply += new EventHandler<AvatarGroupsReplyEventArgs>(Avatars_OnAvatarGroups);
|
||||
Client.Avatars.RequestAvatarProperties(foundAvUUID);
|
||||
|
||||
if (!WaitforAvatar.WaitOne(2500, false))
|
||||
{
|
||||
Client.Avatars.AvatarGroupsReply -= Avatars_OnAvatarGroups;
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.NotGroups"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Avatars.AvatarGroupsReply -= Avatars_OnAvatarGroups;
|
||||
if (foundAvGroupsCorrectlyGot)
|
||||
{
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Groups"));
|
||||
foreach (AvatarGroup avGroup in foundAvGroups)
|
||||
{
|
||||
output.AppendFormat(" {0} ({1})", avGroup.GroupName, avGroup.GroupID);
|
||||
output.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.About"));
|
||||
output.AppendFormat(" {0}", foundAvProperties.AboutText);
|
||||
output.AppendLine();
|
||||
output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.WebProfile"), foundAvProperties.ProfileURL);
|
||||
output.AppendLine();
|
||||
output.AppendLine();
|
||||
|
||||
WaitforAvatar.Reset();
|
||||
Client.Avatars.AvatarInterestsReply += new EventHandler<AvatarInterestsReplyEventArgs>(Avatars_OnAvatarInterests);
|
||||
Client.Avatars.RequestAvatarProperties(foundAvUUID);
|
||||
|
||||
if (!WaitforAvatar.WaitOne(1000, false))
|
||||
{
|
||||
Client.Avatars.AvatarInterestsReply -= Avatars_OnAvatarInterests;
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.NotInterests"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Avatars.AvatarInterestsReply -= Avatars_OnAvatarInterests;
|
||||
if (foundAvInterestsCorrectlyGot)
|
||||
{
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Interests"));
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Wants"), foundAvInterests.WantToMask.ToString("X"), foundAvInterests.WantToText);
|
||||
output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Skills"), foundAvInterests.SkillsMask.ToString("X"), foundAvInterests.SkillsText);
|
||||
output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Languages"), foundAvInterests.LanguagesText);
|
||||
output.AppendLine();
|
||||
output.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.FirstLife"));
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.FirstPhoto"), foundAvProperties.FirstLifeImage.ToString());
|
||||
output.AppendLine();
|
||||
output.AppendFormat(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Information"), foundAvProperties.FirstLifeText);
|
||||
output.AppendLine();
|
||||
output.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Error"));
|
||||
}
|
||||
}
|
||||
|
||||
// CLAUNIA
|
||||
// There is no event nor method for requesting statistics.
|
||||
/*
|
||||
output.AppendLine("Estadísticas:");
|
||||
output.AppendFormat(" Apariencia: {0} votos positivos, {1} votos negativos", foundAv.ProfileStatistics.AppearancePositive, foundAv.ProfileStatistics.AppearanceNegative); output.AppendLine();
|
||||
output.AppendFormat(" Comportamiento: {0} votos positivos, {1} votos negativos", foundAv.ProfileStatistics.BehaviorPositive, foundAv.ProfileStatistics.BehaviorNegative); output.AppendLine();
|
||||
output.AppendFormat(" Construcción: {0} votos positivos, {1} votos negativos", foundAv.ProfileStatistics.BuildingPositive, foundAv.ProfileStatistics.BuildingNegative); output.AppendLine();
|
||||
output.AppendFormat(" Votos emitidos: {0} positivos, {1} negativos", foundAv.ProfileStatistics.GivenPositive, foundAv.ProfileStatistics.GivenNegative); output.AppendLine();
|
||||
|
||||
output.AppendLine();*/
|
||||
|
||||
if (foundAv != null)
|
||||
{
|
||||
if (foundAv.Textures != null)
|
||||
{
|
||||
output.AppendLine(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.Textures"));
|
||||
for (int i = 0; i < foundAv.Textures.FaceTextures.Length; i++)
|
||||
{
|
||||
if (foundAv.Textures.FaceTextures[i] != null)
|
||||
{
|
||||
Primitive.TextureEntryFace face = foundAv.Textures.FaceTextures[i];
|
||||
AvatarTextureIndex type = (AvatarTextureIndex)i;
|
||||
|
||||
output.AppendFormat(" {0}: {1}", type, face.TextureID);
|
||||
output.AppendLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.AvatarInfo.NotFound"), targetName);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_OnAvatarGroups(object sender, AvatarGroupsReplyEventArgs e)
|
||||
{
|
||||
if (e.AvatarID == foundAvUUID)
|
||||
{
|
||||
foundAvGroupsCorrectlyGot = true;
|
||||
foundAvGroups = e.Groups;
|
||||
}
|
||||
else
|
||||
{
|
||||
foundAvGroupsCorrectlyGot = false;
|
||||
}
|
||||
|
||||
WaitforAvatar.Set();
|
||||
return;
|
||||
}
|
||||
|
||||
void Avatars_OnAvatarInterests(object sender, AvatarInterestsReplyEventArgs e)
|
||||
{
|
||||
if (e.AvatarID == foundAvUUID)
|
||||
{
|
||||
foundAvInterestsCorrectlyGot = true;
|
||||
foundAvInterests = e.Interests;
|
||||
}
|
||||
else
|
||||
{
|
||||
foundAvInterestsCorrectlyGot = false;
|
||||
}
|
||||
|
||||
WaitforAvatar.Set();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
115
SLBot/bot/Commands/Avatars/CloneCommand.cs
Normal file
115
SLBot/bot/Commands/Avatars/CloneCommand.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CloneCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class CloneCommand : Command
|
||||
{
|
||||
uint SerialNum = 2;
|
||||
|
||||
public CloneCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "clone";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Clone.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Clone.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string targetName = String.Empty;
|
||||
List<DirectoryManager.AgentSearchData> matches;
|
||||
|
||||
for (int ct = 0; ct < args.Length; ct++)
|
||||
targetName = targetName + args[ct] + " ";
|
||||
targetName = targetName.TrimEnd();
|
||||
|
||||
if (targetName.Length == 0)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Clone.Usage");
|
||||
|
||||
if (Client.Directory.PeopleSearch(DirectoryManager.DirFindFlags.People, targetName, 0, 1000 * 10,
|
||||
out matches) && matches.Count > 0)
|
||||
{
|
||||
UUID target = matches[0].AgentID;
|
||||
targetName += String.Format(" ({0})", target);
|
||||
|
||||
if (Client.Appearances.ContainsKey(target))
|
||||
{
|
||||
#region AvatarAppearance to AgentSetAppearance
|
||||
|
||||
AvatarAppearancePacket appearance = Client.Appearances[target];
|
||||
|
||||
AgentSetAppearancePacket set = new AgentSetAppearancePacket();
|
||||
set.AgentData.AgentID = Client.Self.AgentID;
|
||||
set.AgentData.SessionID = Client.Self.SessionID;
|
||||
set.AgentData.SerialNum = SerialNum++;
|
||||
set.AgentData.Size = new Vector3(2f, 2f, 2f); // HACK
|
||||
|
||||
set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
|
||||
set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];
|
||||
|
||||
for (int i = 0; i < appearance.VisualParam.Length; i++)
|
||||
{
|
||||
set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
|
||||
set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
|
||||
}
|
||||
|
||||
set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;
|
||||
|
||||
#endregion AvatarAppearance to AgentSetAppearance
|
||||
|
||||
// Detach everything we are currently wearing
|
||||
Client.Appearance.AddAttachments(new List<InventoryItem>(), true);
|
||||
|
||||
// Send the new appearance packet
|
||||
Client.Network.SendPacket(set);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Clone.Done"), targetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Clone.Unknown"), targetName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Clone.NotFound"), targetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
186
SLBot/bot/Commands/Avatars/CloneProfileCommand.cs
Normal file
186
SLBot/bot/Commands/Avatars/CloneProfileCommand.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CloneProfileCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class CloneProfileCommand : Command
|
||||
{
|
||||
Avatar.AvatarProperties Properties;
|
||||
Avatar.Interests Interests;
|
||||
List<UUID> Groups = new List<UUID>();
|
||||
bool ReceivedProperties = false;
|
||||
bool ReceivedInterests = false;
|
||||
bool ReceivedGroups = false;
|
||||
ManualResetEvent ReceivedProfileEvent = new ManualResetEvent(false);
|
||||
|
||||
public CloneProfileCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
SecondLifeBot.Avatars.AvatarInterestsReply += new EventHandler<AvatarInterestsReplyEventArgs>(Avatars_AvatarInterestsReply);
|
||||
SecondLifeBot.Avatars.AvatarPropertiesReply += new EventHandler<AvatarPropertiesReplyEventArgs>(Avatars_AvatarPropertiesReply);
|
||||
SecondLifeBot.Avatars.AvatarGroupsReply += new EventHandler<AvatarGroupsReplyEventArgs>(Avatars_AvatarGroupsReply);
|
||||
SecondLifeBot.Groups.GroupJoinedReply += new EventHandler<GroupOperationEventArgs>(Groups_OnGroupJoined);
|
||||
SecondLifeBot.Avatars.AvatarPicksReply += new EventHandler<AvatarPicksReplyEventArgs>(Avatars_AvatarPicksReply);
|
||||
|
||||
base.Name = "cloneprofile";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CloneProfile.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CloneProfile.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CloneProfile.Usage");
|
||||
|
||||
UUID targetID;
|
||||
ReceivedProperties = false;
|
||||
ReceivedInterests = false;
|
||||
ReceivedGroups = false;
|
||||
|
||||
try
|
||||
{
|
||||
targetID = new UUID(args[0]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.CloneProfile.Usage");
|
||||
}
|
||||
|
||||
// Request all of the packets that make up an avatar profile
|
||||
Client.Avatars.RequestAvatarProperties(targetID);
|
||||
|
||||
// Wait for all the packets to arrive
|
||||
ReceivedProfileEvent.Reset();
|
||||
ReceivedProfileEvent.WaitOne(5000, false);
|
||||
|
||||
// Check if everything showed up
|
||||
if (!ReceivedInterests || !ReceivedProperties || !ReceivedGroups)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CloneProfile.Fail");
|
||||
|
||||
// Synchronize our profile
|
||||
Client.Self.UpdateInterests(Interests);
|
||||
Client.Self.UpdateProfile(Properties);
|
||||
|
||||
// TODO: Leave all the groups we're currently a member of? This could
|
||||
// break TestClient connectivity that might be relying on group authentication
|
||||
|
||||
// Attempt to join all the groups
|
||||
foreach (UUID groupID in Groups)
|
||||
{
|
||||
Client.Groups.RequestJoinGroup(groupID);
|
||||
}
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CloneProfile.Done"), targetID.ToString());
|
||||
}
|
||||
|
||||
void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs e)
|
||||
{
|
||||
lock (ReceivedProfileEvent)
|
||||
{
|
||||
Properties = e.Properties;
|
||||
ReceivedProperties = true;
|
||||
|
||||
if (ReceivedInterests && ReceivedProperties && ReceivedGroups)
|
||||
ReceivedProfileEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_AvatarInterestsReply(object sender, AvatarInterestsReplyEventArgs e)
|
||||
{
|
||||
lock (ReceivedProfileEvent)
|
||||
{
|
||||
Interests = e.Interests;
|
||||
ReceivedInterests = true;
|
||||
|
||||
if (ReceivedInterests && ReceivedProperties && ReceivedGroups)
|
||||
ReceivedProfileEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e)
|
||||
{
|
||||
lock (ReceivedProfileEvent)
|
||||
{
|
||||
foreach (AvatarGroup group in e.Groups)
|
||||
{
|
||||
Groups.Add(group.GroupID);
|
||||
}
|
||||
|
||||
ReceivedGroups = true;
|
||||
|
||||
if (ReceivedInterests && ReceivedProperties && ReceivedGroups)
|
||||
ReceivedProfileEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
void Groups_OnGroupJoined(object sender, GroupOperationEventArgs e)
|
||||
{
|
||||
if (e.Success)
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.CloneProfile.Joined"), e.GroupID.ToString());
|
||||
else
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.CloneProfile.FailJoin"), e.GroupID.ToString());
|
||||
|
||||
if (e.Success)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.CloneProfile.Active"), Client.ToString(),
|
||||
e.GroupID.ToString());
|
||||
Client.Groups.ActivateGroup(e.GroupID);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_PickInfoReply(object sender, PickInfoReplyEventArgs e)
|
||||
{
|
||||
Client.Self.PickInfoUpdate(e.PickID, e.Pick.TopPick, e.Pick.ParcelID, e.Pick.Name, e.Pick.PosGlobal, e.Pick.SnapshotID, e.Pick.Desc);
|
||||
}
|
||||
|
||||
void Avatars_AvatarPicksReply(object sender, AvatarPicksReplyEventArgs e)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, string> kvp in e.Picks)
|
||||
{
|
||||
if (e.AvatarID == Client.Self.AgentID)
|
||||
{
|
||||
Client.Self.PickDelete(kvp.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Avatars.RequestPickInfo(e.AvatarID, kvp.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
117
SLBot/bot/Commands/Avatars/DetectBotCommand.cs
Normal file
117
SLBot/bot/Commands/Avatars/DetectBotCommand.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DetectBotCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public class DetectBotCommand : Command
|
||||
{
|
||||
private Dictionary<UUID, bool> m_AgentList = new Dictionary<UUID, bool>();
|
||||
|
||||
public DetectBotCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "detectbots";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.DetectBot.Description");
|
||||
SecondLifeBot.Avatars.ViewerEffect += new EventHandler<ViewerEffectEventArgs>(Avatars_ViewerEffect);
|
||||
SecondLifeBot.Avatars.ViewerEffectLookAt += new EventHandler<ViewerEffectLookAtEventArgs>(Avatars_ViewerEffectLookAt);
|
||||
SecondLifeBot.Avatars.ViewerEffectPointAt += new EventHandler<ViewerEffectPointAtEventArgs>(Avatars_ViewerEffectPointAt);
|
||||
}
|
||||
|
||||
private void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e)
|
||||
{
|
||||
lock (m_AgentList)
|
||||
{
|
||||
if (m_AgentList.ContainsKey(e.SourceID))
|
||||
m_AgentList[e.SourceID] = true;
|
||||
else
|
||||
m_AgentList.Add(e.SourceID, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e)
|
||||
{
|
||||
lock (m_AgentList)
|
||||
{
|
||||
if (m_AgentList.ContainsKey(e.SourceID))
|
||||
m_AgentList[e.SourceID] = true;
|
||||
else
|
||||
m_AgentList.Add(e.SourceID, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e)
|
||||
{
|
||||
lock (m_AgentList)
|
||||
{
|
||||
if (m_AgentList.ContainsKey(e.SourceID))
|
||||
m_AgentList[e.SourceID] = true;
|
||||
else
|
||||
m_AgentList.Add(e.SourceID, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Client.Network.Simulators[i].ObjectsAvatars.ForEach(
|
||||
delegate(Avatar av)
|
||||
{
|
||||
lock (m_AgentList)
|
||||
{
|
||||
if (!m_AgentList.ContainsKey(av.ID))
|
||||
{
|
||||
result.AppendLine();
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.DetectBot.Bot"),
|
||||
av.Name, av.GroupName, av.Position, av.ID, av.LocalID);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
71
SLBot/bot/Commands/Avatars/DetectLindensCommand.cs
Normal file
71
SLBot/bot/Commands/Avatars/DetectLindensCommand.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DetectLindensCommand.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 libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using System;
|
||||
|
||||
public class DetectBotCommand : Command
|
||||
{
|
||||
public DetectBotCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "detectlindens";
|
||||
base.Description = "Runs in the background, reporting any potential bots";
|
||||
SecondLifeBot.Network.RegisterCallback(PacketType.AgentUpdate, new NetworkManager.PacketCallback(this.AgentUpdatePacketHandler));
|
||||
}
|
||||
|
||||
private void AvatarAppearanceHandler(Packet packet, Simulator simulator)
|
||||
{
|
||||
AvatarAppearancePacket packet2 = (AvatarAppearancePacket)packet;
|
||||
packet2.ObjectData[
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
return "This command is always running";
|
||||
}
|
||||
|
||||
private bool IsNullOrZero(LLObject.TextureEntryFace face)
|
||||
{
|
||||
if (face != null)
|
||||
{
|
||||
return (face.TextureID == UUID.Zero);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
95
SLBot/bot/Commands/Avatars/EndFriendshipCommand.cs
Normal file
95
SLBot/bot/Commands/Avatars/EndFriendshipCommand.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : EndFriendshipCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
public class EndFriendshipCommand : Command
|
||||
{
|
||||
public EndFriendshipCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "endfriendship";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.EndFriendship.Description") + " " + bot.Localization.clResourceManager.getText("Commands.EndFriendship.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID avatarID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
bool isGroupKey = false;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out avatarID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.EndFriendship.Usage");
|
||||
|
||||
if (!Client.key2Name(avatarID, out avatarName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.AvNotFound");
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.EndFriendship.CannotGroup");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
|
||||
if (!Client.FindOneAvatar(avatarName, out avatarID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.OfferFriendship.NameNotFound"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.EndFriendship.Usage");
|
||||
}
|
||||
|
||||
if (avatarID != UUID.Zero)
|
||||
{
|
||||
if (!Client.Friends.FriendList.ContainsKey(avatarID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.EndFriendship.NotFriend"), avatarName);
|
||||
|
||||
Client.Friends.TerminateFriendship(avatarID);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.EndFriendship.Terminated"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
94
SLBot/bot/Commands/Avatars/ExportOutfitCommand.cs
Normal file
94
SLBot/bot/Commands/Avatars/ExportOutfitCommand.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ExportOutfitCommand.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 OpenMetaverse.Packets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
public class ExportOutfitCommand : Command
|
||||
{
|
||||
public ExportOutfitCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "exportoutfit";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ExportOutfit.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ExportOutfit.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID id;
|
||||
string path;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
id = Client.Self.AgentID;
|
||||
path = args[0];
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out id))
|
||||
return bot.Localization.clResourceManager.getText("Commands.ExportOutfit.Usage");
|
||||
path = args[1];
|
||||
}
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.ExportOutfit.Usage");
|
||||
|
||||
lock (Client.Appearances)
|
||||
{
|
||||
if (Client.Appearances.ContainsKey(id))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(path, Packet.ToXmlString(Client.Appearances[id]));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.ToString();
|
||||
}
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ExportOutfit.Exported"), id.ToString(), args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ExportOutfit.NotFound"), id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
85
SLBot/bot/Commands/Avatars/FriendsCommand.cs
Normal file
85
SLBot/bot/Commands/Avatars/FriendsCommand.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FriendsCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
public class FriendsCommand : Command
|
||||
{
|
||||
public FriendsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "friends";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Friends.Description");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of current friends
|
||||
/// </summary>
|
||||
/// <param name="args">optional testClient command arguments</param>
|
||||
/// <param name="fromAgentID">The <seealso cref="OpenMetaverse.UUID"/>
|
||||
/// of the agent making the request</param>
|
||||
/// <returns></returns>
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
// initialize a StringBuilder object used to return the results
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Only iterate the Friends dictionary if we actually have friends!
|
||||
if (Client.Friends.FriendList.Count > 0)
|
||||
{
|
||||
// iterate over the InternalDictionary using a delegate to populate
|
||||
// our StringBuilder output string
|
||||
Client.Friends.FriendList.ForEach(delegate(FriendInfo friend)
|
||||
{
|
||||
// append the name of the friend to our output
|
||||
sb.AppendLine(friend.Name + "(UUID: " + friend.UUID.ToString() + ")");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have no friends :(
|
||||
sb.AppendLine(bot.Localization.clResourceManager.getText("Commands.Friends.NoFriends"));
|
||||
}
|
||||
|
||||
// return the result
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
130
SLBot/bot/Commands/Avatars/ImportOutfitCommand.cs
Normal file
130
SLBot/bot/Commands/Avatars/ImportOutfitCommand.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ImportOutfitCommand.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 OpenMetaverse.Packets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
public class ImportOutfitCommand : Command
|
||||
{
|
||||
private Vector3 currentPosition;
|
||||
private Primitive currentPrim;
|
||||
private List<uint> linkQueue;
|
||||
private AutoResetEvent primDone = new AutoResetEvent(false);
|
||||
private List<Primitive> primsCreated;
|
||||
private uint rootLocalID;
|
||||
private ImporterState state = ImporterState.Idle;
|
||||
private uint SerialNum = 2;
|
||||
|
||||
private enum ImporterState
|
||||
{
|
||||
RezzingParent,
|
||||
RezzingChildren,
|
||||
Linking,
|
||||
Idle
|
||||
}
|
||||
|
||||
private class Linkset
|
||||
{
|
||||
public List<Primitive> Children;
|
||||
public Primitive RootPrim;
|
||||
|
||||
public Linkset()
|
||||
{
|
||||
this.Children = new List<Primitive>();
|
||||
this.RootPrim = new Primitive();
|
||||
}
|
||||
|
||||
public Linkset(Primitive rootPrim)
|
||||
{
|
||||
this.Children = new List<Primitive>();
|
||||
this.RootPrim = rootPrim;
|
||||
}
|
||||
}
|
||||
|
||||
public ImportOutfitCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "importoutfit";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ImportOutfit.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ImportOutfit.Usage");
|
||||
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
/* if (args.Length != 1)
|
||||
{
|
||||
return "Uso: importoutfit apariencia.xml";
|
||||
}
|
||||
string path = args[0];
|
||||
string str2;
|
||||
try
|
||||
{
|
||||
str2 = File.ReadAllText(path);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
return exception.Message;
|
||||
}
|
||||
if (str2.Length == 0)
|
||||
return "El archivo exportado está dañado.";
|
||||
|
||||
AvatarAppearancePacket packet= (AvatarAppearancePacket)AvatarAppearancePacket.FromLLSD(LLSDParser.DeserializeXml(str2));
|
||||
AgentSetAppearancePacket packet2 = new AgentSetAppearancePacket();
|
||||
|
||||
packet2.AgentData.AgentID = base.Client.Self.AgentID;
|
||||
packet2.AgentData.SessionID = base.Client.Self.SessionID;
|
||||
packet2.AgentData.SerialNum = this.SerialNum++;
|
||||
packet2.AgentData.Size = new Vector3(2f, 2f, 2f);
|
||||
packet2.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
|
||||
packet2.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[packet.VisualParam.Length];
|
||||
for (int j = 0; j < packet.VisualParam.Length; j++)
|
||||
{
|
||||
packet2.VisualParam[j] = new AgentSetAppearancePacket.VisualParamBlock();
|
||||
packet2.VisualParam[j].ParamValue = packet.VisualParam[j].ParamValue;
|
||||
}
|
||||
packet2.ObjectData.TextureEntry = packet.ObjectData.TextureEntry;
|
||||
base.Client.Appearance.AddAttachments(new List<InventoryBase>(), true);
|
||||
base.Client.Network.SendPacket(packet2);
|
||||
return ("Importado" + args[0]);*/
|
||||
/* return bot.Localization.clResourceManager.getText("Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
76
SLBot/bot/Commands/Avatars/InformFriendCommand.cs
Normal file
76
SLBot/bot/Commands/Avatars/InformFriendCommand.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : InformFriendCommand.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 OpenMetaverse;
|
||||
|
||||
public class InformFriendCommand : Command
|
||||
{
|
||||
public InformFriendCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "informfriend";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.InformFriend.Description") + " " + bot.Localization.clResourceManager.getText("Commands.InformFriend.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
if (Client.InformFriends)
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.Inform");
|
||||
else
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.NotInform");
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
Client.InformFriends = true;
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.WillInform");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
Client.InformFriends = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.WontInform");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.InformFriend.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
85
SLBot/bot/Commands/Avatars/MapFriendCommand.cs
Normal file
85
SLBot/bot/Commands/Avatars/MapFriendCommand.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : MapFriendCommand.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;
|
||||
using System.Threading;
|
||||
|
||||
public class MapFriendCommand : Command
|
||||
{
|
||||
ManualResetEvent WaitforFriend = new ManualResetEvent(false);
|
||||
|
||||
public MapFriendCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "mapfriend";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.MapFriend.Description") + " " + bot.Localization.clResourceManager.getText("Commands.MapFriend.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.MapFriend.Usage");
|
||||
|
||||
UUID targetID;
|
||||
|
||||
if (!UUID.TryParse(args[0], out targetID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.MapFriend.Usage");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
EventHandler<FriendFoundReplyEventArgs> del = delegate(object sender, FriendFoundReplyEventArgs e)
|
||||
{
|
||||
if (!e.RegionHandle.Equals(0))
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.MapFriend.Found"), e.AgentID, e.RegionHandle, e.Location.X, e.Location.Y);
|
||||
else
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.MapFriend.Offline"), e.AgentID);
|
||||
|
||||
WaitforFriend.Set();
|
||||
};
|
||||
|
||||
Client.Friends.FriendFoundReply += del;
|
||||
WaitforFriend.Reset();
|
||||
Client.Friends.MapFriend(targetID);
|
||||
if (!WaitforFriend.WaitOne(10000, false))
|
||||
{
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.MapFriend.TimeOut"), targetID);
|
||||
}
|
||||
Client.Friends.FriendFoundReply -= del;
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
95
SLBot/bot/Commands/Avatars/OfferFriendshipCommand.cs
Normal file
95
SLBot/bot/Commands/Avatars/OfferFriendshipCommand.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : OfferFriendshipCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
public class OfferFriendshipCommand : Command
|
||||
{
|
||||
public OfferFriendshipCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "offerfriendship";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Description") + " " + bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID avatarID = UUID.Zero;
|
||||
string avatarName = "";
|
||||
bool isGroupKey = false;
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
if (!UUID.TryParse(args[0], out avatarID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Usage");
|
||||
|
||||
if (!Client.key2Name(avatarID, out avatarName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.AvNotFound");
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.CannotGroup");
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
avatarName = args[0] + " " + args[1];
|
||||
|
||||
if (!Client.FindOneAvatar(avatarName, out avatarID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.OfferFriendship.NameNotFound"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Usage");
|
||||
}
|
||||
|
||||
if (avatarID != UUID.Zero)
|
||||
{
|
||||
if (Client.Friends.FriendList.ContainsKey(avatarID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.OfferFriendship.AlreadyFriend"), avatarName);
|
||||
|
||||
Client.Friends.OfferFriendship(avatarID, bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Message"));
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Offered"), avatarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.OfferFriendship.Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
111
SLBot/bot/Commands/Avatars/WhoCommand.cs
Normal file
111
SLBot/bot/Commands/Avatars/WhoCommand.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : WhoCommand.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;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class WhoCommand : Command
|
||||
{
|
||||
public WhoCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "who";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Who.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
Dictionary<UUID, string> ClientNames = ClientTags.ToDictionary();
|
||||
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Client.Network.Simulators[i].ObjectsAvatars.ForEach(
|
||||
delegate(Avatar av)
|
||||
{
|
||||
Vector3 RealPosition;
|
||||
|
||||
if (av.ParentID != 0)
|
||||
{
|
||||
Primitive SitPrim;
|
||||
|
||||
SitPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.LocalID == av.ParentID;
|
||||
}
|
||||
);
|
||||
|
||||
if (SitPrim == null)
|
||||
RealPosition = new Vector3(0, 0, 0);
|
||||
else
|
||||
RealPosition = SitPrim.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
RealPosition = av.Position;
|
||||
}
|
||||
|
||||
string ViewerName;
|
||||
|
||||
if (av.Textures == null)
|
||||
ViewerName = bot.Localization.clResourceManager.getText("Viewer.Unknown");
|
||||
else
|
||||
{
|
||||
if (av.Textures.FaceTextures[(int)AvatarTextureIndex.HeadBodypaint] != null)
|
||||
{
|
||||
if (!ClientNames.TryGetValue(av.Textures.FaceTextures[(int)AvatarTextureIndex.HeadBodypaint].TextureID, out ViewerName))
|
||||
ViewerName = bot.Localization.clResourceManager.getText("Viewer.Unidentified");
|
||||
}
|
||||
else
|
||||
ViewerName = bot.Localization.clResourceManager.getText("Viewer.Unknown");
|
||||
}
|
||||
|
||||
result.AppendLine();
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Who.Info"),
|
||||
av.Name, ViewerName, av.GroupName, RealPosition, av.ID.ToString());
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
SLBot/bot/Commands/Command.cs
Normal file
60
SLBot/bot/Commands/Command.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : Command.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
|
||||
Copyright (C) 2007-2009 openmetaverse.org
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
|
||||
public abstract class Command
|
||||
{
|
||||
public bool Active;
|
||||
public SecondLifeBot Client;
|
||||
public string Description;
|
||||
public string Name;
|
||||
|
||||
protected Command()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract string Execute(string[] args, UUID fromAgentID, bool fromSL);
|
||||
|
||||
public virtual void Think()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
70
SLBot/bot/Commands/Communication/EchoMasterCommand.cs
Normal file
70
SLBot/bot/Commands/Communication/EchoMasterCommand.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : EchoMasterCommand.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 EchoMasterCommand : Command
|
||||
{
|
||||
public EchoMasterCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "echoMaster";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.EchoMaster.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (!Active)
|
||||
{
|
||||
Active = true;
|
||||
Client.Self.ChatFromSimulator += Self_ChatFromSimulator;
|
||||
return bot.Localization.clResourceManager.getText("Commands.EchoMaster.On");
|
||||
}
|
||||
else
|
||||
{
|
||||
Active = false;
|
||||
Client.Self.ChatFromSimulator -= Self_ChatFromSimulator;
|
||||
return bot.Localization.clResourceManager.getText("Commands.EchoMaster.Off");
|
||||
}
|
||||
}
|
||||
|
||||
void Self_ChatFromSimulator(object sender, ChatEventArgs e)
|
||||
{
|
||||
if (e.Message.Length > 0 && (Client.MasterKey == e.SourceID || (Client.MasterName == e.FromName /*&& !Client.AllowObjectMaster*/)))
|
||||
Client.Self.Chat(e.Message, 0, ChatType.Normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
121
SLBot/bot/Commands/Communication/ImCommand.cs
Normal file
121
SLBot/bot/Commands/Communication/ImCommand.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ImCommand.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.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class ImCommand : Command
|
||||
{
|
||||
string ToAvatarName = String.Empty;
|
||||
ManualResetEvent NameSearchEvent = new ManualResetEvent(false);
|
||||
Dictionary<string, UUID> Name2Key = new Dictionary<string, UUID>();
|
||||
|
||||
public ImCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
SecondLifeBot.Avatars.AvatarPickerReply += Avatars_AvatarPickerReply;
|
||||
base.Name = "im";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.IM.Description") + " " + bot.Localization.clResourceManager.getText("Commands.IM.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 3)
|
||||
return bot.Localization.clResourceManager.getText("Commands.IM.Usage");
|
||||
|
||||
ToAvatarName = args[0] + " " + args[1];
|
||||
|
||||
// Build the message
|
||||
string message = String.Empty;
|
||||
for (int ct = 2; ct < args.Length; ct++)
|
||||
message += args[ct] + " ";
|
||||
message = message.TrimEnd();
|
||||
if (message.Length > 1023)
|
||||
message = message.Remove(1023);
|
||||
|
||||
if (!Name2Key.ContainsKey(ToAvatarName.ToLower()))
|
||||
{
|
||||
// Send the Query
|
||||
Client.Avatars.RequestAvatarNameSearch(ToAvatarName, UUID.Random());
|
||||
|
||||
NameSearchEvent.WaitOne(6000, false);
|
||||
}
|
||||
|
||||
if (Name2Key.ContainsKey(ToAvatarName.ToLower()))
|
||||
{
|
||||
UUID id = Name2Key[ToAvatarName.ToLower()];
|
||||
|
||||
Client.Self.InstantMessage(id, message);
|
||||
|
||||
bot.Chat.structInstantMessage sim;
|
||||
InstantMessage im = new InstantMessage();
|
||||
|
||||
im.Message = message;
|
||||
im.FromAgentID = id;
|
||||
im.FromAgentName = ToAvatarName;
|
||||
im.Dialog = InstantMessageDialog.MessageFromAgent;
|
||||
|
||||
sim.client = this.Client;
|
||||
sim.isReceived = false;
|
||||
sim.message = im;
|
||||
sim.simulator = this.Client.Network.CurrentSim;
|
||||
sim.timestamp = DateTime.Now;
|
||||
|
||||
bot.Chat.receivedIM(sim);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.IM.Success"), id.ToString(), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.IM.LookupFail"), ToAvatarName);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_AvatarPickerReply(object sender, AvatarPickerReplyEventArgs e)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, string> kvp in e.Avatars)
|
||||
{
|
||||
if (kvp.Value.ToLower() == ToAvatarName.ToLower())
|
||||
{
|
||||
Name2Key[ToAvatarName.ToLower()] = kvp.Key;
|
||||
NameSearchEvent.Set();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
SLBot/bot/Commands/Communication/SayCommand.cs
Normal file
78
SLBot/bot/Commands/Communication/SayCommand.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SayCommand.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 SayCommand : Command
|
||||
{
|
||||
public SayCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "say";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Say.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Say.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Say.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
if (Int32.TryParse(args[0], out channel))
|
||||
startIndex = 1;
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message.Append(args[i]);
|
||||
if (i != args.Length - 1)
|
||||
message.Append(" ");
|
||||
}
|
||||
|
||||
Client.Self.Chat(message.ToString(), channel, ChatType.Normal);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Say.Said"), message.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
SLBot/bot/Commands/Communication/ShoutCommand.cs
Normal file
80
SLBot/bot/Commands/Communication/ShoutCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ShoutCommand.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 ShoutCommand : Command
|
||||
{
|
||||
public ShoutCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "shout";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Shout.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Shout.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
string message = String.Empty;
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Shout.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = Convert.ToInt32(args[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
channel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message += args[i] + " ";
|
||||
}
|
||||
|
||||
Client.Self.Chat(message, channel, ChatType.Shout);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Shout.Shouted"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
SLBot/bot/Commands/Communication/WhisperCommand.cs
Normal file
80
SLBot/bot/Commands/Communication/WhisperCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : WhisperCommand.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 WhisperCommand : Command
|
||||
{
|
||||
public WhisperCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "whisper";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Whisper.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Whisper.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
string message = String.Empty;
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Whisper.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = Convert.ToInt32(args[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
channel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message += args[i] + " ";
|
||||
}
|
||||
|
||||
Client.Self.Chat(message, channel, ChatType.Whisper);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Whisper.Whispered"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
108
SLBot/bot/Commands/Download/AnimationsCommand.cs
Normal file
108
SLBot/bot/Commands/Download/AnimationsCommand.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AnimationsCommand.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.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AnimationsCommand : Command
|
||||
{
|
||||
Dictionary<UUID, UUID> alreadyRequested = new Dictionary<UUID, UUID>();
|
||||
bool enabled = false;
|
||||
|
||||
public AnimationsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "animations";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Animations.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Animations.Usage");
|
||||
|
||||
enabled = SecondLifeBot.Account.LoginDetails.BotConfig.GetSounds;
|
||||
SecondLifeBot.Avatars.AvatarAnimation += new EventHandler<AvatarAnimationEventArgs>(Avatars_AvatarAnimation);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animations.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
enabled = true;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animations.Enabled");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
enabled = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animations.Disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Animations.Usage");
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_AvatarAnimation(object sender, AvatarAnimationEventArgs e)
|
||||
{
|
||||
Dictionary<UUID, string> BuiltInAnimations = Animations.ToDictionary();
|
||||
if (enabled && base.Client.Account.LoginDetails.BotConfig.GetSounds)
|
||||
{
|
||||
foreach (Animation an in e.Animations)
|
||||
{
|
||||
if (!BuiltInAnimations.ContainsKey(an.AnimationID))
|
||||
if (!System.IO.File.Exists("./animations/" + an.AnimationID.ToString() + ".animatn"))
|
||||
base.Client.Assets.RequestAsset(an.AnimationID, AssetType.Animation, true, Assets_OnAnimationReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Assets_OnAnimationReceived(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
{
|
||||
if (!System.IO.Directory.Exists("./animations"))
|
||||
System.IO.Directory.CreateDirectory("./animations");
|
||||
System.IO.File.WriteAllBytes("./animations/" + asset.AssetID.ToString() + ".animatn", asset.AssetData);
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Downloaded"), asset.AssetID.ToString(), asset.AssetData.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Failed"), transfer.AssetID, transfer.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
99
SLBot/bot/Commands/Download/DownloadAnimation.cs
Normal file
99
SLBot/bot/Commands/Download/DownloadAnimation.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DownloadAnimationCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class DownloadAnimationCommand : Command
|
||||
{
|
||||
string downloadResult;
|
||||
System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
public DownloadAnimationCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "downloadanimation";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Description") + " " + bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
UUID AnimationUUID;
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Usage");
|
||||
|
||||
if (!UUID.TryParse(args[0], out AnimationUUID))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.InvalidUUID");
|
||||
}
|
||||
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} downloading animation {2}.", DateTime.Now.ToString(), Client, args[0]));
|
||||
|
||||
base.Client.Assets.RequestAsset(AnimationUUID, AssetType.Animation, true, Assets_OnAnimationReceived);
|
||||
|
||||
if (!waitEvent.WaitOne(10000, false))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
return downloadResult;
|
||||
}
|
||||
}
|
||||
|
||||
public void Assets_OnAnimationReceived(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
{
|
||||
if (!System.IO.Directory.Exists("./animations"))
|
||||
System.IO.Directory.CreateDirectory("./animations");
|
||||
System.IO.File.WriteAllBytes("./animations/" + asset.AssetID.ToString() + ".animatn", asset.AssetData);
|
||||
|
||||
downloadResult = String.Format(bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Downloaded"), asset.AssetID.ToString(), asset.AssetData.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadResult = String.Format(bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.Failed"), transfer.AssetID, transfer.Status);
|
||||
}
|
||||
waitEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
100
SLBot/bot/Commands/Download/DownloadSoundCommand.cs
Normal file
100
SLBot/bot/Commands/Download/DownloadSoundCommand.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DownloadSoundCommand.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.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class DownloadSoundCommand : Command
|
||||
{
|
||||
AutoResetEvent DownloadHandle = new AutoResetEvent(false);
|
||||
string resultState;
|
||||
|
||||
public DownloadSoundCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "downloadsound";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.DownloadSound.Description") + " " + bot.Localization.clResourceManager.getText("Commands.DownloadSound.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
UUID SoundID;
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadSound.Usage");
|
||||
|
||||
DownloadHandle.Reset();
|
||||
|
||||
if (UUID.TryParse(args[0], out SoundID))
|
||||
{
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} downloading sound {2}.", DateTime.Now.ToString(), Client, args[0]));
|
||||
|
||||
base.Client.Assets.RequestAsset(SoundID, AssetType.Sound, true, Assets_OnSoundReceived);
|
||||
|
||||
if (DownloadHandle.WaitOne(120 * 1000, false))
|
||||
{
|
||||
return resultState;
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadSound.Timeout");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadAnimation.InvalidUUID");
|
||||
}
|
||||
}
|
||||
|
||||
public void Assets_OnSoundReceived(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
{
|
||||
if (!System.IO.Directory.Exists("./sounds"))
|
||||
System.IO.Directory.CreateDirectory("./sounds");
|
||||
System.IO.File.WriteAllBytes("./sounds/" + asset.AssetID.ToString() + ".ogg", asset.AssetData);
|
||||
|
||||
resultState = String.Format(bot.Localization.clResourceManager.getText("Commands.Sounds.Downloaded"), asset.AssetID.ToString(), asset.AssetData.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultState = String.Format(bot.Localization.clResourceManager.getText("Commands.Sounds.Failed"), transfer.AssetID, transfer.Status);
|
||||
}
|
||||
DownloadHandle.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
151
SLBot/bot/Commands/Download/DownloadTextureCommand.cs
Normal file
151
SLBot/bot/Commands/Download/DownloadTextureCommand.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DownloadTextureCommand.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.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class DownloadTextureCommand : Command
|
||||
{
|
||||
UUID TextureID;
|
||||
AutoResetEvent DownloadHandle = new AutoResetEvent(false);
|
||||
TextureRequestState resultState;
|
||||
AssetTexture Asset;
|
||||
|
||||
public DownloadTextureCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "downloadtexture";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Description") + " " + bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Usage");
|
||||
|
||||
//SecondLifeBot.Assets.OnImageReceiveProgress += new AssetManager.ImageReceiveProgressCallback(Assets_OnImageReceiveProgress);
|
||||
//SecondLifeBot.Assets.OnImageReceived += new AssetManager.ImageReceivedCallback(Assets_OnImageReceived);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Usage");
|
||||
|
||||
if (args.Length != 1 && args.Length != 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTexture.UsageLong");
|
||||
|
||||
TextureID = UUID.Zero;
|
||||
DownloadHandle.Reset();
|
||||
Asset = null;
|
||||
|
||||
if (UUID.TryParse(args[0], out TextureID))
|
||||
{
|
||||
int discardLevel = 0;
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (!Int32.TryParse(args[1], out discardLevel))
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTexture.UsageLong");
|
||||
}
|
||||
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} downloading texture {2}.", DateTime.Now.ToString(), Client, args[0]));
|
||||
|
||||
Client.Assets.RequestImage(TextureID, ImageType.Normal, Assets_OnImageReceived);
|
||||
|
||||
if (DownloadHandle.WaitOne(120 * 1000, false))
|
||||
{
|
||||
if (resultState == TextureRequestState.Finished)
|
||||
{
|
||||
if (Asset != null && Asset.Decode())
|
||||
{
|
||||
if (!Directory.Exists("textures/"))
|
||||
Directory.CreateDirectory("textures/");
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes("textures/" + Asset.AssetID + ".jp2", Asset.AssetData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.Message, Helpers.LogLevel.Error, Client, ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes("textures/" + Asset.AssetID + ".tga", Asset.Image.ExportTGA());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.Message, Helpers.LogLevel.Error, Client);
|
||||
}
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Saved"), Asset.AssetID, Asset.Image.Width, Asset.Image.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Assets.Image.FailDecode"), TextureID.ToString());
|
||||
}
|
||||
}
|
||||
else if (resultState == TextureRequestState.NotFound)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.DownloadTexture.NotFound"), TextureID.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Assets.Image.FailDownload"), TextureID, resultState);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Timeout");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.DownloadTexture.Usage");
|
||||
}
|
||||
}
|
||||
|
||||
private void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset)
|
||||
{
|
||||
resultState = state;
|
||||
Asset = asset;
|
||||
|
||||
DownloadHandle.Set();
|
||||
}
|
||||
|
||||
/*private void Assets_OnImageReceiveProgress(UUID image, int lastPacket, int recieved, int total)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format("Textura {0}: Recibidos {1} / {2} bytes", image, recieved, total));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
108
SLBot/bot/Commands/Download/SoundsCommand.cs
Normal file
108
SLBot/bot/Commands/Download/SoundsCommand.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SoundsCommand.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.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class SoundsCommand : Command
|
||||
{
|
||||
Dictionary<UUID, UUID> alreadyRequested = new Dictionary<UUID, UUID>();
|
||||
bool enabled = false;
|
||||
|
||||
public SoundsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "sounds";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Sounds.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Textures.Usage");
|
||||
|
||||
enabled = SecondLifeBot.Account.LoginDetails.BotConfig.GetSounds;
|
||||
SecondLifeBot.Sound.SoundTrigger += new EventHandler<SoundTriggerEventArgs>(Sound_SoundTrigger);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Sounds.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
enabled = true;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Sounds.Enabled");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
enabled = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Sounds.Disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Sounds.Usage");
|
||||
}
|
||||
}
|
||||
|
||||
void Sound_SoundTrigger(object sender, SoundTriggerEventArgs e)
|
||||
{
|
||||
if (enabled && base.Client.Account.LoginDetails.BotConfig.GetTextures)
|
||||
{
|
||||
#if DEBUG
|
||||
bot.Console.WriteLine(this.Client, "GETTING SOUND: Gain: {0}, Object: {1}, Owner: {2}, Parent: {3}, Position: {4}, Region: {5}, ID: {6}",
|
||||
e.Gain.ToString(), e.ObjectID.ToString(), e.OwnerID.ToString(), e.ParentID.ToString(),
|
||||
e.Position.ToString(), e.RegionHandle.ToString(), e.SoundID.ToString());
|
||||
#endif
|
||||
if (!System.IO.File.Exists("./sounds/" + e.SoundID.ToString() + ".ogg"))
|
||||
base.Client.Assets.RequestAsset(e.SoundID, AssetType.Sound, true, Assets_OnSoundReceived);
|
||||
}
|
||||
}
|
||||
|
||||
public void Assets_OnSoundReceived(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
{
|
||||
if (!System.IO.Directory.Exists("./sounds"))
|
||||
System.IO.Directory.CreateDirectory("./sounds");
|
||||
System.IO.File.WriteAllBytes("./sounds/" + asset.AssetID.ToString() + ".ogg", asset.AssetData);
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Sounds.Downloaded"), asset.AssetID.ToString(), asset.AssetData.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Sounds.Failed"), transfer.AssetID, transfer.Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
182
SLBot/bot/Commands/Download/TexturesCommand.cs
Normal file
182
SLBot/bot/Commands/Download/TexturesCommand.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : TexturesCommand.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.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TexturesCommand : Command
|
||||
{
|
||||
Dictionary<UUID, UUID> alreadyRequested = new Dictionary<UUID, UUID>();
|
||||
bool enabled = false;
|
||||
|
||||
public TexturesCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "textures";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Textures.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Textures.Usage");
|
||||
|
||||
enabled = SecondLifeBot.Account.LoginDetails.BotConfig.GetTextures;
|
||||
SecondLifeBot.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_OnNewPrim);
|
||||
SecondLifeBot.Objects.AvatarUpdate += Objects_OnNewAvatar;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Textures.Usage");
|
||||
|
||||
if (args[0].ToLower() == "on")
|
||||
{
|
||||
enabled = true;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Textures.Enabled");
|
||||
}
|
||||
else if (args[0].ToLower() == "off")
|
||||
{
|
||||
enabled = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Textures.Disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Textures.Usage");
|
||||
}
|
||||
}
|
||||
|
||||
void Objects_OnNewAvatar(object sender, AvatarUpdateEventArgs e)
|
||||
{
|
||||
if (enabled && base.Client.Account.LoginDetails.BotConfig.GetTextures)
|
||||
{
|
||||
// Search this avatar for textures
|
||||
for (int i = 0; i < e.Avatar.Textures.FaceTextures.Length; i++)
|
||||
{
|
||||
Primitive.TextureEntryFace face = e.Avatar.Textures.FaceTextures[i];
|
||||
|
||||
if (face != null)
|
||||
{
|
||||
if (!alreadyRequested.ContainsKey(face.TextureID))
|
||||
{
|
||||
alreadyRequested[face.TextureID] = face.TextureID;
|
||||
|
||||
// Determine if this is a baked outfit texture or a normal texture
|
||||
ImageType type = ImageType.Normal;
|
||||
AvatarTextureIndex index = (AvatarTextureIndex)i;
|
||||
switch (index)
|
||||
{
|
||||
case AvatarTextureIndex.EyesBaked:
|
||||
case AvatarTextureIndex.HeadBaked:
|
||||
case AvatarTextureIndex.LowerBaked:
|
||||
case AvatarTextureIndex.SkirtBaked:
|
||||
case AvatarTextureIndex.UpperBaked:
|
||||
type = ImageType.Baked;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!File.Exists("textures/" + face.TextureID + ".jp2"))
|
||||
Client.Assets.RequestImage(face.TextureID, type, Assets_OnImageReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Objects_OnNewPrim(object sender, PrimEventArgs e)
|
||||
{
|
||||
Primitive prim = e.Prim;
|
||||
|
||||
if (enabled && base.Client.Account.LoginDetails.BotConfig.GetTextures)
|
||||
{
|
||||
// Search this prim for textures
|
||||
for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
|
||||
{
|
||||
Primitive.TextureEntryFace face = prim.Textures.FaceTextures[i];
|
||||
|
||||
if (face != null)
|
||||
{
|
||||
if (!alreadyRequested.ContainsKey(face.TextureID))
|
||||
{
|
||||
alreadyRequested[face.TextureID] = face.TextureID;
|
||||
if (!File.Exists("textures/" + face.TextureID + ".jp2"))
|
||||
Client.Assets.RequestImage(face.TextureID, ImageType.Normal, Assets_OnImageReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset)
|
||||
{
|
||||
if (state == TextureRequestState.Finished && enabled && alreadyRequested.ContainsKey(asset.AssetID))
|
||||
{
|
||||
if (state == TextureRequestState.Finished)
|
||||
{
|
||||
if (!Directory.Exists("textures"))
|
||||
Directory.CreateDirectory("textures");
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes("textures/" + asset.AssetID + ".jp2", asset.AssetData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.Message, Helpers.LogLevel.Error, Client);
|
||||
}
|
||||
|
||||
if (asset.Decode())
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes("textures/" + asset.AssetID + ".tga", asset.Image.ExportTGA());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.Message, Helpers.LogLevel.Error, Client);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Assets.Image.FailDecode"), asset.AssetID);
|
||||
}
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Assets.Image.Downloaded"), asset.AssetID, asset.AssetData.Length);
|
||||
|
||||
}
|
||||
else
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Assets.Image.FailDownload"), asset.AssetID, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
83
SLBot/bot/Commands/Grid/AgentLocationsCommand.cs
Normal file
83
SLBot/bot/Commands/Grid/AgentLocationsCommand.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AgentLocationsCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public class AgentLocationsCommand : Command
|
||||
{
|
||||
public AgentLocationsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "agentlocations";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.AgentLocations.Description") + " " + bot.Localization.clResourceManager.getText("Commands.AgentLocations.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
ulong regionHandle;
|
||||
|
||||
if (args.Length == 0)
|
||||
regionHandle = Client.Network.CurrentSim.Handle;
|
||||
else if (!(args.Length == 1 && UInt64.TryParse(args[0], out regionHandle)))
|
||||
return bot.Localization.clResourceManager.getText("Commands.AgentLocations.Usage");
|
||||
|
||||
List<MapItem> items = Client.Grid.MapItems(regionHandle, GridItemType.AgentLocations,
|
||||
GridLayerType.Objects, 1000 * 20);
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.AppendLine(bot.Localization.clResourceManager.getText("Commands.AgentLocations.Locations"));
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
MapAgentLocation location = (MapAgentLocation)items[i];
|
||||
|
||||
ret.AppendLine(String.Format(bot.Localization.clResourceManager.getText("Commands.AgentLocations.Avatar"), location.AvatarCount, location.LocalX,
|
||||
location.LocalY));
|
||||
}
|
||||
|
||||
return ret.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.AgentLocations.Fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
SLBot/bot/Commands/Grid/FindSimCommand.cs
Normal file
74
SLBot/bot/Commands/Grid/FindSimCommand.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FindSimCommand.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 FindSimCommand : Command
|
||||
{
|
||||
public FindSimCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "findsim";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.FindSim.Description") + " " + bot.Localization.clResourceManager.getText("Commands.FindSim.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.FindSim.Usage");
|
||||
|
||||
// Build the simulator name from the args list
|
||||
string simName = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
simName += args[i] + " ";
|
||||
simName = simName.TrimEnd().ToLower();
|
||||
|
||||
//if (!GridDataCached[Client])
|
||||
//{
|
||||
// Client.Grid.RequestAllSims(GridManager.MapLayerType.Objects);
|
||||
// System.Threading.Thread.Sleep(5000);
|
||||
// GridDataCached[Client] = true;
|
||||
//}
|
||||
|
||||
GridRegion region;
|
||||
|
||||
if (Client.Grid.GetGridRegion(simName, GridLayerType.Objects, out region))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.FindSim.Info"), region.Name, region.RegionHandle, region.X, region.Y);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.FindSim.LookupFail"), simName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
SLBot/bot/Commands/Grid/GridLayerCommand.cs
Normal file
61
SLBot/bot/Commands/Grid/GridLayerCommand.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GridLayerCommand.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 GridLayerCommand : Command
|
||||
{
|
||||
public GridLayerCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "gridlayer";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GridLayer.Description");
|
||||
SecondLifeBot.Grid.GridLayer += Grid_GridLayer;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
base.Client.Grid.RequestMapLayer(GridLayerType.Objects);
|
||||
return bot.Localization.clResourceManager.getText("Commands.GridLayer.Ready");
|
||||
}
|
||||
|
||||
void Grid_GridLayer(object sender, GridLayerEventArgs e)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(bot.Localization.clResourceManager.getText("Commands.GridLayer.Layer"),
|
||||
e.Layer.ImageID.ToString(), e.Layer.Bottom, e.Layer.Left, e.Layer.Top, e.Layer.Right));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
SLBot/bot/Commands/Grid/GridMapCommand.cs
Normal file
54
SLBot/bot/Commands/Grid/GridMapCommand.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GridMapCommand.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 GridMapCommand : Command
|
||||
{
|
||||
public GridMapCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "gridmap";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GridMap.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.Grid.RequestMainlandSims(GridLayerType.Objects);
|
||||
return bot.Localization.clResourceManager.getText("Commands.GridMap.Ready");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
122
SLBot/bot/Commands/Groups/ActivateGroupCommand.cs
Normal file
122
SLBot/bot/Commands/Groups/ActivateGroupCommand.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ActivateGroupCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class ActivateGroupCommand : Command
|
||||
{
|
||||
ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
string activeGroup;
|
||||
|
||||
public ActivateGroupCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "activategroup";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ActivateGroup.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ActivateGroup.Usage");
|
||||
}
|
||||
|
||||
private void AgentDataUpdateHandler(object sender, PacketReceivedEventArgs e)
|
||||
{
|
||||
AgentDataUpdatePacket p = (AgentDataUpdatePacket)e.Packet;
|
||||
if (p.AgentData.AgentID == Client.Self.AgentID)
|
||||
{
|
||||
activeGroup = Utils.BytesToString(p.AgentData.GroupName) + " ( " + Utils.BytesToString(p.AgentData.GroupTitle) + " )";
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool isGroupID = false;
|
||||
|
||||
if (args.Length < 1)
|
||||
return Description;
|
||||
|
||||
activeGroup = string.Empty;
|
||||
|
||||
string groupName = String.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
groupName += args[i] + " ";
|
||||
groupName = groupName.Trim();
|
||||
|
||||
Client.Groups.RequestCurrentGroups();
|
||||
|
||||
GroupsEvent.Reset();
|
||||
|
||||
string realGroupName = "";
|
||||
|
||||
UUID groupUUID = Client.GroupName2UUID(groupName);
|
||||
if (UUID.Zero != groupUUID)
|
||||
{
|
||||
EventHandler<PacketReceivedEventArgs> pcallback = AgentDataUpdateHandler;
|
||||
Client.Network.RegisterCallback(PacketType.AgentDataUpdate, pcallback);
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.ActivateGroup.Setting"), groupName);
|
||||
Client.Groups.ActivateGroup(groupUUID);
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
|
||||
Client.Network.UnregisterCallback(PacketType.AgentDataUpdate, pcallback);
|
||||
GroupsEvent.Reset();
|
||||
|
||||
/* A.Biondi
|
||||
* TODO: Handle titles choosing.
|
||||
*/
|
||||
|
||||
Client.key2Name(groupUUID, out realGroupName, out isGroupID);
|
||||
|
||||
if (!isGroupID)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarID"), groupUUID);
|
||||
|
||||
if (realGroupName == "")
|
||||
realGroupName = groupUUID.ToString();
|
||||
|
||||
if (String.IsNullOrEmpty(activeGroup))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ActivateGroup.Failed"), Client.ToString(),
|
||||
realGroupName);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ActivateGroup.Active"), Client.ToString(),
|
||||
realGroupName);
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ActivateGroup.NotInGroup"), Client.ToString(),
|
||||
realGroupName);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ActivateGroup.NoGroups"), Client.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
126
SLBot/bot/Commands/Groups/ActivateRoleCommand.cs
Normal file
126
SLBot/bot/Commands/Groups/ActivateRoleCommand.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ActivateRoleCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class ActivateRoleCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private string GroupName;
|
||||
private UUID GroupUUID;
|
||||
private UUID RoleUUID;
|
||||
private UUID GroupRequestID;
|
||||
private Dictionary<UUID, GroupRole> GroupRoles;
|
||||
|
||||
public ActivateRoleCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "activaterole";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.ActivateRole.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ActivateRole.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool isGroupKey = false;
|
||||
|
||||
if (args.Length > 2 || args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.ActivateRole.Usage");
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
if (!UUID.TryParse(args[1], out GroupUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.ExpectedGroupID");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Client.Self.ActiveGroup == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.NoGroupActive");
|
||||
|
||||
GroupUUID = Client.Self.ActiveGroup;
|
||||
}
|
||||
|
||||
if (!UUID.TryParse(args[0], out RoleUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.AddToRole.ExpectedRoleID");
|
||||
|
||||
if (!Client.key2Name(GroupUUID, out GroupName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.GroupNotFound");
|
||||
if (!isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarID");
|
||||
|
||||
Client.ReloadGroupsCache();
|
||||
|
||||
if (Client.GroupsCache == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.CacheFailed");
|
||||
if (Client.GroupsCache.Count == 0)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.NoGroups");
|
||||
if (!Client.GroupsCache.ContainsKey(GroupUUID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.AddToRole.NotMemberSelf"), GroupName);
|
||||
|
||||
Client.Groups.GroupRoleDataReply += Groups_GroupRoles;
|
||||
GroupRequestID = Client.Groups.RequestGroupRoles(GroupUUID);
|
||||
if (!GroupsEvent.WaitOne(30000, false))
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.CannotRoles");
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
}
|
||||
|
||||
GroupRole chosenRole;
|
||||
|
||||
if (!GroupRoles.TryGetValue(RoleUUID, out chosenRole))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.NotRole");
|
||||
|
||||
Client.Groups.ActivateTitle(GroupUUID, RoleUUID);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ActivateRole.Activating"), chosenRole.Name, GroupName);
|
||||
}
|
||||
|
||||
private void Groups_GroupRoles(object sender, GroupRolesDataReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
GroupRoles = e.Roles;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
163
SLBot/bot/Commands/Groups/AddToRoleCommand.cs
Normal file
163
SLBot/bot/Commands/Groups/AddToRoleCommand.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : AddToRoleCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class AddToRoleCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private string GroupName, AvatarName;
|
||||
private UUID GroupUUID;
|
||||
private UUID RoleUUID;
|
||||
private UUID GroupRequestID;
|
||||
private UUID AvatarUUID;
|
||||
private Dictionary<UUID, GroupRole> GroupRoles;
|
||||
private Dictionary<UUID, GroupMember> GroupMembers;
|
||||
|
||||
public AddToRoleCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "addtorole";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.AddToRole.Description") + " " + bot.Localization.clResourceManager.getText("Commands.AddToRole.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool isGroupKey = false;
|
||||
|
||||
if (args.Length > 3 || args.Length < 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.AddToRole.Usage");
|
||||
|
||||
if (args.Length == 3)
|
||||
{
|
||||
if (!UUID.TryParse(args[2], out GroupUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.ExpectedGroupID");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Client.Self.ActiveGroup == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.NoGroupActive");
|
||||
|
||||
GroupUUID = Client.Self.ActiveGroup;
|
||||
}
|
||||
|
||||
if (!UUID.TryParse(args[0], out RoleUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.AddToRole.ExpectedRoleID");
|
||||
if (!UUID.TryParse(args[1], out AvatarUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarID");
|
||||
|
||||
if (!Client.key2Name(GroupUUID, out GroupName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.GroupNotFound");
|
||||
if (!isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarID");
|
||||
|
||||
if (!Client.key2Name(AvatarUUID, out AvatarName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarNotFound");
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.GroupID");
|
||||
|
||||
Client.ReloadGroupsCache();
|
||||
|
||||
if (Client.GroupsCache == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.CacheFailed");
|
||||
if (Client.GroupsCache.Count == 0)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.NoGroups");
|
||||
if (!Client.GroupsCache.ContainsKey(GroupUUID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.AddToRole.NotMemberSelf"), GroupName);
|
||||
|
||||
Client.Groups.GroupMembersReply += GroupMembersHandler;
|
||||
GroupRequestID = Client.Groups.RequestGroupMembers(GroupUUID);
|
||||
if (!GroupsEvent.WaitOne(30000, false))
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupMembersReply -= GroupMembersHandler;
|
||||
return "Unable to get group members.";
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupMembersReply -= GroupMembersHandler;
|
||||
}
|
||||
|
||||
GroupMember chosenMember;
|
||||
|
||||
if (!GroupMembers.TryGetValue(AvatarUUID, out chosenMember))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.AddToRole.NotMember"), AvatarName, GroupName);
|
||||
|
||||
Client.Groups.GroupRoleDataReply += Groups_GroupRoles;
|
||||
GroupRequestID = Client.Groups.RequestGroupRoles(GroupUUID);
|
||||
if (!GroupsEvent.WaitOne(30000, false))
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.CannotRoles");
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
}
|
||||
|
||||
GroupRole chosenRole;
|
||||
|
||||
if (!GroupRoles.TryGetValue(RoleUUID, out chosenRole))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.NotRole");
|
||||
|
||||
Client.Groups.AddToRole(GroupUUID, RoleUUID, AvatarUUID);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.AddToRole.Adding"), AvatarName, chosenRole.Name, GroupName);
|
||||
}
|
||||
|
||||
private void GroupMembersHandler(object sender, GroupMembersReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
GroupMembers = e.Members;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
private void Groups_GroupRoles(object sender, GroupRolesDataReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
GroupRoles = e.Roles;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
119
SLBot/bot/Commands/Groups/GroupEjectCommand.cs
Normal file
119
SLBot/bot/Commands/Groups/GroupEjectCommand.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroupEjectCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class GroupEjectCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private string GroupName;
|
||||
private UUID GroupUUID;
|
||||
private UUID GroupRequestID;
|
||||
private Dictionary<UUID, GroupMember> GroupMembers;
|
||||
|
||||
public GroupEjectCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "groupeject";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.GroupEject.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GroupEject.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID avatarID;
|
||||
bool isGroupKey;
|
||||
string avatarName;
|
||||
GroupMembers = new Dictionary<UUID, GroupMember>();
|
||||
GroupsEvent.Reset();
|
||||
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.Usage");
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
if (!UUID.TryParse(args[1], out GroupUUID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.ExpectedGroupID");
|
||||
|
||||
if (!Client.key2Name(GroupUUID, out GroupName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.GroupNotFound");
|
||||
if (!isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarID");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Client.Self.ActiveGroup == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.NoGroupActive");
|
||||
|
||||
GroupUUID = Client.Self.ActiveGroup;
|
||||
}
|
||||
|
||||
if (!UUID.TryParse(args[0], out avatarID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.ExpectedAvatarID");
|
||||
|
||||
if (!Client.key2Name(avatarID, out avatarName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.AvatarNotFound");
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.GroupID");
|
||||
|
||||
Client.Groups.GroupMembersReply += GroupMembersHandler;
|
||||
GroupRequestID = Client.Groups.RequestGroupMembers(GroupUUID);
|
||||
if (!GroupsEvent.WaitOne(30000, false))
|
||||
{
|
||||
Client.Groups.GroupMembersReply -= GroupMembersHandler;
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupEject.ErrorMembers");
|
||||
}
|
||||
|
||||
Client.Groups.GroupMembersReply -= GroupMembersHandler;
|
||||
|
||||
if (!GroupMembers.ContainsKey(avatarID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupEject.NotMember"), avatarName, GroupName);
|
||||
|
||||
Client.Groups.EjectUser(GroupUUID, avatarID);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupEject.Ejected"), avatarName, GroupName);
|
||||
}
|
||||
|
||||
private void GroupMembersHandler(object sender, GroupMembersReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
GroupMembers = e.Members;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
124
SLBot/bot/Commands/Groups/GroupInviteCommand.cs
Normal file
124
SLBot/bot/Commands/Groups/GroupInviteCommand.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroupInviteCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class GroupInviteCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private UUID roleID;
|
||||
private UUID GroupRequestID;
|
||||
private Dictionary<UUID, GroupRole> Roles;
|
||||
|
||||
public GroupInviteCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "invitegroup";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.GroupInvite.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GroupInvite.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.Usage");
|
||||
|
||||
UUID avatarID;
|
||||
string avatarName, groupName;
|
||||
bool isGroupKey = false;
|
||||
Roles = new Dictionary<UUID,GroupRole>();
|
||||
|
||||
if (!UUID.TryParse(args[0], out avatarID))
|
||||
return Description;
|
||||
|
||||
roleID = UUID.Zero;
|
||||
|
||||
if (args.Length == 2)
|
||||
if (!UUID.TryParse(args[1], out roleID))
|
||||
return Description;
|
||||
|
||||
if (Client.Self.ActiveGroup == UUID.Zero)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.NoGroupActive");
|
||||
|
||||
if (!Client.key2Name(avatarID, out avatarName, out isGroupKey))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.AvNotFound");
|
||||
|
||||
if (isGroupKey)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.CannotGroup");
|
||||
|
||||
Client.key2Name(Client.Self.ActiveGroup, out groupName);
|
||||
|
||||
Client.Groups.GroupRoleDataReply += Groups_GroupRoles;
|
||||
GroupRequestID = Client.Groups.RequestGroupRoles(Client.Self.ActiveGroup);
|
||||
if (!GroupsEvent.WaitOne(30000, false))
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.CannotRoles");
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupsEvent.Reset();
|
||||
}
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
|
||||
if (!Roles.ContainsKey(roleID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupInvite.NotRole"), roleID);
|
||||
|
||||
List<UUID> inviteRoles = new List<UUID>();
|
||||
|
||||
inviteRoles.Add(roleID);
|
||||
|
||||
GroupRole role;
|
||||
|
||||
if (!Roles.TryGetValue(roleID, out role))
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupInvite.ErrorRole");
|
||||
|
||||
Client.Groups.Invite(Client.Self.ActiveGroup, inviteRoles, avatarID);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupInvite.Inviting"), avatarName, groupName, role.Name);
|
||||
}
|
||||
|
||||
void Groups_GroupRoles(object sender, GroupRolesDataReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
Roles = e.Roles;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
108
SLBot/bot/Commands/Groups/GroupMembersCommand.cs
Normal file
108
SLBot/bot/Commands/Groups/GroupMembersCommand.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroupMembersCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class GroupMembersCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private string GroupName;
|
||||
private UUID GroupUUID;
|
||||
private UUID GroupRequestID;
|
||||
StringBuilder sb;
|
||||
|
||||
public GroupMembersCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "groupmembers";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.GroupMembers.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GroupMembers.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupMembers.Usage");
|
||||
|
||||
sb = new StringBuilder();
|
||||
|
||||
GroupName = String.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
GroupName += args[i] + " ";
|
||||
GroupName = GroupName.Trim();
|
||||
|
||||
GroupUUID = Client.GroupName2UUID(GroupName);
|
||||
if (UUID.Zero != GroupUUID)
|
||||
{
|
||||
Client.Groups.GroupMembersReply += GroupMembersHandler;
|
||||
GroupRequestID = Client.Groups.RequestGroupMembers(GroupUUID);
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupMembersReply -= GroupMembersHandler;
|
||||
return sb.ToString();
|
||||
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupMembers.NotMember"), Client.ToString(), GroupName);
|
||||
}
|
||||
|
||||
private void GroupMembersHandler(object sender, GroupMembersReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupMembers.GotMembers"), Client.ToString()).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.RequestID"), e.RequestID).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.GroupName"), GroupName).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.GroupID"), GroupUUID).AppendLine();
|
||||
if (e.Members.Count > 0)
|
||||
foreach (KeyValuePair<UUID, GroupMember> member in e.Members)
|
||||
{
|
||||
string MemberName;
|
||||
|
||||
if (!Client.key2Name(member.Key, out MemberName))
|
||||
MemberName = bot.Localization.clResourceManager.getText("Commands.PrimInfo.Unknown");
|
||||
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupMembers.Member"), MemberName, member.Key.ToString()).AppendLine();
|
||||
|
||||
}
|
||||
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupMembers.MemberCount"), e.Members.Count).AppendLine();
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
98
SLBot/bot/Commands/Groups/GroupRolesCommand.cs
Normal file
98
SLBot/bot/Commands/Groups/GroupRolesCommand.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroupRolesCommand.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
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class GroupRolesCommand : Command
|
||||
{
|
||||
private ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
private string GroupName;
|
||||
private UUID GroupUUID;
|
||||
private UUID GroupRequestID;
|
||||
StringBuilder sb;
|
||||
|
||||
public GroupRolesCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "grouproles";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.GroupRoles.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GroupRoles.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.GroupRoles.Usage");
|
||||
|
||||
sb = new StringBuilder();
|
||||
|
||||
GroupName = String.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
GroupName += args[i] + " ";
|
||||
GroupName = GroupName.Trim();
|
||||
|
||||
GroupUUID = Client.GroupName2UUID(GroupName);
|
||||
if (UUID.Zero != GroupUUID)
|
||||
{
|
||||
Client.Groups.GroupRoleDataReply += Groups_GroupRoles;
|
||||
GroupRequestID = Client.Groups.RequestGroupRoles(GroupUUID);
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
GroupsEvent.Reset();
|
||||
Client.Groups.GroupRoleDataReply -= Groups_GroupRoles;
|
||||
return sb.ToString();
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.GroupRoles.NoRoles"), Client.ToString(), GroupName);
|
||||
}
|
||||
|
||||
private void Groups_GroupRoles(object sender, GroupRolesDataReplyEventArgs e)
|
||||
{
|
||||
if (e.RequestID == GroupRequestID)
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.GotRoles"), Client.ToString()).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.RequestID"), e.RequestID).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.GroupName"), GroupName).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.GroupID"), GroupUUID).AppendLine();
|
||||
if (e.Roles.Count > 0)
|
||||
foreach (KeyValuePair<UUID, GroupRole> role in e.Roles)
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.Role"), role.Value.ID, role.Value.Name, role.Value.Title).AppendLine();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.GroupRoles.RoleCount"), e.Roles.Count).AppendLine();
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
SLBot/bot/Commands/Groups/GroupsCommand.cs
Normal file
77
SLBot/bot/Commands/Groups/GroupsCommand.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GroupsCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
public class GroupsCommand : Command
|
||||
{
|
||||
ManualResetEvent GetCurrentGroupsEvent = new ManualResetEvent(false);
|
||||
Dictionary<UUID, Group> groups = new Dictionary<UUID, Group>();
|
||||
|
||||
public GroupsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "groups";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Groups.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Client.ReloadGroupsCache();
|
||||
return getGroupsString();
|
||||
}
|
||||
|
||||
string getGroupsString()
|
||||
{
|
||||
if (null == Client.GroupsCache)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.CacheFailed");
|
||||
if (0 == Client.GroupsCache.Count)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Groups.NoGroups");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Groups.GotGroups"), Client.GroupsCache.Count).AppendLine();
|
||||
foreach (Group group in Client.GroupsCache.Values)
|
||||
{
|
||||
sb.AppendLine(group.ID + ", " + group.Name);
|
||||
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
110
SLBot/bot/Commands/Groups/ImGroupCommand.cs
Normal file
110
SLBot/bot/Commands/Groups/ImGroupCommand.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ImGroupCommand.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.Threading;
|
||||
|
||||
public class ImGroupCommand : Command
|
||||
{
|
||||
UUID ToGroupID = UUID.Zero;
|
||||
ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);
|
||||
|
||||
public ImGroupCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "imgroup";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.IMGroup.Description") + " " + bot.Localization.clResourceManager.getText("Commands.IMGroup.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.IMGroup.Usage");
|
||||
|
||||
|
||||
|
||||
if (UUID.TryParse(args[0], out ToGroupID))
|
||||
{
|
||||
string message = String.Empty;
|
||||
for (int ct = 1; ct < args.Length; ct++)
|
||||
message += args[ct] + " ";
|
||||
message = message.TrimEnd();
|
||||
if (message.Length > 1023)
|
||||
message = message.Remove(1023);
|
||||
|
||||
Client.Self.GroupChatJoined += Self_GroupChatJoined;
|
||||
if (!Client.Self.GroupChatSessions.ContainsKey(ToGroupID))
|
||||
{
|
||||
WaitForSessionStart.Reset();
|
||||
Client.Self.RequestJoinGroupChat(ToGroupID);
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitForSessionStart.Set();
|
||||
}
|
||||
|
||||
if (WaitForSessionStart.WaitOne(20000, false))
|
||||
{
|
||||
Client.Self.InstantMessageGroup(ToGroupID, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.IMGroup.Timeout");
|
||||
}
|
||||
|
||||
Client.Self.GroupChatJoined -= Self_GroupChatJoined;
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.IMGroup.Success"), ToGroupID.ToString(), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.IMGroup.Fail");
|
||||
}
|
||||
}
|
||||
|
||||
void Self_GroupChatJoined(object sender, GroupChatJoinedEventArgs e)
|
||||
{
|
||||
if (e.Success)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.IMGroup.Joined"), e.SessionName);
|
||||
WaitForSessionStart.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.IMGroup.JoinFail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
169
SLBot/bot/Commands/Groups/JoinGroupCommand.cs
Normal file
169
SLBot/bot/Commands/Groups/JoinGroupCommand.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : JoinGroupCommand.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.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class JoinGroupCommand : Command
|
||||
{
|
||||
ManualResetEvent GetGroupsSearchEvent = new ManualResetEvent(false);
|
||||
private UUID queryID = UUID.Zero;
|
||||
private UUID resolvedGroupID;
|
||||
private string groupName;
|
||||
private string resolvedGroupName;
|
||||
private bool joinedGroup;
|
||||
|
||||
public JoinGroupCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "joingroup";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.JoinGroup.Description") + " " + bot.Localization.clResourceManager.getText("Commands.JoinGroup.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return Description;
|
||||
|
||||
groupName = String.Empty;
|
||||
resolvedGroupID = UUID.Zero;
|
||||
resolvedGroupName = String.Empty;
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
if (!UUID.TryParse((resolvedGroupName = groupName = args[0]), out resolvedGroupID))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.JoinGroup.InvalidUUID"), resolvedGroupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
groupName += args[i] + " ";
|
||||
groupName = groupName.Trim();
|
||||
|
||||
Client.Directory.DirGroupsReply += Directory_DirGroups;
|
||||
|
||||
queryID = Client.Directory.StartGroupSearch(groupName, 0);
|
||||
|
||||
GetGroupsSearchEvent.WaitOne(60000, false);
|
||||
|
||||
Client.Directory.DirGroupsReply -= Directory_DirGroups;
|
||||
|
||||
GetGroupsSearchEvent.Reset();
|
||||
}
|
||||
|
||||
if (resolvedGroupID == UUID.Zero)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resolvedGroupName))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.JoinGroup.UUIDNotFound"), groupName);
|
||||
else
|
||||
return resolvedGroupName;
|
||||
}
|
||||
|
||||
Client.Groups.GroupJoinedReply += Groups_OnGroupJoined;
|
||||
Client.Groups.RequestJoinGroup(resolvedGroupID);
|
||||
|
||||
/* A.Biondi
|
||||
* TODO: implement the pay to join procedure.
|
||||
*/
|
||||
|
||||
GetGroupsSearchEvent.WaitOne(60000, false);
|
||||
|
||||
Client.Groups.GroupJoinedReply -= Groups_OnGroupJoined;
|
||||
GetGroupsSearchEvent.Reset();
|
||||
|
||||
if (joinedGroup)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Joined"), resolvedGroupName);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Failed"), resolvedGroupName);
|
||||
}
|
||||
|
||||
void Groups_OnGroupJoined(object sender, GroupOperationEventArgs e)
|
||||
{
|
||||
if (e.Success)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Joined"), e.GroupID.ToString());
|
||||
joinedGroup = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Failed"), e.GroupID.ToString());
|
||||
joinedGroup = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Directory_DirGroups(object sender, DirGroupsReplyEventArgs e)
|
||||
{
|
||||
if (queryID == e.QueryID)
|
||||
{
|
||||
queryID = UUID.Zero;
|
||||
if (e.MatchedGroups.Count < 1)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Empty"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.MatchedGroups.Count > 1)
|
||||
{
|
||||
/* A.Biondi
|
||||
* The Group search doesn't work as someone could expect...
|
||||
* It'll give back to you a long list of groups even if the
|
||||
* searchText (groupName) matches esactly one of the groups
|
||||
* names present on the server, so we need to check each result.
|
||||
* UUIDs of the matching groups are written on the console.
|
||||
*/
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Matching") + System.Environment.NewLine);
|
||||
foreach (DirectoryManager.GroupSearchData groupRetrieved in e.MatchedGroups)
|
||||
{
|
||||
bot.Console.WriteLine(groupRetrieved.GroupName + "\t\t\t(" +
|
||||
Name + " UUID " + groupRetrieved.GroupID.ToString() + ")");
|
||||
|
||||
if (groupRetrieved.GroupName.ToLower() == groupName.ToLower())
|
||||
{
|
||||
resolvedGroupID = groupRetrieved.GroupID;
|
||||
resolvedGroupName = groupRetrieved.GroupName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(resolvedGroupName))
|
||||
resolvedGroupName = String.Format(bot.Localization.clResourceManager.getText("Commands.JoinGroup.Ambigous"), e.MatchedGroups.Count.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
GetGroupsSearchEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
96
SLBot/bot/Commands/Groups/LeaveGroupCommand.cs
Normal file
96
SLBot/bot/Commands/Groups/LeaveGroupCommand.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : LeaveGroupCommand.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.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class LeaveGroupCommand : Command
|
||||
{
|
||||
ManualResetEvent GroupsEvent = new ManualResetEvent(false);
|
||||
Dictionary<UUID, Group> groups = new Dictionary<UUID, Group>();
|
||||
private bool leftGroup;
|
||||
|
||||
public LeaveGroupCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "leavegroup";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Description") + " " + bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return Description;
|
||||
|
||||
string groupName = String.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
groupName += args[i] + " ";
|
||||
groupName = groupName.Trim();
|
||||
|
||||
UUID groupUUID = Client.GroupName2UUID(groupName);
|
||||
if (UUID.Zero != groupUUID)
|
||||
{
|
||||
Client.Groups.GroupLeaveReply += Groups_GroupLeft;
|
||||
Client.Groups.LeaveGroup(groupUUID);
|
||||
|
||||
GroupsEvent.WaitOne(30000, false);
|
||||
Client.Groups.GroupLeaveReply -= Groups_GroupLeft;
|
||||
|
||||
GroupsEvent.Reset();
|
||||
Client.ReloadGroupsCache();
|
||||
|
||||
if (leftGroup)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Left"), Client.ToString(),
|
||||
groupName);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Failed"), Client.ToString(),
|
||||
groupName);
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.LeaveGroup.NotInGroup"), Client.ToString(), groupName);
|
||||
}
|
||||
|
||||
void Groups_GroupLeft(object sender, GroupOperationEventArgs e)
|
||||
{
|
||||
if (e.Success)
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Left"), Client.ToString(), e.GroupID.ToString());
|
||||
else
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.LeaveGroup.Failed"), Client.ToString(), e.GroupID.ToString());
|
||||
|
||||
leftGroup = e.Success;
|
||||
GroupsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
514
SLBot/bot/Commands/Inventory/BackupCommand.cs
Normal file
514
SLBot/bot/Commands/Inventory/BackupCommand.cs
Normal file
@@ -0,0 +1,514 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BackupCommand.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.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class BackupCommand : Command
|
||||
{
|
||||
private BackgroundWorker BackupWorker;
|
||||
private List<QueuedDownloadInfo> CurrentDownloads = new List<QueuedDownloadInfo>(10);
|
||||
private const int MAX_TRANSFERS = 10;
|
||||
private Queue<QueuedDownloadInfo> PendingDownloads = new Queue<QueuedDownloadInfo>();
|
||||
private BackgroundWorker QueueWorker;
|
||||
private int TextItemErrors;
|
||||
private int TextItemsFound;
|
||||
private int TextItemsTransferred;
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// true if either of the background threads is running
|
||||
/// </summary>
|
||||
private bool BackgroundBackupRunning
|
||||
{
|
||||
get { return InventoryWalkerRunning || QueueRunnerRunning; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the thread walking inventory is running
|
||||
/// </summary>
|
||||
private bool InventoryWalkerRunning
|
||||
{
|
||||
get { return BackupWorker != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the thread feeding the queue to the server is running
|
||||
/// </summary>
|
||||
private bool QueueRunnerRunning
|
||||
{
|
||||
get { return QueueWorker != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a string summarizing activity
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string BackgroundBackupStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder sbResult = new StringBuilder();
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Running"), Name, BoolToNot(BackgroundBackupRunning));
|
||||
if (TextItemErrors != 0 || TextItemsFound != 0 || TextItemsTransferred != 0)
|
||||
{
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Walker"),
|
||||
Name, BoolToNot(InventoryWalkerRunning), TextItemsFound);
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Transfer"),
|
||||
Name, BoolToNot(QueueRunnerRunning), TextItemsTransferred, TextItemErrors);
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Queue"),
|
||||
Name, PendingDownloads.Count, CurrentDownloads.Count);
|
||||
}
|
||||
return sbResult.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public BackupCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "backup";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Backup.Description") + " " + String.Format(bot.Localization.clResourceManager.getText("Commands.Backup.Usage"), Name);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} backing up all inventory.", DateTime.Now.ToString(), Client));
|
||||
|
||||
StringBuilder sbResult = new StringBuilder();
|
||||
|
||||
if (args.Length == 1 && args[0] == "status")
|
||||
{
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
else if (args.Length == 1 && args[0] == "abort")
|
||||
{
|
||||
if (!BackgroundBackupRunning)
|
||||
return BackgroundBackupStatus;
|
||||
|
||||
BackupWorker.CancelAsync();
|
||||
QueueWorker.CancelAsync();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
// check status
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
else if (args.Length != 2)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Backup.Usage"), Name);
|
||||
}
|
||||
else if (BackgroundBackupRunning)
|
||||
{
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
|
||||
QueueWorker = new BackgroundWorker();
|
||||
QueueWorker.WorkerSupportsCancellation = true;
|
||||
QueueWorker.DoWork += new DoWorkEventHandler(bwQueueRunner_DoWork);
|
||||
QueueWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwQueueRunner_RunWorkerCompleted);
|
||||
|
||||
QueueWorker.RunWorkerAsync();
|
||||
|
||||
BackupWorker = new BackgroundWorker();
|
||||
BackupWorker.WorkerSupportsCancellation = true;
|
||||
BackupWorker.DoWork += new DoWorkEventHandler(bwBackup_DoWork);
|
||||
BackupWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBackup_RunWorkerCompleted);
|
||||
|
||||
BackupWorker.RunWorkerAsync(args);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Backup.Started");
|
||||
}
|
||||
|
||||
void bwQueueRunner_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
QueueWorker = null;
|
||||
bot.Console.WriteLine(BackgroundBackupStatus);
|
||||
}
|
||||
|
||||
void bwQueueRunner_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
TextItemErrors = TextItemsTransferred = 0;
|
||||
|
||||
while (QueueWorker.CancellationPending == false)
|
||||
{
|
||||
// have any timed out?
|
||||
if (CurrentDownloads.Count > 0)
|
||||
{
|
||||
lock (CurrentDownloads)
|
||||
{
|
||||
foreach (QueuedDownloadInfo qdi in CurrentDownloads)
|
||||
{
|
||||
if ((qdi.WhenRequested + TimeSpan.FromSeconds(60)) < DateTime.Now)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Timeout"), Name, qdi.AssetID.ToString());
|
||||
// submit request again
|
||||
if (qdi.Type == AssetType.Notecard || qdi.Type == AssetType.LSLText || qdi.Type == AssetType.Texture)
|
||||
{
|
||||
if (qdi.Type == AssetType.Texture)
|
||||
{
|
||||
Client.Assets.RequestImage(qdi.AssetID, Assets_OnImageReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Assets.RequestInventoryAsset(
|
||||
qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Assets.RequestAsset(qdi.AssetID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
}
|
||||
qdi.WhenRequested = DateTime.Now;
|
||||
qdi.IsRequested = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PendingDownloads.Count != 0)
|
||||
{
|
||||
// room in the server queue?
|
||||
if (CurrentDownloads.Count < MAX_TRANSFERS)
|
||||
{
|
||||
// yes
|
||||
QueuedDownloadInfo qdi = PendingDownloads.Dequeue();
|
||||
qdi.WhenRequested = DateTime.Now;
|
||||
qdi.IsRequested = true;
|
||||
if (qdi.Type == AssetType.Notecard || qdi.Type == AssetType.LSLText || qdi.Type == AssetType.Texture)
|
||||
{
|
||||
if (qdi.Type == AssetType.Texture)
|
||||
{
|
||||
Client.Assets.RequestImage(qdi.AssetID, Assets_OnImageReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Assets.RequestInventoryAsset(
|
||||
qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Assets.RequestAsset(qdi.AssetID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
}
|
||||
|
||||
lock (CurrentDownloads)
|
||||
CurrentDownloads.Add(qdi);
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentDownloads.Count == 0 && PendingDownloads.Count == 0 && BackupWorker == null)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.AllDone"), Name);
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void bwBackup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.WalkingDone"), Name);
|
||||
BackupWorker = null;
|
||||
}
|
||||
|
||||
private void bwBackup_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
string[] args;
|
||||
|
||||
TextItemsFound = 0;
|
||||
|
||||
args = (string[])e.Argument;
|
||||
|
||||
lock (CurrentDownloads)
|
||||
CurrentDownloads.Clear();
|
||||
|
||||
// FIXME:
|
||||
//Client.Inventory.RequestFolderContents(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID,
|
||||
// true, true, false, InventorySortOrder.ByName);
|
||||
|
||||
DirectoryInfo di = new DirectoryInfo(args[1]);
|
||||
|
||||
// recurse on the root folder into the entire inventory
|
||||
BackupFolder(Client.Inventory.Store.RootNode, di.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BackupFolder - recurse through the inventory nodes sending scripts and notecards to the transfer queue
|
||||
/// </summary>
|
||||
/// <param name="folder">The current leaf in the inventory tree</param>
|
||||
/// <param name="sPathSoFar">path so far, in the form @"c:\here" -- this needs to be "clean" for the current filesystem</param>
|
||||
private void BackupFolder(InventoryNode folder, string sPathSoFar)
|
||||
{
|
||||
StringBuilder sbRequests = new StringBuilder();
|
||||
|
||||
// FIXME:
|
||||
//Client.Inventory.RequestFolderContents(folder.Data.UUID, Client.Self.AgentID, true, true, false,
|
||||
// InventorySortOrder.ByName);
|
||||
|
||||
// first scan this folder for text
|
||||
foreach (InventoryNode iNode in folder.Nodes.Values)
|
||||
{
|
||||
if (BackupWorker.CancellationPending)
|
||||
return;
|
||||
if (iNode.Data is OpenMetaverse.InventoryItem)
|
||||
{
|
||||
InventoryItem ii = iNode.Data as InventoryItem;
|
||||
|
||||
string sExtension;
|
||||
string sPath;
|
||||
|
||||
switch (ii.AssetType)
|
||||
{
|
||||
case AssetType.Animation:
|
||||
sExtension = ".animatn";
|
||||
break;
|
||||
case AssetType.Bodypart:
|
||||
sExtension = ".bodypart";
|
||||
break;
|
||||
case AssetType.CallingCard:
|
||||
continue; // They really don't exist. Are not backable.
|
||||
case AssetType.Clothing:
|
||||
sExtension = ".clothing";
|
||||
break;
|
||||
case AssetType.Folder:
|
||||
continue;
|
||||
case AssetType.Gesture:
|
||||
sExtension = ".gesture";
|
||||
break;
|
||||
case AssetType.ImageJPEG:
|
||||
sExtension = ".jpg";
|
||||
break;
|
||||
case AssetType.ImageTGA:
|
||||
sExtension = ".tga";
|
||||
break;
|
||||
case AssetType.Landmark:
|
||||
sExtension = ".landmark";
|
||||
break;
|
||||
case AssetType.LostAndFoundFolder:
|
||||
continue;
|
||||
case AssetType.LSLBytecode:
|
||||
sExtension = ".lso";
|
||||
break;
|
||||
case AssetType.LSLText:
|
||||
if ((ii.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.None || (ii.Permissions.OwnerMask & PermissionMask.Modify) == PermissionMask.None)
|
||||
{
|
||||
continue; // Nocopy scripts are not readable (SecondLife Jira VWR-5238). Nomod scripts will never be.
|
||||
}
|
||||
else
|
||||
{
|
||||
sExtension = ".lsl";
|
||||
break;
|
||||
}
|
||||
case AssetType.Notecard:
|
||||
if ((ii.Permissions.OwnerMask & PermissionMask.Copy) == PermissionMask.None)
|
||||
{
|
||||
continue; // Nocopy notecards are not readable (SecondLife Jira VWR-5238)
|
||||
}
|
||||
else
|
||||
{
|
||||
sExtension = ".notecard";
|
||||
break;
|
||||
}
|
||||
case AssetType.Object:
|
||||
/*sExtension=".object";
|
||||
break;*/
|
||||
continue; // They cannot be copied from the inventory, they must be rezzed
|
||||
case AssetType.RootFolder:
|
||||
continue;
|
||||
case AssetType.Simstate:
|
||||
sExtension = ".simstate";
|
||||
break;
|
||||
case AssetType.SnapshotFolder:
|
||||
continue;
|
||||
case AssetType.Sound:
|
||||
sExtension = ".ogg";
|
||||
break;
|
||||
case AssetType.SoundWAV:
|
||||
sExtension = ".wav";
|
||||
break;
|
||||
case AssetType.Texture:
|
||||
sExtension = ".jp2";
|
||||
break;
|
||||
case AssetType.TextureTGA:
|
||||
sExtension = ".tga";
|
||||
break;
|
||||
case AssetType.TrashFolder:
|
||||
continue;
|
||||
case AssetType.Unknown:
|
||||
default:
|
||||
sExtension = ".unk";
|
||||
break;
|
||||
}
|
||||
|
||||
// make the output file
|
||||
sPath = sPathSoFar + @"\" + MakeValid(ii.Name.Trim()) + sExtension;
|
||||
|
||||
// create the new qdi
|
||||
QueuedDownloadInfo qdi = new QueuedDownloadInfo(sPath, ii.AssetUUID, iNode.Data.UUID, UUID.Zero,
|
||||
Client.Self.AgentID, ii.AssetType);
|
||||
|
||||
// add it to the queue
|
||||
lock (PendingDownloads)
|
||||
{
|
||||
TextItemsFound++;
|
||||
PendingDownloads.Enqueue(qdi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now run any subfolders
|
||||
foreach (InventoryNode i in folder.Nodes.Values)
|
||||
{
|
||||
if (BackupWorker.CancellationPending)
|
||||
return;
|
||||
else if (i.Data is OpenMetaverse.InventoryFolder)
|
||||
BackupFolder(i, sPathSoFar + @"\" + MakeValid(i.Data.Name.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
private string MakeValid(string path)
|
||||
{
|
||||
string FinalName;
|
||||
|
||||
//FinalName = path.Replace(" ", "_"); // This is not needed for exporting the inventory
|
||||
FinalName = path.Replace(":", ";");
|
||||
FinalName = FinalName.Replace("*", "+");
|
||||
FinalName = FinalName.Replace("|", "I");
|
||||
FinalName = FinalName.Replace("\\", "[");
|
||||
FinalName = FinalName.Replace("/", "]");
|
||||
FinalName = FinalName.Replace("?", "¿");
|
||||
FinalName = FinalName.Replace(">", "}");
|
||||
FinalName = FinalName.Replace("<", "{");
|
||||
FinalName = FinalName.Replace("\"", "'");
|
||||
FinalName = FinalName.Replace("\n", " ");
|
||||
|
||||
return FinalName;
|
||||
}
|
||||
|
||||
private void Assets_OnAssetReceived(AssetDownload asset, Asset blah)
|
||||
{
|
||||
lock (CurrentDownloads)
|
||||
{
|
||||
// see if we have this in our transfer list
|
||||
QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q)
|
||||
{
|
||||
return q.AssetID == asset.AssetID;
|
||||
});
|
||||
|
||||
if (r != null && r.AssetID == asset.AssetID)
|
||||
{
|
||||
if (asset.Success)
|
||||
{
|
||||
// create the directory to put this in
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(r.FileName));
|
||||
|
||||
// write out the file
|
||||
File.WriteAllBytes(r.FileName, asset.AssetData);
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Wrote"), Name, r.FileName);
|
||||
TextItemsTransferred++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextItemErrors++;
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Failed"), Name, r.FileName,
|
||||
r.AssetID.ToString(), asset.Status.ToString());
|
||||
}
|
||||
|
||||
// remove the entry
|
||||
CurrentDownloads.Remove(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns blank or "not" if false
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
private static string BoolToNot(bool b)
|
||||
{
|
||||
return b ? String.Empty : bot.Localization.clResourceManager.getText("Commands.Backup.Not");
|
||||
}
|
||||
|
||||
private void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset)
|
||||
{
|
||||
lock (CurrentDownloads)
|
||||
{
|
||||
// see if we have this in our transfer list
|
||||
QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q)
|
||||
{
|
||||
return q.AssetID == asset.AssetID;
|
||||
});
|
||||
|
||||
if (r != null && r.AssetID == asset.AssetID)
|
||||
{
|
||||
if (asset != null/* && asset.Decode()*/)
|
||||
{
|
||||
// create the directory to put this in
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(r.FileName));
|
||||
|
||||
// write out the file
|
||||
File.WriteAllBytes(r.FileName, asset.AssetData);
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Wrote"), Name, r.FileName);
|
||||
|
||||
// This, even being a desiderable feature, timeouts the bot and it gets ejected from SL.
|
||||
/*File.WriteAllBytes(r.FileName.Substring(0, r.FileName.Length - 4) + ".tga", asset.Image.ExportTGA());
|
||||
bot.Console.WriteLine("Wrote " + r.FileName.Substring(0, r.FileName.Length - 4) + ".tga");
|
||||
Logger.DebugLog(Name + " Wrote: " + r.FileName.Substring(0, r.FileName.Length - 4) + ".tga", Client);*/
|
||||
TextItemsTransferred++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextItemErrors++;
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Failed"), Name, r.FileName,
|
||||
r.AssetID.ToString(), bot.Localization.clResourceManager.getText("Commands.Backup.Unknown"));
|
||||
}
|
||||
|
||||
// remove the entry
|
||||
CurrentDownloads.Remove(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
370
SLBot/bot/Commands/Inventory/BackupTextCommand.cs
Normal file
370
SLBot/bot/Commands/Inventory/BackupTextCommand.cs
Normal file
@@ -0,0 +1,370 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BackupTextCommand.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.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class BackupTextCommand : Command
|
||||
{
|
||||
private BackgroundWorker BackupWorker;
|
||||
private List<QueuedDownloadInfo> CurrentDownloads = new List<QueuedDownloadInfo>(10);
|
||||
private const int MAX_TRANSFERS = 10;
|
||||
private Queue<QueuedDownloadInfo> PendingDownloads = new Queue<QueuedDownloadInfo>();
|
||||
private BackgroundWorker QueueWorker;
|
||||
private int TextItemErrors;
|
||||
private int TextItemsFound;
|
||||
private int TextItemsTransferred;
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// true if either of the background threads is running
|
||||
/// </summary>
|
||||
private bool BackgroundBackupRunning
|
||||
{
|
||||
get { return InventoryWalkerRunning || QueueRunnerRunning; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the thread walking inventory is running
|
||||
/// </summary>
|
||||
private bool InventoryWalkerRunning
|
||||
{
|
||||
get { return BackupWorker != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// true if the thread feeding the queue to the server is running
|
||||
/// </summary>
|
||||
private bool QueueRunnerRunning
|
||||
{
|
||||
get { return QueueWorker != null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a string summarizing activity
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string BackgroundBackupStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder sbResult = new StringBuilder();
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Running"), Name, BoolToNot(BackgroundBackupRunning));
|
||||
if (TextItemErrors != 0 || TextItemsFound != 0 || TextItemsTransferred != 0)
|
||||
{
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Walker"),
|
||||
Name, BoolToNot(InventoryWalkerRunning), TextItemsFound);
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Transfer"),
|
||||
Name, BoolToNot(QueueRunnerRunning), TextItemsTransferred, TextItemErrors);
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Backup.Queue"),
|
||||
Name, PendingDownloads.Count, CurrentDownloads.Count);
|
||||
}
|
||||
return sbResult.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
public BackupTextCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "backuptext";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.BackupText.Description") + " " + String.Format(bot.Localization.clResourceManager.getText("Commands.Backup.Usage"), Name);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} backing up all text.", DateTime.Now.ToString(), Client));
|
||||
|
||||
StringBuilder sbResult = new StringBuilder();
|
||||
|
||||
if (args.Length == 1 && args[0] == "status")
|
||||
{
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
else if (args.Length == 1 && args[0] == "abort")
|
||||
{
|
||||
if (!BackgroundBackupRunning)
|
||||
return BackgroundBackupStatus;
|
||||
|
||||
BackupWorker.CancelAsync();
|
||||
QueueWorker.CancelAsync();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
// check status
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
else if (args.Length != 2)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Backup.Usage"), Name);
|
||||
}
|
||||
else if (BackgroundBackupRunning)
|
||||
{
|
||||
return BackgroundBackupStatus;
|
||||
}
|
||||
|
||||
QueueWorker = new BackgroundWorker();
|
||||
QueueWorker.WorkerSupportsCancellation = true;
|
||||
QueueWorker.DoWork += new DoWorkEventHandler(bwQueueRunner_DoWork);
|
||||
QueueWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwQueueRunner_RunWorkerCompleted);
|
||||
|
||||
QueueWorker.RunWorkerAsync();
|
||||
|
||||
BackupWorker = new BackgroundWorker();
|
||||
BackupWorker.WorkerSupportsCancellation = true;
|
||||
BackupWorker.DoWork += new DoWorkEventHandler(bwBackup_DoWork);
|
||||
BackupWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwBackup_RunWorkerCompleted);
|
||||
|
||||
BackupWorker.RunWorkerAsync(args);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Backup.Started");
|
||||
}
|
||||
|
||||
void bwQueueRunner_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
QueueWorker = null;
|
||||
bot.Console.WriteLine(BackgroundBackupStatus);
|
||||
}
|
||||
|
||||
void bwQueueRunner_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
TextItemErrors = TextItemsTransferred = 0;
|
||||
|
||||
while (QueueWorker.CancellationPending == false)
|
||||
{
|
||||
// have any timed out?
|
||||
if (CurrentDownloads.Count > 0)
|
||||
{
|
||||
foreach (QueuedDownloadInfo qdi in CurrentDownloads)
|
||||
{
|
||||
if ((qdi.WhenRequested + TimeSpan.FromSeconds(60)) < DateTime.Now)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Timeout"), Name, qdi.AssetID.ToString());
|
||||
// submit request again
|
||||
Client.Assets.RequestInventoryAsset(
|
||||
qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
qdi.WhenRequested = DateTime.Now;
|
||||
qdi.IsRequested = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PendingDownloads.Count != 0)
|
||||
{
|
||||
// room in the server queue?
|
||||
if (CurrentDownloads.Count < MAX_TRANSFERS)
|
||||
{
|
||||
// yes
|
||||
QueuedDownloadInfo qdi = PendingDownloads.Dequeue();
|
||||
qdi.WhenRequested = DateTime.Now;
|
||||
qdi.IsRequested = true;
|
||||
Client.Assets.RequestInventoryAsset(
|
||||
qdi.AssetID, qdi.ItemID, qdi.TaskID, qdi.OwnerID, qdi.Type, true, Assets_OnAssetReceived);
|
||||
|
||||
lock (CurrentDownloads)
|
||||
CurrentDownloads.Add(qdi);
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentDownloads.Count == 0 && PendingDownloads.Count == 0 && BackupWorker == null)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.AllDone"), Name);
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void bwBackup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.WalkingDone"), Name);
|
||||
BackupWorker = null;
|
||||
}
|
||||
|
||||
private void bwBackup_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
string[] args;
|
||||
|
||||
TextItemsFound = 0;
|
||||
|
||||
args = (string[])e.Argument;
|
||||
|
||||
lock (CurrentDownloads)
|
||||
CurrentDownloads.Clear();
|
||||
|
||||
// FIXME:
|
||||
//Client.Inventory.RequestFolderContents(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID,
|
||||
// true, true, false, InventorySortOrder.ByName);
|
||||
|
||||
DirectoryInfo di = new DirectoryInfo(args[1]);
|
||||
|
||||
// recurse on the root folder into the entire inventory
|
||||
BackupFolder(Client.Inventory.Store.RootNode, di.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BackupFolder - recurse through the inventory nodes sending scripts and notecards to the transfer queue
|
||||
/// </summary>
|
||||
/// <param name="folder">The current leaf in the inventory tree</param>
|
||||
/// <param name="sPathSoFar">path so far, in the form @"c:\here" -- this needs to be "clean" for the current filesystem</param>
|
||||
private void BackupFolder(InventoryNode folder, string sPathSoFar)
|
||||
{
|
||||
StringBuilder sbRequests = new StringBuilder();
|
||||
|
||||
// FIXME:
|
||||
//Client.Inventory.RequestFolderContents(folder.Data.UUID, Client.Self.AgentID, true, true, false,
|
||||
// InventorySortOrder.ByName);
|
||||
|
||||
// first scan this folder for text
|
||||
foreach (InventoryNode iNode in folder.Nodes.Values)
|
||||
{
|
||||
if (BackupWorker.CancellationPending)
|
||||
return;
|
||||
if (iNode.Data is OpenMetaverse.InventoryItem)
|
||||
{
|
||||
InventoryItem ii = iNode.Data as InventoryItem;
|
||||
if (ii.AssetType == AssetType.LSLText || ii.AssetType == AssetType.Notecard)
|
||||
{
|
||||
// check permissions on scripts
|
||||
if (ii.AssetType == AssetType.LSLText)
|
||||
{
|
||||
if ((ii.Permissions.OwnerMask & PermissionMask.Modify) == PermissionMask.None)
|
||||
{
|
||||
// skip this one
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
string sExtension = (ii.AssetType == AssetType.LSLText) ? ".lsl" : ".txt";
|
||||
// make the output file
|
||||
string sPath = sPathSoFar + @"\" + MakeValid(ii.Name.Trim()) + sExtension;
|
||||
|
||||
// create the new qdi
|
||||
QueuedDownloadInfo qdi = new QueuedDownloadInfo(sPath, ii.AssetUUID, iNode.Data.UUID, UUID.Zero,
|
||||
Client.Self.AgentID, ii.AssetType);
|
||||
|
||||
// add it to the queue
|
||||
lock (PendingDownloads)
|
||||
{
|
||||
TextItemsFound++;
|
||||
PendingDownloads.Enqueue(qdi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now run any subfolders
|
||||
foreach (InventoryNode i in folder.Nodes.Values)
|
||||
{
|
||||
if (BackupWorker.CancellationPending)
|
||||
return;
|
||||
else if (i.Data is OpenMetaverse.InventoryFolder)
|
||||
BackupFolder(i, sPathSoFar + @"\" + MakeValid(i.Data.Name.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
private string MakeValid(string path)
|
||||
{
|
||||
string FinalName;
|
||||
|
||||
FinalName = path.Replace(" ", "_");
|
||||
FinalName = FinalName.Replace(":", ";");
|
||||
FinalName = FinalName.Replace("*", "+");
|
||||
FinalName = FinalName.Replace("|", "I");
|
||||
FinalName = FinalName.Replace("\\", "[");
|
||||
FinalName = FinalName.Replace("/", "]");
|
||||
FinalName = FinalName.Replace("?", "¿");
|
||||
FinalName = FinalName.Replace(">", "}");
|
||||
FinalName = FinalName.Replace("<", "{");
|
||||
FinalName = FinalName.Replace("\"", "'");
|
||||
FinalName = FinalName.Replace("\n", " ");
|
||||
|
||||
return FinalName;
|
||||
}
|
||||
|
||||
private void Assets_OnAssetReceived(AssetDownload asset, Asset blah)
|
||||
{
|
||||
lock (CurrentDownloads)
|
||||
{
|
||||
// see if we have this in our transfer list
|
||||
QueuedDownloadInfo r = CurrentDownloads.Find(delegate(QueuedDownloadInfo q)
|
||||
{
|
||||
return q.AssetID == asset.AssetID;
|
||||
});
|
||||
|
||||
if (r != null && r.AssetID == asset.AssetID)
|
||||
{
|
||||
if (asset.Success)
|
||||
{
|
||||
// create the directory to put this in
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(r.FileName));
|
||||
|
||||
// write out the file
|
||||
File.WriteAllBytes(r.FileName, asset.AssetData);
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Wrote"), Name, r.FileName);
|
||||
TextItemsTransferred++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextItemErrors++;
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Backup.Failed"), Name, r.FileName,
|
||||
r.AssetID.ToString(), asset.Status.ToString());
|
||||
}
|
||||
|
||||
// remove the entry
|
||||
CurrentDownloads.Remove(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns blank or "not" if false
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
private static string BoolToNot(bool b)
|
||||
{
|
||||
return b ? String.Empty : bot.Localization.clResourceManager.getText("Commands.Backup.Not");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
122
SLBot/bot/Commands/Inventory/ChangeDirectoryCommand.cs
Normal file
122
SLBot/bot/Commands/Inventory/ChangeDirectoryCommand.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ChangeDirectoryCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
public class ChangeDirectoryCommand : Command
|
||||
{
|
||||
private InventoryManager Manager;
|
||||
private OpenMetaverse.Inventory Inventory;
|
||||
|
||||
public ChangeDirectoryCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "cd";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Client.Inventory.Store;
|
||||
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.Usage");
|
||||
string pathStr = "";
|
||||
string[] path = null;
|
||||
if (args.Length == 0)
|
||||
{
|
||||
path = new string[] { "" };
|
||||
// cd without any arguments doesn't do anything.
|
||||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
pathStr = args[0];
|
||||
path = pathStr.Split(new char[] { '/' });
|
||||
// Use '/' as a path seperator.
|
||||
}
|
||||
InventoryFolder currentFolder = Client.CurrentDirectory;
|
||||
if (pathStr.StartsWith("/"))
|
||||
currentFolder = Inventory.RootFolder;
|
||||
|
||||
if (currentFolder == null) // We need this to be set to something.
|
||||
//return "Error: Sesi<73>n no iniciada.";
|
||||
currentFolder = Inventory.RootFolder;
|
||||
|
||||
// Traverse the path, looking for the
|
||||
for (int i = 0; i < path.Length; ++i)
|
||||
{
|
||||
string nextName = path[i];
|
||||
if (string.IsNullOrEmpty(nextName) || nextName == ".")
|
||||
continue; // Ignore '.' and blanks, stay in the current directory.
|
||||
if (nextName == ".." && currentFolder != Inventory.RootFolder)
|
||||
{
|
||||
// If we encounter .., move to the parent folder.
|
||||
currentFolder = Inventory[currentFolder.ParentUUID] as InventoryFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<InventoryBase> currentContents = Inventory.GetContents(currentFolder);
|
||||
// Try and find an InventoryBase with the corresponding name.
|
||||
bool found = false;
|
||||
foreach (InventoryBase item in currentContents)
|
||||
{
|
||||
// Allow lookup by UUID as well as name:
|
||||
if (item.Name == nextName || item.UUID.ToString() == nextName)
|
||||
{
|
||||
found = true;
|
||||
if (item is InventoryFolder)
|
||||
{
|
||||
currentFolder = item as InventoryFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.NotFolder"), item.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.NotFound"), nextName, currentFolder.Name);
|
||||
}
|
||||
}
|
||||
Client.CurrentDirectory = currentFolder;
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.ChangeDirectory.CurrentFolder"), currentFolder.Name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
504
SLBot/bot/Commands/Inventory/CreateClothingCommand.cs
Normal file
504
SLBot/bot/Commands/Inventory/CreateClothingCommand.cs
Normal file
@@ -0,0 +1,504 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CreateClothingCommand.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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class CreateClothingCommand : Command
|
||||
{
|
||||
public CreateClothingCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "createclothing";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CreateClothing.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CreateClothing.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string LongUsage = bot.Localization.clResourceManager.getText("Commands.CreateClothing.UsageLine1") + System.Environment.NewLine +
|
||||
bot.Localization.clResourceManager.getText("Commands.CreateClothing.UsageLine2");
|
||||
string finalmessage = "";
|
||||
string NL = "\n";
|
||||
WearableType wtype;
|
||||
UUID uuid1, uuid2;
|
||||
uuid2 = UUID.Zero;
|
||||
|
||||
if (args.Length == 0)
|
||||
return Description;
|
||||
if (args.Length == 1)
|
||||
if (args[0].ToLower() == "help")
|
||||
return LongUsage;
|
||||
else
|
||||
return Description;
|
||||
if (args.Length != 3 && args.Length != 4)
|
||||
return Description;
|
||||
|
||||
switch (args[1].ToLower())
|
||||
{
|
||||
case "gloves":
|
||||
wtype = WearableType.Gloves;
|
||||
break;
|
||||
case "jacket":
|
||||
wtype = WearableType.Jacket;
|
||||
if (args.Length != 4)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateClothing.Jacket");
|
||||
break;
|
||||
case "pants":
|
||||
wtype = WearableType.Pants;
|
||||
break;
|
||||
case "shirt":
|
||||
wtype = WearableType.Shirt;
|
||||
break;
|
||||
case "shoes":
|
||||
wtype = WearableType.Shoes;
|
||||
break;
|
||||
case "skirt":
|
||||
wtype = WearableType.Skirt;
|
||||
break;
|
||||
case "socks":
|
||||
wtype = WearableType.Socks;
|
||||
break;
|
||||
case "underpants":
|
||||
wtype = WearableType.Underpants;
|
||||
break;
|
||||
case "undershirt":
|
||||
wtype = WearableType.Undershirt;
|
||||
break;
|
||||
default:
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateClothing.Incorrect");
|
||||
}
|
||||
|
||||
if (!UUID.TryParse(args[2], out uuid1))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateClothing.ExpectedID1");
|
||||
|
||||
if (args.Length == 4)
|
||||
if (!UUID.TryParse(args[3], out uuid2))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateClothing.ExpectedID2");
|
||||
|
||||
if (args[1].ToLower() == "jacket")
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} creating clothing of type {2} named {3} with uuid {4} {5}.", DateTime.Now.ToString(), Client, args[1], args[0], args[2], args[3]));
|
||||
else
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} creating clothing of type {2} named {3} with uuid {4}.", DateTime.Now.ToString(), Client, args[1], args[0], args[2]));
|
||||
|
||||
#region Part common to all wearable types
|
||||
StringBuilder sbcloth = new StringBuilder("LLWearable version 22\n");
|
||||
sbcloth.Append(args[0]);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\tpermissions 0\n\t{\n");
|
||||
sbcloth.Append("\t\tbase_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\teveryone_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tnext_owner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tcreator_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tlast_owner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_id\t");
|
||||
sbcloth.Append(UUID.Zero.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
sbcloth.Append("\tsale_info\t0\n");
|
||||
sbcloth.Append("\t{\n");
|
||||
sbcloth.Append("\t\tsale_type\t");
|
||||
sbcloth.Append("not");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tsale_price\t");
|
||||
sbcloth.Append("0");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
#endregion #region Part common to all wearable types
|
||||
|
||||
sbcloth.Append("type ");
|
||||
sbcloth.Append((int)wtype);
|
||||
sbcloth.Append(NL);
|
||||
|
||||
switch (wtype)
|
||||
{
|
||||
case WearableType.Gloves:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(5);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("93 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("827 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("829 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("830 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("844 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("15 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Jacket:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(9);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("606 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("607 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("608 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("609 ");
|
||||
sbcloth.Append(".2");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("780 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("834 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("835 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("836 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("877 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(2);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("13 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("14 ");
|
||||
sbcloth.Append(uuid2.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Pants:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(9);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("625 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("638 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("806 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("807 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("808 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("814 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("815 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("816 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("869 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("2 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Shirt:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(10);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("781 ");
|
||||
sbcloth.Append(".78");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("800 ");
|
||||
sbcloth.Append(".89");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("801 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("802 ");
|
||||
sbcloth.Append(".78");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("803 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("804 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("805 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("828 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("840 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("868 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("1 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Shoes:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(10);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("198 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("503 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("508 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("513 ");
|
||||
sbcloth.Append(".5");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("514 ");
|
||||
sbcloth.Append(".5");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("616 ");
|
||||
sbcloth.Append(".1");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("654 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("812 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("813 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("817 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("7 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Skirt:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(10);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("848 ");
|
||||
sbcloth.Append(".2");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("858 ");
|
||||
sbcloth.Append(".4");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("859 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("860 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("861 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("862 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("863 ");
|
||||
sbcloth.Append(".33");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("921 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("922 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("923 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("18 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Socks:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(4);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("617 ");
|
||||
sbcloth.Append(".35");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("818 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("819 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("820 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("12 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Underpants:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(5);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("619 ");
|
||||
sbcloth.Append(".3");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("624 ");
|
||||
sbcloth.Append(".8");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("824 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("825 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("826 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("17 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
case WearableType.Undershirt:
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(7);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("603 ");
|
||||
sbcloth.Append(".4");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("604 ");
|
||||
sbcloth.Append(".85");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("605 ");
|
||||
sbcloth.Append(".84");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("779 ");
|
||||
sbcloth.Append(".84");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("821 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("822 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("823 ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("16 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
break;
|
||||
}
|
||||
|
||||
AssetClothing clothing = new AssetClothing(sbcloth.ToString());
|
||||
|
||||
clothing.Decode();
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(clothing.AssetData, args[0], String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreatedBy"), args[0], DateTime.Now), AssetType.Clothing,
|
||||
InventoryType.Wearable, Client.Inventory.FindFolderForType(AssetType.Clothing),
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateClothing.Created"), assetID);
|
||||
Client.Inventory.GiveItem(itemID, args[0], AssetType.Clothing, Client.MasterKey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateClothing.Failed"), status);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return finalmessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
156
SLBot/bot/Commands/Inventory/CreateEyesCommand.cs
Normal file
156
SLBot/bot/Commands/Inventory/CreateEyesCommand.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CreateEyesCommand.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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class CreateEyesCommand : Command
|
||||
{
|
||||
public CreateEyesCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "createeyes";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CreateEyes.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CreateEyes.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string finalmessage = "";
|
||||
string NL = "\n";
|
||||
UUID uuid1;
|
||||
uuid1 = UUID.Zero;
|
||||
|
||||
if (args.Length != 2)
|
||||
return Description;
|
||||
|
||||
if (!UUID.TryParse(args[1], out uuid1))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateEyes.ExpectedID");
|
||||
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} creating eyes named {2} with uuid {3}.", DateTime.Now.ToString(), Client, args[0], args[1]));
|
||||
|
||||
#region Part common to all wearable types
|
||||
StringBuilder sbcloth = new StringBuilder("LLWearable version 22\n");
|
||||
sbcloth.Append(args[0]);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\tpermissions 0\n\t{\n");
|
||||
sbcloth.Append("\t\tbase_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\teveryone_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tnext_owner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tcreator_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tlast_owner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_id\t");
|
||||
sbcloth.Append(UUID.Zero.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
sbcloth.Append("\tsale_info\t0\n");
|
||||
sbcloth.Append("\t{\n");
|
||||
sbcloth.Append("\t\tsale_type\t");
|
||||
sbcloth.Append("not");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tsale_price\t");
|
||||
sbcloth.Append("0");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
#endregion #region Part common to all wearable types
|
||||
|
||||
sbcloth.Append("type ");
|
||||
sbcloth.Append((int)WearableType.Eyes);
|
||||
sbcloth.Append(NL);
|
||||
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(2);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("98 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("99 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(1);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("3 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
|
||||
AssetBodypart bodypart = new AssetBodypart(sbcloth.ToString());
|
||||
|
||||
|
||||
bodypart.Decode();
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(bodypart.AssetData, args[0], String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreatedBy"), args[0], DateTime.Now), AssetType.Bodypart,
|
||||
InventoryType.Wearable, Client.Inventory.FindFolderForType(AssetType.Bodypart),
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateEyes.Created"), assetID);
|
||||
Client.Inventory.GiveItem(itemID, args[0], AssetType.Bodypart, Client.MasterKey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateEyes.Failed"), status);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return finalmessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
SLBot/bot/Commands/Inventory/CreateLandMarkCommand.cs
Normal file
81
SLBot/bot/Commands/Inventory/CreateLandMarkCommand.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CreateLandMarkCommand.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
|
||||
****************************************************************************/
|
||||
// Does not work, HTTP error 400.
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class CreateLandMarkCommand : Command
|
||||
{
|
||||
public CreateLandMarkCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "createlm";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CreateLandMark.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string finalmessage = "";
|
||||
|
||||
AssetLandmark landmark = new AssetLandmark(this.Client.Network.CurrentSim.RegionID, this.Client.Self.SimPosition);
|
||||
|
||||
landmark.Encode();
|
||||
landmark.Decode();
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(landmark.AssetData, this.Client.Network.CurrentSim.Name, String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreatedBy"), this.Client.Network.CurrentSim.Name, DateTime.Now), AssetType.Landmark,
|
||||
InventoryType.Landmark, Client.Inventory.FindFolderForType(AssetType.Landmark),
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateLandMark.Created"), assetID);
|
||||
Client.Inventory.GiveItem(itemID, this.Client.Network.CurrentSim.Name, AssetType.Clothing, Client.MasterKey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateLandMark.Failed"), status);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return finalmessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
233
SLBot/bot/Commands/Inventory/CreateNotecardCommand.cs
Normal file
233
SLBot/bot/Commands/Inventory/CreateNotecardCommand.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CreateNotecardCommand.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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class CreateNotecardCommand : Command
|
||||
{
|
||||
const int NOTECARD_CREATE_TIMEOUT = 2500 * 10;
|
||||
const int NOTECARD_FETCH_TIMEOUT = 1500 * 10;
|
||||
const int INVENTORY_FETCH_TIMEOUT = 1500 * 10;
|
||||
|
||||
public CreateNotecardCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "createnotecard";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
UUID embedItemID = UUID.Zero, notecardItemID = UUID.Zero, notecardAssetID = UUID.Zero;
|
||||
string filename, fileData;
|
||||
bool success = false, finalUploadSuccess = false;
|
||||
string message = String.Empty;
|
||||
AutoResetEvent notecardEvent = new AutoResetEvent(false);
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
filename = args[0];
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
filename = args[0];
|
||||
UUID.TryParse(args[1], out embedItemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Usage");
|
||||
}
|
||||
|
||||
if (!File.Exists(filename))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.NotFound"), filename);
|
||||
|
||||
try
|
||||
{
|
||||
fileData = File.ReadAllText(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.OpenFailed"), filename, ex.Message);
|
||||
}
|
||||
|
||||
#region Notecard asset data
|
||||
|
||||
AssetNotecard notecard = new AssetNotecard();
|
||||
notecard.BodyText = fileData;
|
||||
|
||||
// Item embedding
|
||||
if (embedItemID != UUID.Zero)
|
||||
{
|
||||
// Try to fetch the inventory item
|
||||
InventoryItem item = FetchItem(embedItemID);
|
||||
if (item != null)
|
||||
{
|
||||
notecard.EmbeddedItems = new List<InventoryItem> { item };
|
||||
notecard.BodyText += (char)0xdbc0 + (char)0xdc00;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.FetchFailed"), embedItemID);
|
||||
}
|
||||
}
|
||||
|
||||
notecard.Encode();
|
||||
|
||||
#endregion Notecard asset data
|
||||
|
||||
Client.Inventory.RequestCreateItem(Client.Inventory.FindFolderForType(AssetType.Notecard),
|
||||
filename, String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreatedBy"), filename, DateTime.Now), AssetType.Notecard,
|
||||
UUID.Random(), InventoryType.Notecard, PermissionMask.All,
|
||||
delegate(bool createSuccess, InventoryItem item)
|
||||
{
|
||||
if (createSuccess)
|
||||
{
|
||||
#region Upload an empty notecard asset first
|
||||
|
||||
AutoResetEvent emptyNoteEvent = new AutoResetEvent(false);
|
||||
AssetNotecard empty = new AssetNotecard();
|
||||
empty.BodyText = "\n";
|
||||
empty.Encode();
|
||||
|
||||
Client.Inventory.RequestUploadNotecardAsset(empty.AssetData, item.UUID,
|
||||
delegate(bool uploadSuccess, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
notecardItemID = itemID;
|
||||
notecardAssetID = assetID;
|
||||
success = uploadSuccess;
|
||||
message = status ?? bot.Localization.clResourceManager.getText("Commands.CreateNotecard.UnknownError");
|
||||
emptyNoteEvent.Set();
|
||||
});
|
||||
|
||||
emptyNoteEvent.WaitOne(NOTECARD_CREATE_TIMEOUT, false);
|
||||
|
||||
#endregion Upload an empty notecard asset first
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Upload the actual notecard asset
|
||||
Client.Inventory.RequestUploadNotecardAsset(notecard.AssetData, item.UUID,
|
||||
delegate(bool uploadSuccess, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
notecardItemID = itemID;
|
||||
notecardAssetID = assetID;
|
||||
finalUploadSuccess = uploadSuccess;
|
||||
message = status ?? bot.Localization.clResourceManager.getText("Commands.CreateNotecard.UnknownError");
|
||||
notecardEvent.Set();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notecardEvent.Set();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message = bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreateFail");
|
||||
notecardEvent.Set();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
notecardEvent.WaitOne(NOTECARD_CREATE_TIMEOUT, false);
|
||||
|
||||
if (finalUploadSuccess)
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Success"), notecardItemID, notecardAssetID);
|
||||
Client.Inventory.GiveItem(notecardItemID, filename, AssetType.Notecard, Client.MasterKey, false);
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Sending"));
|
||||
return DownloadNotecard(notecardItemID, notecardAssetID);
|
||||
}
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreateFailDetails"), message);
|
||||
}
|
||||
|
||||
private InventoryItem FetchItem(UUID itemID)
|
||||
{
|
||||
InventoryItem fetchItem = null;
|
||||
AutoResetEvent fetchItemEvent = new AutoResetEvent(false);
|
||||
|
||||
EventHandler<ItemReceivedEventArgs> itemReceivedCallback =
|
||||
delegate(object sender, ItemReceivedEventArgs e)
|
||||
{
|
||||
if (e.Item.UUID == itemID)
|
||||
{
|
||||
fetchItem = e.Item;
|
||||
fetchItemEvent.Set();
|
||||
}
|
||||
};
|
||||
|
||||
Client.Inventory.ItemReceived += itemReceivedCallback;
|
||||
|
||||
Client.Inventory.RequestFetchInventory(itemID, Client.Self.AgentID);
|
||||
|
||||
fetchItemEvent.WaitOne(INVENTORY_FETCH_TIMEOUT, false);
|
||||
|
||||
Client.Inventory.ItemReceived -= itemReceivedCallback;
|
||||
|
||||
return fetchItem;
|
||||
}
|
||||
|
||||
private string DownloadNotecard(UUID itemID, UUID assetID)
|
||||
{
|
||||
AutoResetEvent assetDownloadEvent = new AutoResetEvent(false);
|
||||
byte[] notecardData = null;
|
||||
string error = bot.Localization.clResourceManager.getText("Commands.CreateNotecard.Timeout");
|
||||
|
||||
Client.Assets.RequestInventoryAsset(assetID, itemID, UUID.Zero, Client.Self.AgentID, AssetType.Notecard, true,
|
||||
delegate(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
notecardData = transfer.AssetData;
|
||||
else
|
||||
error = transfer.Status.ToString();
|
||||
assetDownloadEvent.Set();
|
||||
}
|
||||
);
|
||||
|
||||
assetDownloadEvent.WaitOne(NOTECARD_FETCH_TIMEOUT, false);
|
||||
|
||||
if (notecardData != null)
|
||||
return Encoding.UTF8.GetString(notecardData);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.DownloadError"), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
240
SLBot/bot/Commands/Inventory/CreateSkinCommand.cs
Normal file
240
SLBot/bot/Commands/Inventory/CreateSkinCommand.cs
Normal file
@@ -0,0 +1,240 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CreateSkinCommand.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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class CreateSkinCommand : Command
|
||||
{
|
||||
public CreateSkinCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "createskin";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CreateSkin.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CreateSkin.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
string finalmessage = "";
|
||||
string NL = "\n";
|
||||
UUID uuid1, uuid2, uuid3;
|
||||
uuid3 = uuid2 = uuid1 = UUID.Zero;
|
||||
|
||||
if (args.Length != 4)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateSkin.Usage");
|
||||
|
||||
if (!UUID.TryParse(args[1], out uuid1))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateSkin.ExpectedFaceID");
|
||||
|
||||
if (!UUID.TryParse(args[2], out uuid2))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateSkin.ExpectedUpID");
|
||||
|
||||
if (!UUID.TryParse(args[3], out uuid3))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CreateSkin.ExpectedLowID");
|
||||
|
||||
Program.NBStats.AddStatData(String.Format("{0}: {1} creating skin named {2} with uuids {3} {4} {5}.", DateTime.Now.ToString(), Client, args[0], args[1], args[2], args[3]));
|
||||
|
||||
#region Part common to all wearable types
|
||||
StringBuilder sbcloth = new StringBuilder("LLWearable version 22\n");
|
||||
sbcloth.Append(args[0]);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\tpermissions 0\n\t{\n");
|
||||
sbcloth.Append("\t\tbase_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\teveryone_mask\t");
|
||||
sbcloth.Append("00000000");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tnext_owner_mask\t");
|
||||
sbcloth.Append("7fffffff");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tcreator_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\towner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tlast_owner_id\t");
|
||||
sbcloth.Append(Client.Self.AgentID.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tgroup_id\t");
|
||||
sbcloth.Append(UUID.Zero.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
sbcloth.Append("\tsale_info\t0\n");
|
||||
sbcloth.Append("\t{\n");
|
||||
sbcloth.Append("\t\tsale_type\t");
|
||||
sbcloth.Append("not");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t\tsale_price\t");
|
||||
sbcloth.Append("0");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("\t}\n");
|
||||
#endregion #region Part common to all wearable types
|
||||
|
||||
sbcloth.Append("type ");
|
||||
sbcloth.Append((int)WearableType.Skin);
|
||||
sbcloth.Append(NL);
|
||||
|
||||
sbcloth.Append("parameters ");
|
||||
sbcloth.Append(26);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("108 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("110 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("111 ");
|
||||
sbcloth.Append(".5");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("116 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("117 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("150 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("162 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("163 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("165 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("700 ");
|
||||
sbcloth.Append(".25");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("701 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("702 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("703 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("704 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("705 ");
|
||||
sbcloth.Append(".5");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("706 ");
|
||||
sbcloth.Append(".6");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("707 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("708 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("709 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("710 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("711 ");
|
||||
sbcloth.Append(".5");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("712 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("713 ");
|
||||
sbcloth.Append(".7");
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("714 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("715 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("775 ");
|
||||
sbcloth.Append(0);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("textures ");
|
||||
sbcloth.Append(3);
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("0 ");
|
||||
sbcloth.Append(uuid1.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("5 ");
|
||||
sbcloth.Append(uuid2.ToString());
|
||||
sbcloth.Append(NL);
|
||||
sbcloth.Append("6 ");
|
||||
sbcloth.Append(uuid3.ToString());
|
||||
sbcloth.Append(NL);
|
||||
|
||||
AssetBodypart bodypart = new AssetBodypart(sbcloth.ToString());
|
||||
|
||||
|
||||
bodypart.Decode();
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(bodypart.AssetData, args[0], String.Format(bot.Localization.clResourceManager.getText("Commands.CreateNotecard.CreatedBy"), args[0], DateTime.Now), AssetType.Bodypart,
|
||||
InventoryType.Wearable, Client.Inventory.FindFolderForType(AssetType.Bodypart),
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateSkin.Created"), assetID);
|
||||
Client.Inventory.GiveItem(itemID, args[0], AssetType.Bodypart, Client.MasterKey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalmessage = String.Format(bot.Localization.clResourceManager.getText("Commands.CreateSkin.Failed"), status);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return finalmessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
80
SLBot/bot/Commands/Inventory/DeleteFolderCommand.cs
Normal file
80
SLBot/bot/Commands/Inventory/DeleteFolderCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : DeleteCommand.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.Collections.Generic;
|
||||
|
||||
public class DeleteCommand : Command
|
||||
{
|
||||
public DeleteCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "rmdir";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.DeleteFolder.Description") + " " + bot.Localization.clResourceManager.getText("Commands.DeleteFolder.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
// parse the command line
|
||||
string target = String.Empty;
|
||||
for (int ct = 0; ct < args.Length; ct++)
|
||||
target = target + args[ct] + " ";
|
||||
target = target.TrimEnd();
|
||||
|
||||
// initialize results list
|
||||
List<InventoryBase> found = new List<InventoryBase>();
|
||||
|
||||
// find the folder
|
||||
found = Client.Inventory.LocalFind(Client.Inventory.Store.RootFolder.UUID, target.Split('/'), 0, true);
|
||||
if (found.Count.Equals(1))
|
||||
{
|
||||
// move the folder to the trash folder
|
||||
Client.Inventory.MoveFolder(found[0].UUID, Client.Inventory.FindFolderForType(AssetType.TrashFolder));
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.DeleteFolder.Deleted"), found[0].Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.DeleteFolder.NotFound"), "");
|
||||
}
|
||||
}
|
||||
return bot.Localization.clResourceManager.getText("Commands.DeleteFolder.Usage");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
55
SLBot/bot/Commands/Inventory/EmptyLostAndFoundCommand.cs
Normal file
55
SLBot/bot/Commands/Inventory/EmptyLostAndFoundCommand.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : EmptyLostAndFoundCommand.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 System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using bot;
|
||||
|
||||
class EmptyLostAndFoundCommand : Command
|
||||
{
|
||||
public EmptyLostAndFoundCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "emptylostandfound";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.EmptyLostAndFound.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
Client.Inventory.EmptyLostAndFound();
|
||||
return bot.Localization.clResourceManager.getText("Commands.EmptyLostAndFound.Done");
|
||||
}
|
||||
}
|
||||
}
|
||||
55
SLBot/bot/Commands/Inventory/EmptyTrashCommand.cs
Normal file
55
SLBot/bot/Commands/Inventory/EmptyTrashCommand.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : EmptyTrashCommand.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 System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using bot;
|
||||
|
||||
class EmptyTrashCommand : Command
|
||||
{
|
||||
public EmptyTrashCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "emptytrash";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.EmptyTrash.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
Client.Inventory.EmptyLostAndFound();
|
||||
return bot.Localization.clResourceManager.getText("Commands.EmptyTrash.Done");
|
||||
}
|
||||
}
|
||||
}
|
||||
96
SLBot/bot/Commands/Inventory/GiveItemCommand.cs
Normal file
96
SLBot/bot/Commands/Inventory/GiveItemCommand.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : GiveItemCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public class GiveItemCommand : Command
|
||||
{
|
||||
private InventoryManager Manager;
|
||||
private OpenMetaverse.Inventory Inventory;
|
||||
|
||||
public GiveItemCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "give";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.GiveItem.Description") + " " + bot.Localization.clResourceManager.getText("Commands.GiveItem.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.GiveItem.Usage");
|
||||
}
|
||||
UUID dest;
|
||||
if (!UUID.TryParse(args[0], out dest))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.GiveItem.InvalidUUID");
|
||||
}
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Manager.Store;
|
||||
string ret = "";
|
||||
string nl = "\n";
|
||||
for (int i = 1; i < args.Length; ++i)
|
||||
{
|
||||
string inventoryName = args[i];
|
||||
// WARNING: Uses local copy of inventory contents, need to download them first.
|
||||
List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
|
||||
bool found = false;
|
||||
foreach (InventoryBase b in contents)
|
||||
{
|
||||
if (inventoryName == b.Name || inventoryName == b.UUID.ToString())
|
||||
{
|
||||
found = true;
|
||||
if (b is InventoryItem)
|
||||
{
|
||||
InventoryItem item = b as InventoryItem;
|
||||
Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true);
|
||||
ret += String.Format(bot.Localization.clResourceManager.getText("Commands.GiveItem.Gave"), item.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += String.Format(bot.Localization.clResourceManager.getText("Commands.GiveItem.Folder"), b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
ret += String.Format(bot.Localization.clResourceManager.getText("Commands.GiveItem.NotFound"), inventoryName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
85
SLBot/bot/Commands/Inventory/InventoryCommand.cs
Normal file
85
SLBot/bot/Commands/Inventory/InventoryCommand.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : InventoryCommand.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;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class InventoryCommand : Command
|
||||
{
|
||||
private Inventory Inventory;
|
||||
private InventoryManager Manager;
|
||||
|
||||
public InventoryCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "i";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Inventory.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Manager.Store;
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
InventoryFolder rootFolder = Inventory.RootFolder;
|
||||
PrintFolder(rootFolder, result, 0);
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
void PrintFolder(InventoryFolder f, StringBuilder result, int indent)
|
||||
{
|
||||
List<InventoryBase> contents = Manager.FolderContents(f.UUID, Client.Self.AgentID,
|
||||
true, true, InventorySortOrder.ByName, 3000);
|
||||
|
||||
if (contents != null)
|
||||
{
|
||||
foreach (InventoryBase i in contents)
|
||||
{
|
||||
result.AppendFormat("{0}{1} ({2})\n", new String(' ', indent * 2), i.Name, i.UUID);
|
||||
if (i is InventoryFolder)
|
||||
{
|
||||
InventoryFolder folder = (InventoryFolder)i;
|
||||
PrintFolder(folder, result, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
225
SLBot/bot/Commands/Inventory/ListContentsCommand.cs
Normal file
225
SLBot/bot/Commands/Inventory/ListContentsCommand.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ListContentsCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
public class ListContentsCommand : Command
|
||||
{
|
||||
private InventoryManager Manager;
|
||||
private OpenMetaverse.Inventory Inventory;
|
||||
|
||||
public ListContentsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "ls";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ListContents.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ListContents.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.ListContents.Usage");
|
||||
bool longDisplay = false;
|
||||
if (args.Length > 0 && args[0] == "-l")
|
||||
longDisplay = true;
|
||||
|
||||
List<InventoryBase> contents;
|
||||
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Manager.Store;
|
||||
// WARNING: Uses local copy of inventory contents, need to download them first.
|
||||
if (Client.CurrentDirectory != null)
|
||||
contents = Manager.FolderContents(Client.CurrentDirectory.UUID, Inventory.RootFolder.OwnerID, true, true, InventorySortOrder.SystemFoldersToTop | InventorySortOrder.FoldersByName | InventorySortOrder.ByName, 1000);
|
||||
else
|
||||
contents = Manager.FolderContents(Inventory.RootFolder.UUID, Inventory.RootFolder.OwnerID, true, true, InventorySortOrder.SystemFoldersToTop | InventorySortOrder.FoldersByName | InventorySortOrder.ByName, 1000);
|
||||
|
||||
string displayString = "";
|
||||
string nl = "\n"; // New line character
|
||||
// Pretty simple, just print out the contents.
|
||||
if (contents != null)
|
||||
{
|
||||
foreach (InventoryBase b in contents)
|
||||
{
|
||||
if (longDisplay)
|
||||
{
|
||||
// Generate a nicely formatted description of the item.
|
||||
// It kinda looks like the output of the unix ls.
|
||||
// starts with 'd' if the inventory is a folder, '-' if not.
|
||||
// 9 character permissions string
|
||||
// UUID of object
|
||||
// Name of object
|
||||
if (b is InventoryFolder)
|
||||
{
|
||||
InventoryFolder folder = b as InventoryFolder;
|
||||
displayString += "d--------- ";
|
||||
displayString += " " + "<DIR>";
|
||||
displayString += " " + DateTime.MinValue.ToShortDateString() + " " + DateTime.MinValue.ToShortTimeString();
|
||||
displayString += folder.UUID.ToString().ToUpperInvariant();
|
||||
displayString += " " + folder.Name;
|
||||
}
|
||||
else if (b is InventoryItem)
|
||||
{
|
||||
InventoryItem item = b as InventoryItem;
|
||||
string iteminvType;
|
||||
|
||||
switch (item.AssetType)
|
||||
{
|
||||
case AssetType.Animation:
|
||||
iteminvType = "<ANM>";
|
||||
break;
|
||||
case AssetType.Bodypart:
|
||||
iteminvType = "<BDY>";
|
||||
break;
|
||||
case AssetType.CallingCard:
|
||||
iteminvType = "<CCD>";
|
||||
break;
|
||||
case AssetType.Clothing:
|
||||
iteminvType = "<CLT>";
|
||||
break;
|
||||
case AssetType.Folder:
|
||||
iteminvType = "<DIR>";
|
||||
break;
|
||||
case AssetType.Gesture:
|
||||
iteminvType = "<GES>";
|
||||
break;
|
||||
case AssetType.ImageJPEG:
|
||||
iteminvType = "<JPG>";
|
||||
break;
|
||||
case AssetType.ImageTGA:
|
||||
iteminvType = "<TGA>";
|
||||
break;
|
||||
case AssetType.Landmark:
|
||||
iteminvType = "<LND>";
|
||||
break;
|
||||
case AssetType.LostAndFoundFolder:
|
||||
iteminvType = "<L&F>";
|
||||
break;
|
||||
case AssetType.LSLBytecode:
|
||||
iteminvType = "<LSO>";
|
||||
break;
|
||||
case AssetType.LSLText:
|
||||
iteminvType = "<LSL>";
|
||||
break;
|
||||
case AssetType.Notecard:
|
||||
iteminvType = "<NOT>";
|
||||
break;
|
||||
case AssetType.Object:
|
||||
iteminvType = "<OBJ>";
|
||||
break;
|
||||
case AssetType.RootFolder:
|
||||
iteminvType = "< / >";
|
||||
break;
|
||||
case AssetType.Simstate:
|
||||
iteminvType = "<SIM>";
|
||||
break;
|
||||
case AssetType.SnapshotFolder:
|
||||
iteminvType = "<SNA>";
|
||||
break;
|
||||
case AssetType.Sound:
|
||||
iteminvType = "<OGG>";
|
||||
break;
|
||||
case AssetType.SoundWAV:
|
||||
iteminvType = "<WAV>";
|
||||
break;
|
||||
case AssetType.Texture:
|
||||
iteminvType = "<JP2>";
|
||||
break;
|
||||
case AssetType.TextureTGA:
|
||||
iteminvType = "<TGA>";
|
||||
break;
|
||||
case AssetType.TrashFolder:
|
||||
iteminvType = "<TRS>";
|
||||
break;
|
||||
case AssetType.Unknown:
|
||||
default:
|
||||
iteminvType = "<?<3F>?>";
|
||||
break;
|
||||
}
|
||||
|
||||
displayString += "-";
|
||||
displayString += PermMaskString(item.Permissions.OwnerMask);
|
||||
displayString += PermMaskString(item.Permissions.GroupMask);
|
||||
displayString += PermMaskString(item.Permissions.EveryoneMask);
|
||||
displayString += " " + iteminvType;
|
||||
displayString += " " + item.CreationDate.ToShortDateString() + " " + item.CreationDate.ToShortTimeString();
|
||||
displayString += " " + item.UUID.ToString().ToUpperInvariant();
|
||||
displayString += " " + item.Name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
displayString += b.Name;
|
||||
}
|
||||
displayString += nl;
|
||||
}
|
||||
return displayString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.ListContents.NotReady");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a 3-character summary of the PermissionMask
|
||||
/// CMT if the mask allows copy, mod and transfer
|
||||
/// -MT if it disallows copy
|
||||
/// --T if it only allows transfer
|
||||
/// --- if it disallows everything
|
||||
/// </summary>
|
||||
/// <param name="mask"></param>
|
||||
/// <returns></returns>
|
||||
private static string PermMaskString(PermissionMask mask)
|
||||
{
|
||||
string str = "";
|
||||
if (((uint)mask | (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
|
||||
str += "C";
|
||||
else
|
||||
str += "-";
|
||||
if (((uint)mask | (uint)PermissionMask.Modify) == (uint)PermissionMask.Modify)
|
||||
str += "M";
|
||||
else
|
||||
str += "-";
|
||||
if (((uint)mask | (uint)PermissionMask.Transfer) == (uint)PermissionMask.Transfer)
|
||||
str += "T";
|
||||
else
|
||||
str += "-";
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
93
SLBot/bot/Commands/Inventory/RezItemCommand.cs
Normal file
93
SLBot/bot/Commands/Inventory/RezItemCommand.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : RezItemCommand.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.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
public class RezItemCommand : Command
|
||||
{
|
||||
private InventoryManager Manager;
|
||||
private OpenMetaverse.Inventory Inventory;
|
||||
|
||||
public RezItemCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "rezitem";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.RezItem.Description") + " " + bot.Localization.clResourceManager.getText("Commands.RezItem.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.RezItem.Usage");
|
||||
}
|
||||
UUID dest;
|
||||
if (!UUID.TryParse(args[0], out dest))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.RezItem.ExpectedID");
|
||||
}
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Manager.Store;
|
||||
|
||||
string inventoryName = args[0];
|
||||
// WARNING: Uses local copy of inventory contents, need to download them first.
|
||||
List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
|
||||
foreach (InventoryBase b in contents)
|
||||
{
|
||||
if (inventoryName == b.Name || inventoryName.ToLower() == b.UUID.ToString())
|
||||
{
|
||||
if (b is InventoryItem)
|
||||
{
|
||||
InventoryItem item = b as InventoryItem;
|
||||
Vector3 Position = new Vector3();
|
||||
|
||||
Position = Client.Self.SimPosition;
|
||||
Position.Z += 3.0f;
|
||||
|
||||
Manager.RequestRezFromInventory(Client.Network.CurrentSim, Quaternion.Identity, Position, item);
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.RezItem.Requesting"), item.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.RezItem.CannotFolder"), b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.RezItem.NotFound"), inventoryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
82
SLBot/bot/Commands/Inventory/TakeItemCommand.cs
Normal file
82
SLBot/bot/Commands/Inventory/TakeItemCommand.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : TakeItemCommand.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 TakeItemCommand : Command
|
||||
{
|
||||
|
||||
public TakeItemCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "takeitem";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.TakeItem.Description") + " " + bot.Localization.clResourceManager.getText("Commands.TakeItem.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
UUID target;
|
||||
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.TakeItem.Usage");
|
||||
|
||||
if (UUID.TryParse(args[0], out target))
|
||||
{
|
||||
Primitive targetPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == target;
|
||||
}
|
||||
);
|
||||
|
||||
if (targetPrim != null)
|
||||
{
|
||||
string primName;
|
||||
Client.Inventory.RequestDeRezToInventory(targetPrim.LocalID);
|
||||
|
||||
if (targetPrim.Properties.Name == null)
|
||||
primName = "Object";
|
||||
else
|
||||
primName = targetPrim.Properties.Name;
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TakeItem.Took"), primName, targetPrim.ID);
|
||||
}
|
||||
}
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TakeItem.NotFound"), args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
169
SLBot/bot/Commands/Inventory/TaskRunningCommand.cs
Normal file
169
SLBot/bot/Commands/Inventory/TaskRunningCommand.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : TaskRunningCommand.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.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class TaskRunningCommand : Command
|
||||
{
|
||||
public TaskRunningCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "taskrunning";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.TaskRunning.Description") + " " + bot.Localization.clResourceManager.getText("Commands.TaskRunning.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.TaskRunning.Usage");
|
||||
|
||||
uint objectLocalID;
|
||||
UUID objectID;
|
||||
|
||||
if (!UUID.TryParse(args[0], out objectID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.TaskRunning.Usage");
|
||||
|
||||
Primitive found = Client.Network.CurrentSim.ObjectsPrimitives.Find(delegate(Primitive prim)
|
||||
{
|
||||
return prim.ID == objectID;
|
||||
});
|
||||
if (found != null)
|
||||
objectLocalID = found.LocalID;
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TaskRunning.NotFound"), objectID);
|
||||
|
||||
List<InventoryBase> items = Client.Inventory.GetTaskInventory(objectID, objectLocalID, 1000 * 30);
|
||||
|
||||
//bool wantSet = false;
|
||||
bool setTaskTo = false;
|
||||
if (items != null)
|
||||
{
|
||||
string result = String.Empty;
|
||||
string matching = String.Empty;
|
||||
bool setAny = false;
|
||||
if (args.Length > 1)
|
||||
{
|
||||
matching = args[1];
|
||||
|
||||
string tf;
|
||||
if (args.Length > 2)
|
||||
{
|
||||
tf = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
tf = matching.ToLower();
|
||||
}
|
||||
if (tf == "true")
|
||||
{
|
||||
setAny = true;
|
||||
setTaskTo = true;
|
||||
}
|
||||
else if (tf == "false")
|
||||
{
|
||||
setAny = true;
|
||||
setTaskTo = false;
|
||||
}
|
||||
|
||||
}
|
||||
bool wasRunning = false;
|
||||
|
||||
EventHandler<ScriptRunningReplyEventArgs> callback;
|
||||
using (AutoResetEvent OnScriptRunningReset = new AutoResetEvent(false))
|
||||
{
|
||||
callback = ((object sender, ScriptRunningReplyEventArgs e) =>
|
||||
{
|
||||
if (e.ObjectID == objectID)
|
||||
{
|
||||
result += String.Format(bot.Localization.clResourceManager.getText("Commands.TaskRunning.Running"), e.IsMono, e.IsRunning);
|
||||
wasRunning = e.IsRunning;
|
||||
OnScriptRunningReset.Set();
|
||||
}
|
||||
});
|
||||
|
||||
Client.Inventory.ScriptRunningReply += callback;
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
if (items[i] is InventoryFolder)
|
||||
{
|
||||
// this shouldn't happen this year
|
||||
result += String.Format(bot.Localization.clResourceManager.getText("Commands.TaskRunning.Folder"), items[i].Name) + Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryItem item = (InventoryItem)items[i];
|
||||
AssetType assetType = item.AssetType;
|
||||
result += String.Format(bot.Localization.clResourceManager.getText("Commands.TaskRunning.Item"), item.Name, item.Description,
|
||||
assetType);
|
||||
if (assetType == AssetType.LSLBytecode || assetType == AssetType.LSLText)
|
||||
{
|
||||
OnScriptRunningReset.Reset();
|
||||
Client.Inventory.RequestGetScriptRunning(objectID, item.UUID);
|
||||
if (!OnScriptRunningReset.WaitOne(10000, true))
|
||||
{
|
||||
result += bot.Localization.clResourceManager.getText("Commands.TaskRunning.NoInfo");
|
||||
}
|
||||
if (setAny && item.Name.Contains(matching))
|
||||
{
|
||||
if (wasRunning != setTaskTo)
|
||||
{
|
||||
OnScriptRunningReset.Reset();
|
||||
result += bot.Localization.clResourceManager.getText("Commands.TaskRunning.Setting") + setTaskTo + " => ";
|
||||
Client.Inventory.RequestSetScriptRunning(objectID, item.UUID, setTaskTo);
|
||||
if (!OnScriptRunningReset.WaitOne(10000, true))
|
||||
{
|
||||
result += bot.Localization.clResourceManager.getText("Commands.TaskRunning.NotSet");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result += Environment.NewLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
Client.Inventory.ScriptRunningReply -= callback;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.TaskRunning.failed"), objectLocalID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
475
SLBot/bot/Commands/Inventory/UploadCommand.cs
Normal file
475
SLBot/bot/Commands/Inventory/UploadCommand.cs
Normal file
@@ -0,0 +1,475 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : UploadCommand.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 OpenMetaverse.Capabilities;
|
||||
using OpenMetaverse.Imaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class UploadCommand : Command
|
||||
{
|
||||
AutoResetEvent UploadCompleteEvent = new AutoResetEvent(false);
|
||||
UUID TextureID = UUID.Zero;
|
||||
DateTime start;
|
||||
AssetType detectedAssetType = AssetType.Unknown;
|
||||
InventoryType detectedInventoryType = InventoryType.Unknown;
|
||||
System.Text.StringBuilder returnString;
|
||||
const int NOTECARD_CREATE_TIMEOUT = 1000 * 10;
|
||||
|
||||
public UploadCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "upload";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Upload.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Upload.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
returnString = new System.Text.StringBuilder();
|
||||
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
string inventoryName;
|
||||
string fileName;
|
||||
|
||||
if (args.Length != 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.Usage");
|
||||
|
||||
TextureID = UUID.Zero;
|
||||
inventoryName = args[0];
|
||||
fileName = args[1];
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Upload.Loading"), fileName);
|
||||
|
||||
switch (System.IO.Path.GetExtension(fileName))
|
||||
{
|
||||
case ".animatn":
|
||||
detectedAssetType = AssetType.Animation;
|
||||
detectedInventoryType = InventoryType.Animation;
|
||||
break;
|
||||
case ".bodypart":
|
||||
detectedAssetType = AssetType.Bodypart;
|
||||
detectedInventoryType = InventoryType.Wearable;
|
||||
break;
|
||||
case ".gesture":
|
||||
detectedAssetType = AssetType.Gesture;
|
||||
detectedInventoryType = InventoryType.Gesture;
|
||||
break;
|
||||
case ".clothing":
|
||||
detectedAssetType = AssetType.Clothing;
|
||||
detectedInventoryType = InventoryType.Wearable;
|
||||
break;
|
||||
case ".jpg":
|
||||
case ".tga":
|
||||
case ".jp2":
|
||||
case ".j2c":
|
||||
detectedAssetType = AssetType.Texture;
|
||||
detectedInventoryType = InventoryType.Texture;
|
||||
break;
|
||||
case ".notecard":
|
||||
detectedAssetType = AssetType.Notecard;
|
||||
detectedInventoryType = InventoryType.Notecard;
|
||||
break;
|
||||
case ".landmark":
|
||||
detectedAssetType = AssetType.Landmark;
|
||||
detectedInventoryType = InventoryType.Landmark;
|
||||
break;
|
||||
case ".ogg":
|
||||
detectedAssetType = AssetType.Sound;
|
||||
detectedInventoryType = InventoryType.Sound;
|
||||
break;
|
||||
case ".lsl":
|
||||
detectedAssetType = AssetType.LSLText;
|
||||
detectedInventoryType = InventoryType.LSL;
|
||||
break;
|
||||
case ".lso":
|
||||
detectedAssetType = AssetType.LSLBytecode;
|
||||
detectedInventoryType = InventoryType.LSL;
|
||||
break;
|
||||
case ".wav":
|
||||
default:
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.Unsupported");
|
||||
}
|
||||
|
||||
switch (detectedAssetType)
|
||||
{
|
||||
case AssetType.Texture:
|
||||
byte[] jpeg2k;
|
||||
try
|
||||
{
|
||||
jpeg2k = System.IO.File.ReadAllBytes(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
if (jpeg2k == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.FailedCompress");
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Upload.CompressedUpload"));
|
||||
start = DateTime.Now;
|
||||
DoUpload(jpeg2k, inventoryName);
|
||||
break;
|
||||
case AssetType.LSLText:
|
||||
byte[] rawScriptData;
|
||||
try
|
||||
{
|
||||
rawScriptData = System.IO.File.ReadAllBytes(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
if (rawScriptData == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.FailedLoad");
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Upload.LoadedUpload"));
|
||||
start = DateTime.Now;
|
||||
DoUploadScript(rawScriptData, inventoryName);
|
||||
break;
|
||||
case AssetType.Notecard:
|
||||
byte[] rawNotecardData;
|
||||
try
|
||||
{
|
||||
rawNotecardData = System.IO.File.ReadAllBytes(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
if (rawNotecardData == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.FailedLoad");
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Upload.LoadedUpload"));
|
||||
start = DateTime.Now;
|
||||
DoUploadNotecard(rawNotecardData, inventoryName);
|
||||
break;
|
||||
default:
|
||||
byte[] rawData;
|
||||
try
|
||||
{
|
||||
rawData = System.IO.File.ReadAllBytes(fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
if (rawData == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.FailedLoad");
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Upload.LoadedUpload"));
|
||||
start = DateTime.Now;
|
||||
DoUpload(rawData, inventoryName);
|
||||
break;
|
||||
}
|
||||
|
||||
if (UploadCompleteEvent.WaitOne(15000, false))
|
||||
{
|
||||
return returnString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.Timeout");
|
||||
}
|
||||
}
|
||||
return bot.Localization.clResourceManager.getText("Commands.Upload.Usage");
|
||||
}
|
||||
|
||||
private void DoUploadNotecard(byte[] UploadData, string FileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string desc = String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.CreatedBy"), FileName, DateTime.Now);
|
||||
AutoResetEvent emptyNoteEvent = new AutoResetEvent(false);
|
||||
AutoResetEvent notecardEvent = new AutoResetEvent(false);
|
||||
AssetNotecard empty = new AssetNotecard();
|
||||
bool emptySuccess = false, finalUploadSuccess = false;
|
||||
string message = String.Empty;
|
||||
UUID notecardItemID = UUID.Zero, notecardAssetID = UUID.Zero;
|
||||
|
||||
// create the asset
|
||||
Client.Inventory.RequestCreateItem(Client.Inventory.FindFolderForType(AssetType.Notecard), FileName, desc, AssetType.Notecard, UUID.Random(), InventoryType.Notecard, PermissionMask.All,
|
||||
delegate(bool success, InventoryItem item)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.Returned"),
|
||||
success, item.UUID, item.AssetUUID));
|
||||
if (success)
|
||||
{
|
||||
// upload the asset
|
||||
|
||||
#region Upload an empty notecard asset first
|
||||
empty.BodyText = "\n";
|
||||
empty.Encode();
|
||||
|
||||
Client.Inventory.RequestUploadNotecardAsset(empty.AssetData, item.UUID,
|
||||
delegate(bool uploadSuccess, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
notecardItemID = itemID;
|
||||
notecardAssetID = assetID;
|
||||
emptySuccess = uploadSuccess;
|
||||
message = status ?? bot.Localization.clResourceManager.getText("Commands.Upload.UnknownError");
|
||||
emptyNoteEvent.Set();
|
||||
});
|
||||
|
||||
emptyNoteEvent.WaitOne(NOTECARD_CREATE_TIMEOUT, false);
|
||||
|
||||
#endregion Upload an empty notecard asset first
|
||||
|
||||
if (emptySuccess)
|
||||
{
|
||||
// Upload the actual notecard asset
|
||||
Client.Inventory.RequestUploadNotecardAsset(UploadData, item.UUID,
|
||||
delegate(bool uploadSuccess, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
notecardItemID = itemID;
|
||||
notecardAssetID = assetID;
|
||||
finalUploadSuccess = uploadSuccess;
|
||||
message = status ?? bot.Localization.clResourceManager.getText("Commands.Upload.UnknownError");
|
||||
notecardEvent.Set();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notecardEvent.Set();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
notecardEvent.WaitOne(NOTECARD_CREATE_TIMEOUT, false);
|
||||
|
||||
if (finalUploadSuccess)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.ReturnedNotecard"),
|
||||
finalUploadSuccess.ToString(), message, notecardItemID, notecardAssetID));
|
||||
bot.Console.WriteLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.UploadTook"), DateTime.Now.Subtract(start)));
|
||||
Client.Inventory.GiveItem(notecardItemID, FileName, AssetType.Notecard, Client.MasterKey, true);
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.UploadedUUID"), notecardAssetID);
|
||||
returnString.AppendLine();
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.Sent"), Client.MasterName, Client.MasterKey);
|
||||
returnString.AppendLine();
|
||||
UploadCompleteEvent.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.ReturnedNotecard"),
|
||||
finalUploadSuccess.ToString(), message, notecardItemID, notecardAssetID));
|
||||
UploadCompleteEvent.Set();
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
bot.Console.WriteLine(e.ToString());
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.ErrorNotecard"), FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoUploadScript(byte[] UploadData, string FileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string desc = String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.CreatedBy"), FileName, DateTime.Now);
|
||||
// create the asset
|
||||
Client.Inventory.RequestCreateItem(Client.Inventory.FindFolderForType(AssetType.LSLText), FileName, desc, AssetType.LSLText, UUID.Random(), InventoryType.LSL, PermissionMask.All,
|
||||
delegate(bool success, InventoryItem item)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.Returned"),
|
||||
success, item.UUID, item.AssetUUID));
|
||||
if (success)
|
||||
// upload the asset
|
||||
Client.Inventory.RequestUpdateScriptAgentInventory(UploadData, item.UUID, true, new InventoryManager.ScriptUpdatedCallback(delegate(bool success1, string status, UUID itemid, UUID assetid)
|
||||
{
|
||||
if (success1)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.ReturnedScript"),
|
||||
success1, status, itemid, assetid));
|
||||
bot.Console.WriteLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.UploadTook"), DateTime.Now.Subtract(start)));
|
||||
Client.Inventory.GiveItem(item.UUID, FileName, AssetType.LSLText, Client.MasterKey, true);
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.UploadUUID"), assetid);
|
||||
returnString.AppendLine();
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.Sent"), Client.MasterName, Client.MasterKey);
|
||||
returnString.AppendLine();
|
||||
UploadCompleteEvent.Set();
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
bot.Console.WriteLine(e.ToString());
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.ErrorScript"), FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoUpload(byte[] UploadData, string FileName)
|
||||
{
|
||||
if (UploadData != null)
|
||||
{
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(FileName);
|
||||
string desc = String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.CreatedBy"), FileName, DateTime.Now);
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(UploadData, name, desc,
|
||||
detectedAssetType, detectedInventoryType, Client.Inventory.FindFolderForType(detectedAssetType),
|
||||
|
||||
/*delegate(CapsClient client, long bytesReceived, long bytesSent, long totalBytesToReceive, long totalBytesToSend)
|
||||
{
|
||||
if (bytesSent > 0)
|
||||
bot.Console.WriteLine(String.Format("Textura subida: {0} / {1}", bytesSent, totalBytesToSend));
|
||||
},*/
|
||||
// CLAUNIA: Seems that libomv changes nulled this functionality
|
||||
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.Upload.ReturnedAsset"),
|
||||
success, status, itemID, assetID));
|
||||
|
||||
bot.Console.WriteLine(String.Format(bot.Localization.clResourceManager.getText("Commands.Upload.UploadTook"), DateTime.Now.Subtract(start)));
|
||||
|
||||
if (!success)
|
||||
{
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.Failed"), status);
|
||||
returnString.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryItem item = Client.Inventory.FetchItem(itemID, Client.Self.AgentID, 1000 * 15);
|
||||
item.Permissions.NextOwnerMask = PermissionMask.All;
|
||||
Client.Inventory.RequestUpdateItem(item);
|
||||
|
||||
Client.Inventory.GiveItem(itemID, FileName, detectedAssetType, Client.MasterKey, true);
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.UploadedUUID"), assetID);
|
||||
returnString.AppendLine();
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.Upload.Sent"), Client.MasterName, Client.MasterKey);
|
||||
returnString.AppendLine();
|
||||
}
|
||||
|
||||
TextureID = assetID;
|
||||
|
||||
UploadCompleteEvent.Set();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] LoadImage(string fileName)
|
||||
{
|
||||
byte[] UploadData;
|
||||
string lowfilename = fileName.ToLower();
|
||||
Bitmap bitmap = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (lowfilename.EndsWith(".jp2") || lowfilename.EndsWith(".j2c"))
|
||||
{
|
||||
Image image;
|
||||
ManagedImage managedImage;
|
||||
|
||||
// Upload JPEG2000 images untouched
|
||||
UploadData = System.IO.File.ReadAllBytes(fileName);
|
||||
|
||||
OpenJPEG.DecodeToImage(UploadData, out managedImage, out image);
|
||||
bitmap = (Bitmap)image;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lowfilename.EndsWith(".tga"))
|
||||
bitmap = LoadTGAClass.LoadTGA(fileName);
|
||||
else
|
||||
bitmap = (Bitmap)System.Drawing.Image.FromFile(fileName);
|
||||
|
||||
int oldwidth = bitmap.Width;
|
||||
int oldheight = bitmap.Height;
|
||||
|
||||
if (!IsPowerOfTwo((uint)oldwidth) || !IsPowerOfTwo((uint)oldheight))
|
||||
{
|
||||
Bitmap resized = new Bitmap(256, 256, bitmap.PixelFormat);
|
||||
Graphics graphics = Graphics.FromImage(resized);
|
||||
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
graphics.InterpolationMode =
|
||||
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(bitmap, 0, 0, 256, 256);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = resized;
|
||||
|
||||
oldwidth = 256;
|
||||
oldheight = 256;
|
||||
}
|
||||
|
||||
// Handle resizing to prevent excessively large images
|
||||
if (oldwidth > 1024 || oldheight > 1024)
|
||||
{
|
||||
int newwidth = (oldwidth > 1024) ? 1024 : oldwidth;
|
||||
int newheight = (oldheight > 1024) ? 1024 : oldheight;
|
||||
|
||||
Bitmap resized = new Bitmap(newwidth, newheight, bitmap.PixelFormat);
|
||||
Graphics graphics = Graphics.FromImage(resized);
|
||||
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
graphics.InterpolationMode =
|
||||
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(bitmap, 0, 0, newwidth, newheight);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = resized;
|
||||
}
|
||||
|
||||
UploadData = OpenJPEG.EncodeFromImage(bitmap, false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.ToString() + " SL Image Upload ");
|
||||
return null;
|
||||
}
|
||||
return UploadData;
|
||||
}
|
||||
|
||||
private static bool IsPowerOfTwo(uint n)
|
||||
{
|
||||
return (n & (n - 1)) == 0 && n != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
218
SLBot/bot/Commands/Inventory/UploadImageCommand.cs
Normal file
218
SLBot/bot/Commands/Inventory/UploadImageCommand.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : UploadImageCommand.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 OpenMetaverse.Imaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
public class UploadImageCommand : Command
|
||||
{
|
||||
AutoResetEvent UploadCompleteEvent = new AutoResetEvent(false);
|
||||
UUID TextureID = UUID.Zero;
|
||||
DateTime start;
|
||||
System.Text.StringBuilder returnString = new System.Text.StringBuilder();
|
||||
|
||||
public UploadImageCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "uploadimage";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.UploadImage.Description") + " " + bot.Localization.clResourceManager.getText("Commands.UploadImage.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
string inventoryName;
|
||||
string fileName;
|
||||
|
||||
if (args.Length != 2)
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadImage.Usage");
|
||||
|
||||
TextureID = UUID.Zero;
|
||||
inventoryName = args[0];
|
||||
fileName = args[1];
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.UploadImage.Loading"), fileName);
|
||||
byte[] jpeg2k = LoadImage(fileName);
|
||||
if (jpeg2k == null)
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadImage.FailedConvert");
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.UploadImage.Uploading"));
|
||||
start = DateTime.Now;
|
||||
DoUpload(jpeg2k, inventoryName);
|
||||
|
||||
if (UploadCompleteEvent.WaitOne(10000, false))
|
||||
{
|
||||
return returnString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadImage.Timeout");
|
||||
}
|
||||
}
|
||||
return bot.Localization.clResourceManager.getText("Commands.UploadImage.Usage");
|
||||
}
|
||||
|
||||
private void DoUpload(byte[] UploadData, string FileName)
|
||||
{
|
||||
if (UploadData != null)
|
||||
{
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(FileName);
|
||||
string desc = String.Format(bot.Localization.clResourceManager.getText("Commands.UploadImage.CreatedBy"), FileName, DateTime.Now);
|
||||
|
||||
Client.Inventory.RequestCreateItemFromAsset(UploadData, name, desc,
|
||||
AssetType.Texture, InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture),
|
||||
|
||||
/* delegate(CapsClient client, long bytesReceived, long bytesSent, long totalBytesToReceive, long totalBytesToSend)
|
||||
{
|
||||
if (bytesSent > 0)
|
||||
bot.Console.WriteLine(String.Format("Textura subida: {0} / {1}", bytesSent, totalBytesToSend));
|
||||
},*/
|
||||
// CLAUNIA: Seems that libomv changes nulled this functionality
|
||||
|
||||
delegate(bool success, string status, UUID itemID, UUID assetID)
|
||||
{
|
||||
bot.Console.WriteLine(String.Format(
|
||||
bot.Localization.clResourceManager.getText("Commands.UploadImage.Returned"),
|
||||
success, status, itemID, assetID));
|
||||
|
||||
bot.Console.WriteLine(String.Format(bot.Localization.clResourceManager.getText("Commands.UploadImage.UploadTook"), DateTime.Now.Subtract(start)));
|
||||
|
||||
if (!success)
|
||||
{
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.UploadImage.FailedUpload"), status);
|
||||
returnString.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Inventory.GiveItem(itemID, FileName, AssetType.Texture, Client.MasterKey, true);
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.UploadImage.UploadedUUID"), assetID);
|
||||
returnString.AppendLine();
|
||||
returnString.AppendFormat(bot.Localization.clResourceManager.getText("Commands.UploadImage.ImageSent"), Client.MasterName, Client.MasterKey);
|
||||
returnString.AppendLine();
|
||||
}
|
||||
|
||||
TextureID = assetID;
|
||||
|
||||
UploadCompleteEvent.Set();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] LoadImage(string fileName)
|
||||
{
|
||||
byte[] UploadData;
|
||||
string lowfilename = fileName.ToLower();
|
||||
Bitmap bitmap = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (lowfilename.EndsWith(".jp2") || lowfilename.EndsWith(".j2c"))
|
||||
{
|
||||
Image image;
|
||||
ManagedImage managedImage;
|
||||
|
||||
// Upload JPEG2000 images untouched
|
||||
UploadData = System.IO.File.ReadAllBytes(fileName);
|
||||
|
||||
OpenJPEG.DecodeToImage(UploadData, out managedImage, out image);
|
||||
bitmap = (Bitmap)image;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lowfilename.EndsWith(".tga"))
|
||||
bitmap = LoadTGAClass.LoadTGA(fileName);
|
||||
else
|
||||
bitmap = (Bitmap)System.Drawing.Image.FromFile(fileName);
|
||||
|
||||
int oldwidth = bitmap.Width;
|
||||
int oldheight = bitmap.Height;
|
||||
|
||||
if (!IsPowerOfTwo((uint)oldwidth) || !IsPowerOfTwo((uint)oldheight))
|
||||
{
|
||||
Bitmap resized = new Bitmap(256, 256, bitmap.PixelFormat);
|
||||
Graphics graphics = Graphics.FromImage(resized);
|
||||
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
graphics.InterpolationMode =
|
||||
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(bitmap, 0, 0, 256, 256);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = resized;
|
||||
|
||||
oldwidth = 256;
|
||||
oldheight = 256;
|
||||
}
|
||||
|
||||
// Handle resizing to prevent excessively large images
|
||||
if (oldwidth > 1024 || oldheight > 1024)
|
||||
{
|
||||
int newwidth = (oldwidth > 1024) ? 1024 : oldwidth;
|
||||
int newheight = (oldheight > 1024) ? 1024 : oldheight;
|
||||
|
||||
Bitmap resized = new Bitmap(newwidth, newheight, bitmap.PixelFormat);
|
||||
Graphics graphics = Graphics.FromImage(resized);
|
||||
|
||||
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
graphics.InterpolationMode =
|
||||
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(bitmap, 0, 0, newwidth, newheight);
|
||||
|
||||
bitmap.Dispose();
|
||||
bitmap = resized;
|
||||
}
|
||||
|
||||
UploadData = OpenJPEG.EncodeFromImage(bitmap, false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
bot.Console.WriteLine(ex.ToString() + " SL Image Upload ");
|
||||
return null;
|
||||
}
|
||||
return UploadData;
|
||||
}
|
||||
|
||||
private static bool IsPowerOfTwo(uint n)
|
||||
{
|
||||
return (n & (n - 1)) == 0 && n != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
101
SLBot/bot/Commands/Inventory/ViewNotecardCommand.cs
Normal file
101
SLBot/bot/Commands/Inventory/ViewNotecardCommand.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ViewNotecardCommand.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.Collections.Generic;
|
||||
using OpenMetaverse.Assets;
|
||||
|
||||
public class ViewNotecardCommand : Command
|
||||
{
|
||||
public ViewNotecardCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "viewnote";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ViewNotecard.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ViewNotecard.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.ViewNotecard.Usage");
|
||||
}
|
||||
UUID note;
|
||||
if (!UUID.TryParse(args[0], out note))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.ViewNotecard.ExpectedUUID");
|
||||
}
|
||||
|
||||
System.Threading.AutoResetEvent waitEvent = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
System.Text.StringBuilder result = new System.Text.StringBuilder();
|
||||
|
||||
// verify asset is loaded in store
|
||||
if (Client.Inventory.Store.Contains(note))
|
||||
{
|
||||
// retrieve asset from store
|
||||
InventoryItem ii = (InventoryItem)Client.Inventory.Store[note];
|
||||
|
||||
// make request for asset
|
||||
Client.Assets.RequestInventoryAsset(ii, true,
|
||||
delegate(AssetDownload transfer, Asset asset)
|
||||
{
|
||||
if (transfer.Success)
|
||||
{
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.ViewNotecard.NotecardData"), Utils.BytesToString(asset.AssetData));
|
||||
waitEvent.Set();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// wait for reply or timeout
|
||||
if (!waitEvent.WaitOne(10000, false))
|
||||
{
|
||||
result.Append(bot.Localization.clResourceManager.getText("Commands.ViewNotecard.Timeout"));
|
||||
}
|
||||
// unsubscribe from reply event
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Append(bot.Localization.clResourceManager.getText("Commands.ViewNotecard.NotFound"));
|
||||
}
|
||||
|
||||
// return results
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
87
SLBot/bot/Commands/Movement/BackCommand.cs
Normal file
87
SLBot/bot/Commands/Movement/BackCommand.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : BackCommand.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.Collections.Generic;
|
||||
|
||||
public class BackCommand : Command
|
||||
{
|
||||
public BackCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "back";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Back.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.AtNeg = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Back.Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
70
SLBot/bot/Commands/Movement/CameraFarCommand.cs
Normal file
70
SLBot/bot/Commands/Movement/CameraFarCommand.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CameraFarCommand.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 CameraFarCommand : Command
|
||||
{
|
||||
public CameraFarCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "camerafar";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.CameraFar.Description") + " " + bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CameraFar.Actual"), Client.Self.Movement.Camera.Far.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!float.TryParse(args[0], out distance))
|
||||
return bot.Localization.clResourceManager.getText("Commands.CameraFar.Usage");
|
||||
|
||||
Client.Self.Movement.Camera.Far = distance;
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.CameraFar.Changed"), Client.Self.Movement.Camera.Far.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
SLBot/bot/Commands/Movement/CrouchCommand.cs
Normal file
67
SLBot/bot/Commands/Movement/CrouchCommand.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : CrouchCommand.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 CrouchCommand : Command
|
||||
{
|
||||
public CrouchCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "crouch";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Crouch.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Crouch.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool start = true;
|
||||
|
||||
if (args.Length == 1 && args[0].ToLower() == "stop")
|
||||
start = false;
|
||||
|
||||
if (start)
|
||||
{
|
||||
Client.Self.Crouch(true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Crouch.Started");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Crouch(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Crouch.Stopped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
SLBot/bot/Commands/Movement/FlyCommand.cs
Normal file
67
SLBot/bot/Commands/Movement/FlyCommand.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FlyCommand.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 FlyCommand : Command
|
||||
{
|
||||
public FlyCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "fly";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Fly.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Fly.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
bool start = true;
|
||||
|
||||
if (args.Length == 1 && args[0].ToLower() == "stop")
|
||||
start = false;
|
||||
|
||||
if (start)
|
||||
{
|
||||
Client.Self.Fly(true);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Fly.Started");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Fly(false);
|
||||
return bot.Localization.clResourceManager.getText("Commands.Fly.Stopped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
185
SLBot/bot/Commands/Movement/FlyToCommand.cs
Normal file
185
SLBot/bot/Commands/Movement/FlyToCommand.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FlyToCommand.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 System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using bot;
|
||||
|
||||
class FlyToCommand : Command
|
||||
{
|
||||
Vector3 myPos = new Vector3();
|
||||
Vector2 myPos0 = new Vector2();
|
||||
Vector3 target = new Vector3();
|
||||
Vector2 target0 = new Vector2();
|
||||
float diff, olddiff, saveolddiff;
|
||||
int startTime = 0;
|
||||
int duration = 10000;
|
||||
|
||||
public FlyToCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "flyto";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.FlyTo.Description") + " " + bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
|
||||
SecondLifeBot.Objects.TerseObjectUpdate += Objects_OnObjectUpdated;
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 4 || args.Length < 3)
|
||||
return bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
|
||||
if (!float.TryParse(args[0], out target.X) ||
|
||||
!float.TryParse(args[1], out target.Y) ||
|
||||
!float.TryParse(args[2], out target.Z))
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.FlyTo.Usage");
|
||||
}
|
||||
target0.X = target.X;
|
||||
target0.Y = target.Y;
|
||||
|
||||
if (args.Length == 4 && Int32.TryParse(args[3], out duration))
|
||||
duration *= 1000;
|
||||
|
||||
startTime = Environment.TickCount;
|
||||
Client.Self.Movement.Fly = true;
|
||||
Client.Self.Movement.AtPos = true;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
ZMovement();
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
|
||||
return string.Format(bot.Localization.clResourceManager.getText("Commands.FlyTo.Flying"), target.ToString(), duration / 1000);
|
||||
}
|
||||
|
||||
private void Objects_OnObjectUpdated(object sender, TerseObjectUpdateEventArgs e)
|
||||
{
|
||||
if (startTime == 0)
|
||||
return;
|
||||
if (e.Update.LocalID == Client.Self.LocalID)
|
||||
{
|
||||
XYMovement();
|
||||
ZMovement();
|
||||
if (Client.Self.Movement.AtPos || Client.Self.Movement.AtNeg)
|
||||
{
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
Debug("Flyxy ");
|
||||
}
|
||||
else if (Client.Self.Movement.UpPos || Client.Self.Movement.UpNeg)
|
||||
{
|
||||
Client.Self.Movement.TurnToward(target);
|
||||
//Client.Self.Movement.SendUpdate(false);
|
||||
Debug("Fly z ");
|
||||
}
|
||||
else if (Vector3.Distance(target, Client.Self.SimPosition) <= 2.0)
|
||||
{
|
||||
EndFlyto();
|
||||
Debug("At Target");
|
||||
}
|
||||
}
|
||||
if (Environment.TickCount - startTime > duration)
|
||||
{
|
||||
EndFlyto();
|
||||
Debug("End Flyto");
|
||||
}
|
||||
}
|
||||
|
||||
private bool XYMovement()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
myPos = Client.Self.SimPosition;
|
||||
myPos0.X = myPos.X;
|
||||
myPos0.Y = myPos.Y;
|
||||
diff = Vector2.Distance(target0, myPos0);
|
||||
Vector2 vvel = new Vector2(Client.Self.Velocity.X, Client.Self.Velocity.Y);
|
||||
float vel = vvel.Length();
|
||||
if (diff >= 10.0)
|
||||
{
|
||||
Client.Self.Movement.AtPos = true;
|
||||
res = true;
|
||||
}
|
||||
else if (diff >= 2 && vel < 5)
|
||||
{
|
||||
Client.Self.Movement.AtPos = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Client.Self.Movement.AtPos = false;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
}
|
||||
saveolddiff = olddiff;
|
||||
olddiff = diff;
|
||||
return res;
|
||||
}
|
||||
|
||||
private void ZMovement()
|
||||
{
|
||||
Client.Self.Movement.UpPos = false;
|
||||
Client.Self.Movement.UpNeg = false;
|
||||
float diffz = (target.Z - Client.Self.SimPosition.Z);
|
||||
if (diffz >= 20.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -20.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
else if (diffz >= +5.0 && Client.Self.Velocity.Z < +4.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -5.0 && Client.Self.Velocity.Z > -4.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
else if (diffz >= +2.0 && Client.Self.Velocity.Z < +1.0)
|
||||
Client.Self.Movement.UpPos = true;
|
||||
else if (diffz <= -2.0 && Client.Self.Velocity.Z > -1.0)
|
||||
Client.Self.Movement.UpNeg = true;
|
||||
}
|
||||
|
||||
private void EndFlyto()
|
||||
{
|
||||
startTime = 0;
|
||||
Client.Self.Movement.AtPos = false;
|
||||
Client.Self.Movement.AtNeg = false;
|
||||
Client.Self.Movement.UpPos = false;
|
||||
Client.Self.Movement.UpNeg = false;
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("DEBUG")]
|
||||
private void Debug(string x)
|
||||
{
|
||||
bot.Console.WriteLine(x + " {0,3:##0} {1,3:##0} {2,3:##0} diff {3,5:##0.0} olddiff {4,5:##0.0} At:{5,5} {6,5} Up:{7,5} {8,5} v: {9} w: {10}",
|
||||
myPos.X, myPos.Y, myPos.Z, diff, saveolddiff,
|
||||
Client.Self.Movement.AtPos, Client.Self.Movement.AtNeg, Client.Self.Movement.UpPos, Client.Self.Movement.UpNeg,
|
||||
Client.Self.Velocity.ToString(), Client.Self.AngularVelocity.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
207
SLBot/bot/Commands/Movement/FollowCommand.cs
Normal file
207
SLBot/bot/Commands/Movement/FollowCommand.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : FollowCommand.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 OpenMetaverse.Packets;
|
||||
using System;
|
||||
|
||||
public class FollowCommand : Command
|
||||
{
|
||||
public FollowCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "follow";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Follow.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Follow.Usage");
|
||||
SecondLifeBot.Network.RegisterCallback(PacketType.AlertMessage, AlertMessageHandler);
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
string target = String.Empty;
|
||||
for (int ct = 0; ct < args.Length; ct++)
|
||||
target = target + args[ct] + " ";
|
||||
target = target.TrimEnd();
|
||||
|
||||
if (target.Length > 0)
|
||||
{
|
||||
if (args[0] == "stop")
|
||||
{
|
||||
Active = false;
|
||||
return bot.Localization.clResourceManager.getText("Commands.Follow.Stopped");
|
||||
}
|
||||
|
||||
if (Follow(target))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Following"), target);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Unable"), target);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Client.MasterKey != UUID.Zero)
|
||||
{
|
||||
if (Follow(Client.MasterKey))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.FollowingUUID"), Client.MasterKey);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.UnableUUID"), Client.MasterKey);
|
||||
}
|
||||
else if (Client.MasterName != String.Empty)
|
||||
{
|
||||
if (Follow(Client.MasterName))
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Following"), Client.MasterName);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Follow.Unable"), Client.MasterName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Follow.NoMaster") + " " + bot.Localization.clResourceManager.getText("Commands.Follow.Usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const float DISTANCE_BUFFER = 3.0f;
|
||||
uint targetLocalID = 0;
|
||||
|
||||
bool Follow(string name)
|
||||
{
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return avatar.Name == name;
|
||||
}
|
||||
);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
targetLocalID = target.LocalID;
|
||||
Active = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Follow(UUID id)
|
||||
{
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar target = Client.Network.Simulators[i].ObjectsAvatars.Find(
|
||||
delegate(Avatar avatar)
|
||||
{
|
||||
return avatar.ID == id;
|
||||
}
|
||||
);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
targetLocalID = target.LocalID;
|
||||
Active = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Active = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Think()
|
||||
{
|
||||
// Find the target position
|
||||
lock (Client.Network.Simulators)
|
||||
{
|
||||
for (int i = 0; i < Client.Network.Simulators.Count; i++)
|
||||
{
|
||||
Avatar targetAv;
|
||||
|
||||
if (Client.Network.Simulators[i].ObjectsAvatars.TryGetValue(targetLocalID, out targetAv))
|
||||
{
|
||||
float distance = 0.0f;
|
||||
|
||||
if (Client.Network.Simulators[i] == Client.Network.CurrentSim)
|
||||
{
|
||||
distance = Vector3.Distance(targetAv.Position, Client.Self.SimPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Calculate global distances
|
||||
}
|
||||
|
||||
if (distance > DISTANCE_BUFFER)
|
||||
{
|
||||
uint regionX, regionY;
|
||||
Utils.LongToUInts(Client.Network.Simulators[i].Handle, out regionX, out regionY);
|
||||
|
||||
double xTarget = (double)targetAv.Position.X + (double)regionX;
|
||||
double yTarget = (double)targetAv.Position.Y + (double)regionY;
|
||||
double zTarget = targetAv.Position.Z - 2f;
|
||||
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Follow.Autopilot"),
|
||||
distance, xTarget, yTarget, zTarget);
|
||||
|
||||
Client.Self.AutoPilot(xTarget, yTarget, zTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are in range of the target and moving, stop moving
|
||||
Client.Self.AutoPilotCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.Think();
|
||||
}
|
||||
|
||||
private void AlertMessageHandler(object sender, PacketReceivedEventArgs e)
|
||||
{
|
||||
AlertMessagePacket alert = (AlertMessagePacket)e.Packet;
|
||||
string message = Utils.BytesToString(alert.AlertData.Message);
|
||||
|
||||
if (message.Contains("Autopilot cancel"))
|
||||
{
|
||||
bot.Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.Follow.AutopilotCancelled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
87
SLBot/bot/Commands/Movement/ForwardCommand.cs
Normal file
87
SLBot/bot/Commands/Movement/ForwardCommand.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ForwardCommand.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.Collections.Generic;
|
||||
|
||||
public class ForwardCommand : Command
|
||||
{
|
||||
public ForwardCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "forward";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Forward.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool something_else)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Client.Self.Movement.SendManualUpdate(AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, Client.Self.Movement.Camera.Position,
|
||||
Client.Self.Movement.Camera.AtAxis, Client.Self.Movement.Camera.LeftAxis, Client.Self.Movement.Camera.UpAxis,
|
||||
Client.Self.Movement.BodyRotation, Client.Self.Movement.HeadRotation, Client.Self.Movement.Camera.Far, AgentFlags.None,
|
||||
AgentState.None, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the number of seconds
|
||||
int duration;
|
||||
if (!Int32.TryParse(args[0], out duration))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Usage");
|
||||
// Convert to milliseconds
|
||||
duration *= 1000;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
|
||||
Client.Self.Movement.AtPos = true;
|
||||
|
||||
while (Environment.TickCount - start < duration)
|
||||
{
|
||||
// The movement timer will do this automatically, but we do it here as an example
|
||||
// and to make sure updates are being sent out fast enough
|
||||
Client.Self.Movement.SendUpdate(false);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
|
||||
Client.Self.Movement.AtPos = false;
|
||||
}
|
||||
|
||||
return bot.Localization.clResourceManager.getText("Commands.Forward.Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user