update UploadMediaWave command and create SetInventoryUpdate command

This commit is contained in:
Madpeter 2021-11-20 09:52:33 +00:00
parent fcb1cdff79
commit 0c42bb58d7

View file

@ -19,9 +19,26 @@ namespace BetterSecondBot.HttpService
public HTTP_Inventory(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { } public HTTP_Inventory(SecondBot mainbot, TokenStorage setuptokens) : base(mainbot, setuptokens) { }
[About("Does a thing")]
[About("Attachs an event for inventory changes")]
[ReturnHints("cleared")]
[ReturnHints("No action")]
[ReturnHints("Event added")]
[ArgHints("inventoryType", "URLARG", "Types: texture,sound,callcard,landmark,clothing,object,notecard,lsltext,lslbyte,animatn,gesture,mesh")]
[ArgHints("outputTarget", "text", "HTTP url, channel, avatar UUID or clear to remove all events for the selected type")]
[Route(HttpVerbs.Post, "/SetInventoryUpdate/{inventoryType}/{token}")]
public object SetInventoryUpdate(string inventoryType, [FormField] string outputTarget, string token)
{
if (tokens.Allow(token, "inventory", "SetInventoryUpdate", handleGetClientIP()) == false)
{
return Failure("Token not accepted", "SetInventoryUpdate");
}
return BasicReply(bot.addInventoryUpdateEvent(inventoryType, outputTarget), "SetInventoryUpdate");
}
[About("Uploads a new sound file to inventory")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ArgHints("sourcePath", "Text", "The path to the wavefile")] [ArgHints("sourcePath", "Text", "accepts a file path to a wave PCM file @ 44100")]
[ArgHints("inventoryName", "URLARG", "the name in secondlife")] [ArgHints("inventoryName", "URLARG", "the name in secondlife")]
[Route(HttpVerbs.Post, "/UploadMediaWave/{inventoryName}/{token}")] [Route(HttpVerbs.Post, "/UploadMediaWave/{inventoryName}/{token}")]
public object UploadMediaWave([FormField] string sourcePath, string inventoryName, string token) public object UploadMediaWave([FormField] string sourcePath, string inventoryName, string token)
@ -46,13 +63,9 @@ namespace BetterSecondBot.HttpService
S.AssetData = audioData; S.AssetData = audioData;
S.Encode(); S.Encode();
bot.GetClient.Inventory.RequestCreateItemFromAsset(S.AssetData, inventoryName, "", AssetType.Sound, InventoryType.Sound, AA.UUID, uploadFinished); bot.GetClient.Inventory.RequestCreateItemFromAsset(S.AssetData, inventoryName, "", AssetType.Sound, InventoryType.Sound, AA.UUID, null);
return BasicReply("ok", "UploadMediaWave"); return BasicReply("ok", "UploadMediaWave");
} }
private void uploadFinished(bool success, string status, UUID itemID, UUID assetID)
{
bot.GetClient.Self.Chat("Success: " + success + " status:" + status + " Inv: " + itemID.ToString() + " Ass:" + assetID.ToString(), 0, ChatType.Normal);
}
[About("rezs the item at the bots current location")] [About("rezs the item at the bots current location")]