diff --git a/SecondBotEvents/Commands/Inventory.cs b/SecondBotEvents/Commands/Inventory.cs index e3831fb..60b59c7 100644 --- a/SecondBotEvents/Commands/Inventory.cs +++ b/SecondBotEvents/Commands/Inventory.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using OpenMetaverse; using OpenMetaverse.Assets; +using Org.BouncyCastle.Tls; using SecondBotEvents.Services; using System; using System.Collections.Generic; @@ -1074,6 +1075,44 @@ namespace SecondBotEvents.Commands return BasicReply(HelperInventory.MapFolderInventoryJson(GetClient(), folder), [folderUUID]); } + + [About("Requests the mapped inventory on the bot using catched data only")] + [ReturnHints("a json data object with: " + + "{" + + "Name: String"+ + "UUID: String"+ + "InventoryType: String"+ + "Children: null or a copy of this data object"+ + "}")] + [CmdTypeGet()] + public object InventoryContentsCatched() + { + InventoryNodeEntry root = LoadInventoryNode(GetClient().Inventory.Store.RootFolder.UUID,"root"); + return BasicReply(JsonConvert.SerializeObject(root)); + } + + protected InventoryNodeEntry LoadInventoryNode(UUID folder, string name="") + { + InventoryNodeEntry myentry = new InventoryNodeEntry(); + myentry.Name = name; + myentry.UUID = folder.Guid.ToString(); + myentry.InventoryType = "folder"; + List folderlist = GetClient().Inventory.Store.GetContents(folder); + foreach (InventoryBase entry in folderlist) + { + if(entry is InventoryFolder) + { + myentry.Children.Add(LoadInventoryNode(entry.UUID, entry.Name)); + } + else if (entry is InventoryItem) + { + myentry.Children.Add(new InventoryNodeEntry() { Children = null, InventoryType = "item", Name = entry.Name, UUID = entry.UUID.ToString() }); + } + } + return myentry; + } + + [About("Requests the contents of a folder as an array of InventoryMapItem")] [ReturnHints("RequestUUID check the smart reply for results")] [ReturnHints("Smart reply: json object of {request:\"\",status:BOOL,message:\"\",data:\"\"")] @@ -1199,6 +1238,14 @@ namespace SecondBotEvents.Commands } } + public class InventoryNodeEntry + { + public string UUID { get; set; } + public string Name { get; set; } + public List Children { get; set; } = new List(); + public string InventoryType { get; set; } + } + public class InventoryAsyncReply { public string requestUUID; diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index 39d8db3..132916c 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -446,6 +446,10 @@ namespace SecondBotEvents.Services } if (master.BotClient.basicCfg.GetLogCommands() == true) { + if(e.results.Length >= 100) + { + e.results = e.results.Substring(0, 100) + "..."; + } LogFormater.Info("Command log:" + JsonConvert.SerializeObject(e)); } }