adds 4 new commands for avatar levels

GetProfileImage, SetProfileImage, GetProfileAbout, SetProfileAbout
This commit is contained in:
Madpeter 2024-08-23 14:08:13 +01:00
parent c338b9c617
commit 74f0ef29a8
3 changed files with 118 additions and 3 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using Newtonsoft.Json; using Newtonsoft.Json;
using SecondBotEvents.Services; using SecondBotEvents.Services;
using System.Threading.Tasks;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -42,6 +43,97 @@ namespace SecondBotEvents.Commands
return BasicReply(JsonConvert.SerializeObject(BetterNearMe)); return BasicReply(JsonConvert.SerializeObject(BetterNearMe));
} }
[About("Requests the given avatars profile image")]
[ReturnHints("profile UUID")]
[ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHints("Requesting avatar details [Retry later]")]
[ArgHints("avatar", "a UUID or Firstname Lastname")]
public object GetProfileImage(string avatar)
{
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar uuid", new[] { avatar });
}
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid);
if(reply.Key == false)
{
return Failure("Requesting avatar details [Retry later]", new[] { avatar });
}
return BasicReply(reply.Value.ProfileImage.ToString());
}
[About("Requests the bot updates its profile image")]
[ReturnHints("ok")]
[ReturnHints("Requesting avatar details [Retry later]")]
[ReturnHintsFailure("Invaild texture uuid")]
[ArgHints("texture", "a UUID of a texture to use")]
public object SetProfileImage(string texture)
{
if (UUID.TryParse(texture, out UUID textureUUID) == false)
{
return Failure("Invaild texture uuid\"", new[] { texture });
}
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID);
if (reply.Key == false)
{
return Failure("Requesting avatar details [Retry later]", new[] { texture });
}
Avatar.AvatarProperties props = reply.Value;
props.ProfileImage = textureUUID;
GetClient().Self.UpdateProfile(props);
return BasicReply("ok");
}
[About("Requests the given avatars profile about me")]
[ReturnHints("profile UUID")]
[ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHints("Requesting avatar details [Retry later]")]
[ArgHints("avatar", "a UUID or Firstname Lastname")]
public object GetProfileAbout(string avatar)
{
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar uuid", new[] { avatar });
}
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid);
if (reply.Key == false)
{
return Failure("Requesting avatar details [Retry later]", new[] { avatar });
}
return BasicReply(reply.Value.AboutText.ToString());
}
[About("Requests the bot updates its about me")]
[ReturnHints("ok")]
[ReturnHints("Requesting avatar details [Retry later]")]
[ReturnHintsFailure("about text to short")]
[ReturnHintsFailure("about text to long")]
[ArgHints("abouttext", "text to use in the about me area, length 10 to 300")]
public object SetProfileAbout(string abouttext)
{
if(abouttext.Length < 10)
{
return Failure("About text to short", new string[] { abouttext });
}
else if (abouttext.Length > 300)
{
return Failure("About text to long", new string[] { abouttext });
}
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID);
if (reply.Key == false)
{
return Failure("Requesting avatar details [Retry later]", new[] { abouttext });
}
Avatar.AvatarProperties props = reply.Value;
props.AboutText = abouttext;
GetClient().Self.UpdateProfile(props);
return BasicReply("ok");
}
[About("returns a list of all known avatars nearby")] [About("returns a list of all known avatars nearby")]
[ReturnHints("array UUID = Name")] [ReturnHints("array UUID = Name")]
[ReturnHintsFailure("Error not in a sim")] [ReturnHintsFailure("Error not in a sim")]

View file

@ -394,8 +394,8 @@ namespace SecondBotEvents.Commands
} }
[About("Sends a folder to an avatar")] [About("Sends a folder to an avatar")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("Invaild avatar uuid")] [ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHints("Unable to find folder")] [ReturnHintsFailure("Unable to find folder")]
[ArgHints("path", "path to the folder from root")] [ArgHints("path", "path to the folder from root")]
[ArgHints("avatar", "a UUID or Firstname Lastname")] [ArgHints("avatar", "a UUID or Firstname Lastname")]
public object SendFolderByPath(string path, string avatar) public object SendFolderByPath(string path, string avatar)

View file

@ -43,6 +43,7 @@ namespace SecondBotEvents.Services
protected long lastCleanupKeyValueStore = 0; protected long lastCleanupKeyValueStore = 0;
protected long lastCleanupAvatarStore = 0; protected long lastCleanupAvatarStore = 0;
@ -153,7 +154,7 @@ namespace SecondBotEvents.Services
int sum = commandHistories.Count + KeyValueStoreLastUsed.Count + KeyValueStore.Count + int sum = commandHistories.Count + KeyValueStoreLastUsed.Count + KeyValueStore.Count +
chatWindowsOwner.Count + chatWindowsIsGroup.Count + chatWindowsUnread.Count + chatWindowsOwner.Count + chatWindowsIsGroup.Count + chatWindowsUnread.Count +
chatWindows.Count + localChatHistory.Count + groupRoles.Count + chatWindows.Count + localChatHistory.Count + groupRoles.Count +
groupMembers.Count + groupsKey2Name.Count + avatarsName2Key.Count; groupMembers.Count + groupsKey2Name.Count + avatarsName2Key.Count + avprops.Count;
return sum.ToString(); return sum.ToString();
} }
@ -901,6 +902,26 @@ namespace SecondBotEvents.Services
} }
Dictionary<UUID, Avatar.AvatarProperties> avprops = new Dictionary<UUID, Avatar.AvatarProperties>();
public KeyValuePair<bool,Avatar.AvatarProperties> GetAvatarAvatarProperties(UUID agentID)
{
if (avprops.ContainsKey(agentID) == false)
{
GetClient().Avatars.RequestAvatarProperties(agentID);
return new KeyValuePair<bool, Avatar.AvatarProperties>(false, new Avatar.AvatarProperties());
}
return new KeyValuePair<bool, Avatar.AvatarProperties>(true, avprops[agentID]);
}
protected void AvatarDetailsReply(object sender, AvatarPropertiesReplyEventArgs e)
{
if(avprops.ContainsKey(e.AvatarID) == false)
{
avprops.Add(e.AvatarID,new Avatar.AvatarProperties());
}
avprops[e.AvatarID] = e.Properties;
}
protected void attachEventsAfterDelay() protected void attachEventsAfterDelay()
{ {
GetClient().Groups.CurrentGroups += GroupCurrent; GetClient().Groups.CurrentGroups += GroupCurrent;
@ -915,6 +936,7 @@ namespace SecondBotEvents.Services
GetClient().Groups.GroupRoleDataReply += GroupRoles; GetClient().Groups.GroupRoleDataReply += GroupRoles;
GetClient().Estate.EstateBansReply += EstateBans; GetClient().Estate.EstateBansReply += EstateBans;
GetClient().Friends.FriendFoundReply += FindFriendReply; GetClient().Friends.FriendFoundReply += FindFriendReply;
GetClient().Avatars.AvatarPropertiesReply += AvatarDetailsReply;
GetClient().Groups.RequestCurrentGroups(); GetClient().Groups.RequestCurrentGroups();
GetClient().Self.RetrieveInstantMessages(); GetClient().Self.RetrieveInstantMessages();
} }
@ -1130,6 +1152,7 @@ namespace SecondBotEvents.Services
GetClient().Groups.GroupRoleDataReply -= GroupRoles; GetClient().Groups.GroupRoleDataReply -= GroupRoles;
GetClient().Estate.EstateBansReply -= EstateBans; GetClient().Estate.EstateBansReply -= EstateBans;
GetClient().Friends.FriendFoundReply -= FindFriendReply; GetClient().Friends.FriendFoundReply -= FindFriendReply;
GetClient().Avatars.AvatarPropertiesReply -= AvatarDetailsReply;
} }
} }