add NotecardRead support
This commit is contained in:
parent
6def5f65cf
commit
552f5a48ad
6 changed files with 98 additions and 15 deletions
|
|
@ -41,7 +41,7 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return BasicReply("Error with gesture", new [] { gesture });
|
||||
}
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(gestureUUID, GetClient().Self.AgentID, new TimeSpan(0, 0, 3));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(gestureUUID, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
GetClient().Self.PlayGesture(itm.AssetUUID);
|
||||
return BasicReply("Accepted", new [] { gesture });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return Failure("Invaild item UUID: "+ item, new [] { item });
|
||||
}
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, new TimeSpan(0, 0, 5));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
if (itm == null)
|
||||
{
|
||||
return Failure("Unable to find item: " + item, new [] { item });
|
||||
|
|
@ -203,7 +203,7 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return Failure("invaild folder uuid", new[] { folder });
|
||||
}
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, new TimeSpan(0,0,5));
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15));
|
||||
List<InventoryItem> wareables = new();
|
||||
if (contents == null)
|
||||
{
|
||||
|
|
@ -264,7 +264,7 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return Failure("Cant find target folder", new [] { name });
|
||||
}
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(AA.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, new TimeSpan(0, 0, 5));
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(AA.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15));
|
||||
List<InventoryItem> wareables = new();
|
||||
if (contents == null)
|
||||
{
|
||||
|
|
@ -303,7 +303,7 @@ namespace SecondBotEvents.Commands
|
|||
return Failure("Unable to find notecard folder");
|
||||
}
|
||||
List<UUID> purge_notecards = new();
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(NotecardFolder.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByDate, new TimeSpan(0, 0, 5));
|
||||
List<InventoryBase> contents = GetClient().Inventory.FolderContents(NotecardFolder.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByDate, TimeSpan.FromSeconds(15));
|
||||
foreach (InventoryBase C in contents)
|
||||
{
|
||||
InventoryItem A = (InventoryItem)C;
|
||||
|
|
@ -351,12 +351,12 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return Failure("Invaild avatar uuid", new[] { path, avatar });
|
||||
}
|
||||
UUID targetitem = GetClient().Inventory.FindObjectByPath(GetClient().Inventory.Store.RootFolder.UUID, GetClient().Self.AgentID, path, new TimeSpan(0, 0, 3));
|
||||
UUID targetitem = GetClient().Inventory.FindObjectByPath(GetClient().Inventory.Store.RootFolder.UUID, GetClient().Self.AgentID, path, TimeSpan.FromSeconds(15));
|
||||
if(targetitem == UUID.Zero)
|
||||
{
|
||||
return Failure("Unable to find item via path", new[] { path, avatar });
|
||||
}
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, new TimeSpan(0, 0, 3));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
if (itm == null)
|
||||
{
|
||||
return Failure("Unable to find item with found uuid", new[] { path, avatar });
|
||||
|
|
@ -384,7 +384,7 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
return Failure("Invaild item uuid", new [] { item, avatar });
|
||||
}
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, new TimeSpan(0, 0, 3));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
if (itm == null)
|
||||
{
|
||||
return Failure("Unable to find item", new [] { item, avatar });
|
||||
|
|
@ -469,7 +469,7 @@ namespace SecondBotEvents.Commands
|
|||
return Failure("Invaild running", new [] { item, objectuuid, running });
|
||||
}
|
||||
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(itemuuid, GetClient().Self.AgentID, new TimeSpan(0, 0, 3));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(itemuuid, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
if (itm == null)
|
||||
{
|
||||
return Failure("Unable to find inventory", new [] { item, objectuuid, running });
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
using OpenMetaverse;
|
||||
using Newtonsoft.Json;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using SecondBotEvents.Services;
|
||||
using static OpenAI.ObjectModels.StaticValues.AssistantsStatics.MessageStatics;
|
||||
|
||||
|
||||
namespace SecondBotEvents.Commands
|
||||
|
|
@ -11,6 +14,78 @@ namespace SecondBotEvents.Commands
|
|||
{
|
||||
}
|
||||
|
||||
[About("Reads the notecards content, if it is able to read the notecard will give a json reply of notecarduuid name and contents")]
|
||||
[ReturnHintsFailure("Not a vaild UUID")]
|
||||
[ReturnHintsFailure("Unable to find inventory item")]
|
||||
[ReturnHintsFailure("Inventory item is not a notecard")]
|
||||
[ReturnHintsFailure("replytarget not set")]
|
||||
[ReturnHints("Making request to get data from notecard")]
|
||||
[ArgHints("notecardInventoryUUID", "The inventory UUID of the notecard to read")]
|
||||
[ArgHints("replytarget", "where to send the results to (smartreply target Avatar UUID, HTTP url, chat channel")]
|
||||
public object NotecardRead(string notecardInventoryUUID, string replytarget)
|
||||
{
|
||||
if(SecondbotHelpers.isempty(replytarget) == true)
|
||||
{
|
||||
return Failure("replytarget not set");
|
||||
}
|
||||
NotecardReadReply reply = new NotecardReadReply();
|
||||
reply.uuid = notecardInventoryUUID;
|
||||
reply.name = "?";
|
||||
reply.status = false;
|
||||
reply.content = "Not a vaild UUID";
|
||||
if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false)
|
||||
{
|
||||
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
|
||||
return Failure(reply.content, new[] { notecardInventoryUUID });
|
||||
}
|
||||
reply.content = "Unable to find inventory item";
|
||||
InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30));
|
||||
if (item == null)
|
||||
{
|
||||
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
|
||||
return Failure(reply.content, new[] { notecardInventoryUUID });
|
||||
}
|
||||
reply.content = "Inventory item is not a notecard";
|
||||
if (item.InventoryType != InventoryType.Notecard)
|
||||
{
|
||||
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
|
||||
return Failure(reply.content, new[] { notecardInventoryUUID }); ;
|
||||
}
|
||||
InventoryNotecard notecard = (InventoryNotecard)item;
|
||||
GetClient().Assets.RequestInventoryAsset(notecard, true, UUID.Random(), (AssetDownload transfer, Asset asset) =>
|
||||
{
|
||||
if (transfer.Success == false)
|
||||
{
|
||||
reply.content = "!ERROR! - unable to read notecard";
|
||||
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetNotecard note = (AssetNotecard)asset;
|
||||
note.Decode();
|
||||
string contents = "";
|
||||
for (int index = 0; index < note.BodyText.Length; index++)
|
||||
{
|
||||
char c = note.BodyText[index];
|
||||
if ((int)c == 0xdbc0)
|
||||
{
|
||||
contents = "[ATTACHMENT]";
|
||||
}
|
||||
else
|
||||
{
|
||||
contents += c;
|
||||
}
|
||||
}
|
||||
reply.content = contents;
|
||||
reply.name = notecard.Name;
|
||||
reply.status = true;
|
||||
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
|
||||
}
|
||||
}
|
||||
);
|
||||
return BasicReply("Making request to get data from notecard");
|
||||
}
|
||||
|
||||
[About("Adds content to the Collection<br/> Also creates the Collection if it does not exist")]
|
||||
[ReturnHintsFailure("Collection value is empty")]
|
||||
[ReturnHintsFailure("Content value is empty")]
|
||||
|
|
@ -114,4 +189,12 @@ namespace SecondBotEvents.Commands
|
|||
return BasicReply("ok");
|
||||
}
|
||||
}
|
||||
|
||||
public class NotecardReadReply
|
||||
{
|
||||
public string uuid;
|
||||
public string name;
|
||||
public string content;
|
||||
public bool status;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ namespace SecondBotEvents.Services
|
|||
{
|
||||
return chatHistoryAI[store]; // nothing in memory use the default store
|
||||
}
|
||||
redisDb.KeyExpire(readkey, new TimeSpan(0, myConfig.GetRedisMaxageMins(), 0)); // update the expire value
|
||||
redisDb.KeyExpire(readkey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins())); // update the expire value
|
||||
return JsonConvert.DeserializeObject<List<KeyValuePair<string, string>>>(rawstring);
|
||||
}
|
||||
return NoRedisStoreFound(store);
|
||||
|
|
@ -459,7 +459,7 @@ namespace SecondBotEvents.Services
|
|||
RedisValue storeme = new RedisValue(savestring);
|
||||
if(redisDb.StringSet(writekey, storeme) == true)
|
||||
{
|
||||
return redisDb.KeyExpire(writekey, new TimeSpan(0, myConfig.GetRedisMaxageMins(), 0));
|
||||
return redisDb.KeyExpire(writekey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ namespace SecondBotEvents.Services
|
|||
master.DataStoreService.AddAvatar(e.Offer.FromAgentID, e.Offer.FromAgentName);
|
||||
details.Add("itemuuid", e.ObjectID.ToString());
|
||||
details.Add("itemname", "?");
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(e.ObjectID, GetClient().Self.AgentID, new TimeSpan(0, 0, 2));
|
||||
InventoryItem itm = GetClient().Inventory.FetchItem(e.ObjectID, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
if(itm != null)
|
||||
{
|
||||
details["itemname"] = itm.Name;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace BetterSecondBot.Static
|
|||
{
|
||||
public static InventoryItem getItemByInventoryUUID(GridClient bot, UUID target)
|
||||
{
|
||||
return bot.Inventory.FetchItem(target, bot.Self.AgentID, new TimeSpan(0, 0, 3));
|
||||
return bot.Inventory.FetchItem(target, bot.Self.AgentID, TimeSpan.FromSeconds(15));
|
||||
}
|
||||
public static UUID GetAssetUUID(GridClient bot, UUID target)
|
||||
{
|
||||
|
|
@ -123,7 +123,7 @@ namespace BetterSecondBot.Static
|
|||
mapitem.id = node.Data.UUID.ToString();
|
||||
mapitem.typename = "Folder";
|
||||
entrys.Add(mapitem);
|
||||
List<InventoryBase> contents = bot.Inventory.FolderContents(folder, bot.Self.AgentID, true, true, InventorySortOrder.ByDate, new TimeSpan(0, 0, 45), true);
|
||||
List<InventoryBase> contents = bot.Inventory.FolderContents(folder, bot.Self.AgentID, true, true, InventorySortOrder.ByDate, TimeSpan.FromSeconds(45), true);
|
||||
if (contents != null)
|
||||
{
|
||||
if (contents.Count > 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue