Inventory commands
corrects UUID check for rez object, adds new inventoryfolders limited command.
This commit is contained in:
parent
5cf427c500
commit
13fc38e81f
2 changed files with 41 additions and 7 deletions
|
|
@ -28,14 +28,14 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Token not accepted", "RezObject", new [] { item });
|
return Failure("Token not accepted", "RezObject", new [] { item });
|
||||||
}
|
}
|
||||||
if (UUID.TryParse(item, out UUID targetitem) == true)
|
if (UUID.TryParse(item, out UUID targetitem) == false)
|
||||||
{
|
{
|
||||||
return Failure("Invaild item UUID", "RezObject", new [] { item });
|
return Failure("Invaild item UUID: "+ item, "RezObject", new [] { item });
|
||||||
}
|
}
|
||||||
InventoryItem itm = bot.GetClient.Inventory.FetchItem(targetitem, bot.GetClient.Self.AgentID, (5 * 1000));
|
InventoryItem itm = bot.GetClient.Inventory.FetchItem(targetitem, bot.GetClient.Self.AgentID, (5 * 1000));
|
||||||
if (itm == null)
|
if (itm == null)
|
||||||
{
|
{
|
||||||
return Failure("Unable to find item", "RezObject", new [] { item });
|
return Failure("Unable to find item: " + item, "RezObject", new [] { item });
|
||||||
}
|
}
|
||||||
UUID rezedobject = bot.GetClient.Inventory.RequestRezFromInventory(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimRotation, bot.GetClient.Self.RelativePosition, itm);
|
UUID rezedobject = bot.GetClient.Inventory.RequestRezFromInventory(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimRotation, bot.GetClient.Self.RelativePosition, itm);
|
||||||
return BasicReply(rezedobject.ToString(), "RezObject", new [] { item });
|
return BasicReply(rezedobject.ToString(), "RezObject", new [] { item });
|
||||||
|
|
@ -432,6 +432,22 @@ namespace BetterSecondBot.HttpService
|
||||||
return Failure("Error", "InventoryFolders");
|
return Failure("Error", "InventoryFolders");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[About("Requests folders limited to selected folder")]
|
||||||
|
[ArgHints("targetfolder", "URLARG", "the UUID of the folder or root")]
|
||||||
|
[ReturnHints("single InventoryMapFolder")]
|
||||||
|
[ReturnHints("Error")]
|
||||||
|
[Route(HttpVerbs.Get, "/InventoryFoldersLimited/{targetfolder}/{token}")]
|
||||||
|
public object InventoryFoldersLimited(string targetfolder,string token)
|
||||||
|
{
|
||||||
|
if (tokens.Allow(token, "inventory", "InventoryFoldersLimited", handleGetClientIP()) == false)
|
||||||
|
{
|
||||||
|
return Failure("Token not accepted", "InventoryFoldersLimited");
|
||||||
|
}
|
||||||
|
string reply = HelperInventory.MapFolderJson(bot, targetfolder,false);
|
||||||
|
if (reply != null) return BasicReply(reply, "InventoryFoldersLimited");
|
||||||
|
return Failure("Error", "InventoryFoldersLimited");
|
||||||
|
}
|
||||||
|
|
||||||
[About("Requests the contents of a folder as an array of InventoryMapItem<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>typename: String</li></ul>")]
|
[About("Requests the contents of a folder as an array of InventoryMapItem<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>typename: String</li></ul>")]
|
||||||
[ReturnHints("array of InventoryMapItem")]
|
[ReturnHints("array of InventoryMapItem")]
|
||||||
[ReturnHints("Invaild folder UUID")]
|
[ReturnHints("Invaild folder UUID")]
|
||||||
|
|
|
||||||
|
|
@ -113,19 +113,34 @@ namespace BetterSecondBot.Static
|
||||||
return new KeyValuePair<string,string>(foldername,output.ToString());
|
return new KeyValuePair<string,string>(foldername,output.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MapFolderJson(CommandsBot bot)
|
public static string MapFolderJson(CommandsBot bot,string targetFolder="root", bool subfolders = true)
|
||||||
{
|
{
|
||||||
if (bot.GetClient.Inventory.Store != null)
|
if (bot.GetClient.Inventory.Store != null)
|
||||||
{
|
{
|
||||||
if (bot.GetClient.Inventory.Store.RootFolder != null)
|
if (bot.GetClient.Inventory.Store.RootFolder != null)
|
||||||
{
|
{
|
||||||
return JsonConvert.SerializeObject(DoMapFolderJson(bot, bot.GetClient.Inventory.Store.RootFolder));
|
InventoryFolder topLevel = null;
|
||||||
|
if (targetFolder == "root")
|
||||||
|
{
|
||||||
|
topLevel = bot.GetClient.Inventory.Store.RootFolder;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(UUID.TryParse(targetFolder, out UUID folderUUID) == true)
|
||||||
|
{
|
||||||
|
topLevel = new InventoryFolder(folderUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (topLevel != null)
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(DoMapFolderJson(bot, topLevel, subfolders));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InventoryMapFolder DoMapFolderJson(CommandsBot bot, InventoryFolder folder)
|
public static InventoryMapFolder DoMapFolderJson(CommandsBot bot, InventoryFolder folder, bool subfolders=true)
|
||||||
{
|
{
|
||||||
InventoryMapFolder ReplyFolder = new InventoryMapFolder();
|
InventoryMapFolder ReplyFolder = new InventoryMapFolder();
|
||||||
ReplyFolder.id = folder.UUID.ToString();
|
ReplyFolder.id = folder.UUID.ToString();
|
||||||
|
|
@ -136,7 +151,10 @@ namespace BetterSecondBot.Static
|
||||||
{
|
{
|
||||||
if (R.GetType() == typeof(InventoryFolder))
|
if (R.GetType() == typeof(InventoryFolder))
|
||||||
{
|
{
|
||||||
ReplyFolder.subfolders.Add(DoMapFolderJson(bot, (InventoryFolder)R));
|
if (subfolders == true)
|
||||||
|
{
|
||||||
|
ReplyFolder.subfolders.Add(DoMapFolderJson(bot, (InventoryFolder)R, subfolders));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReplyFolder;
|
return ReplyFolder;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue