cleanup and CommandHistoryLogResults

This commit is contained in:
Madpeter 2025-02-12 20:25:52 +00:00
parent 63cad44d55
commit bc5ca85489
61 changed files with 885 additions and 1024 deletions

View file

@ -38,6 +38,7 @@ ENV basic_Username='' \
commands_Enabled='true' \ commands_Enabled='true' \
commands_ObjectMasterOptout='false' \ commands_ObjectMasterOptout='false' \
commands_AllowServiceControl='false' \ commands_AllowServiceControl='false' \
commands_CommandHistoryLogResults='false' \
datastore_AutoCleanAvatars='true' \ datastore_AutoCleanAvatars='true' \
datastore_AvatarsCleanAfterMins=10 \ datastore_AvatarsCleanAfterMins=10 \
datastore_LocalChatHistoryLimit=120 \ datastore_LocalChatHistoryLimit=120 \

View file

@ -7,14 +7,8 @@ using System.Linq;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Animations and Gestures")] [ClassInfo("Animations and Gestures")]
internal class AnimationCommands : CommandsAPI internal class AnimationCommands(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public AnimationCommands(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Toggles if animation requests from this avatar (used for remote poseballs) are accepted")] [About("Toggles if animation requests from this avatar (used for remote poseballs) are accepted")]
[ReturnHints("Granted perm animation")] [ReturnHints("Granted perm animation")]
[ReturnHints("Removed perm animation")] [ReturnHints("Removed perm animation")]
@ -25,7 +19,7 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return BasicReply("avatar lookup", new [] { avatar }); return BasicReply("avatar lookup", [avatar]);
} }
// @todo accept storage // @todo accept storage
return Failure("@todo"); return Failure("@todo");
@ -39,18 +33,18 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(gesture, out UUID gestureUUID) == false) if (UUID.TryParse(gesture, out UUID gestureUUID) == false)
{ {
return BasicReply("Error with gesture", new [] { gesture }); return BasicReply("Error with gesture", [gesture]);
} }
InventoryItem itm = GetClient().Inventory.FetchItem(gestureUUID, GetClient().Self.AgentID, TimeSpan.FromSeconds(15)); InventoryItem itm = GetClient().Inventory.FetchItem(gestureUUID, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
GetClient().Self.PlayGesture(itm.AssetUUID); GetClient().Self.PlayGesture(itm.AssetUUID);
return BasicReply("Accepted", new [] { gesture }); return BasicReply("Accepted", [gesture]);
} }
[About("Resets the animation stack for the bot")] [About("Resets the animation stack for the bot")]
[ReturnHints("Accepted - X stopped animations")] [ReturnHints("Accepted - X stopped animations")]
public object ResetAnimations() public object ResetAnimations()
{ {
List<UUID> animations = GetClient().Self.SignaledAnimations.Copy().Keys.ToList(); List<UUID> animations = [.. GetClient().Self.SignaledAnimations.Copy().Keys];
foreach (UUID anim in animations) foreach (UUID anim in animations)
{ {
GetClient().Self.AnimationStop(anim, true); GetClient().Self.AnimationStop(anim, true);

View file

@ -8,13 +8,8 @@ using System.Threading.Tasks;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Avatars near me and Key2Name and Name2Key lookups")] [ClassInfo("Avatars near me and Key2Name and Name2Key lookups")]
public class Avatars : CommandsAPI public class Avatars(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Avatars(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Adds avatars to the one time accept list for interactions")] [About("Adds avatars to the one time accept list for interactions")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar uuid")] [ReturnHintsFailure("Invaild avatar uuid")]
@ -28,7 +23,7 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { store, avatar, remove }); return Failure("Invaild avatar uuid", [store, avatar, remove]);
} }
bool toberemoved = false; bool toberemoved = false;
if((remove == "true") || (remove == "True")) if((remove == "true") || (remove == "True"))
@ -37,13 +32,13 @@ namespace SecondBotEvents.Commands
} }
if(master.DataStoreService.KnownStoreType(store) == false) if(master.DataStoreService.KnownStoreType(store) == false)
{ {
return Failure("Unknown store type", new[] { store, avatar, remove }); return Failure("Unknown store type", [store, avatar, remove]);
} }
if (master.DataStoreService.AddToAcceptNext(store, avataruuid, toberemoved) == false) if (master.DataStoreService.AddToAcceptNext(store, avataruuid, toberemoved) == false)
{ {
return Failure("Unable to process request store", new[] { store, avatar, remove }); return Failure("Unable to process request store", [store, avatar, remove]);
} }
return BasicReply("ok", new[] { store, avatar, remove }); return BasicReply("ok", [store, avatar, remove]);
} }
[About("Checks if the avatar is on the accept next list (without using the token) for the given store")] [About("Checks if the avatar is on the accept next list (without using the token) for the given store")]
[ReturnHints("true")] [ReturnHints("true")]
@ -57,17 +52,17 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { store, avatar }); return Failure("Invaild avatar uuid", [store, avatar]);
} }
if (master.DataStoreService.KnownStoreType(store) == false) if (master.DataStoreService.KnownStoreType(store) == false)
{ {
return Failure("Unknown store type", new[] { store, avatar }); return Failure("Unknown store type", [store, avatar]);
} }
if(master.DataStoreService.IsInAcceptNext(store,avataruuid) == false) if(master.DataStoreService.IsInAcceptNext(store,avataruuid) == false)
{ {
return BasicReply("false", new[] { store, avatar }); return BasicReply("false", [store, avatar]);
} }
return BasicReply("true", new[] { store, avatar }); return BasicReply("true", [store, avatar]);
} }
@ -80,19 +75,21 @@ namespace SecondBotEvents.Commands
{ {
return BasicReply("Error not in a sim"); return BasicReply("Error not in a sim");
} }
List<NearMeDetails> BetterNearMe = new List<NearMeDetails>(); List<NearMeDetails> BetterNearMe = [];
Dictionary<uint, Avatar> avcopy = GetClient().Network.CurrentSim.ObjectsAvatars.Copy(); Dictionary<uint, Avatar> avcopy = GetClient().Network.CurrentSim.ObjectsAvatars.Copy();
foreach (Avatar av in avcopy.Values) foreach (Avatar av in avcopy.Values)
{ {
if (av.ID != GetClient().Self.AgentID) if (av.ID != GetClient().Self.AgentID)
{ {
NearMeDetails details = new NearMeDetails(); NearMeDetails details = new()
details.id = av.ID.ToString(); {
details.name = av.Name; id = av.ID.ToString(),
details.x = (int)Math.Round(av.Position.X); name = av.Name,
details.y = (int)Math.Round(av.Position.Y); x = (int)Math.Round(av.Position.X),
details.z = (int)Math.Round(av.Position.Z); y = (int)Math.Round(av.Position.Y),
details.range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition)); z = (int)Math.Round(av.Position.Z),
range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition))
};
BetterNearMe.Add(details); BetterNearMe.Add(details);
} }
} }
@ -109,12 +106,12 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { avatar }); return Failure("Invaild avatar uuid", [avatar]);
} }
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid); KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid);
if(reply.Key == false) if(reply.Key == false)
{ {
return Failure("Requesting avatar details [Retry later]", new[] { avatar }); return Failure("Requesting avatar details [Retry later]", [avatar]);
} }
return BasicReply(reply.Value.ProfileImage.ToString()); return BasicReply(reply.Value.ProfileImage.ToString());
} }
@ -128,12 +125,12 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(texture, out UUID textureUUID) == false) if (UUID.TryParse(texture, out UUID textureUUID) == false)
{ {
return Failure("Invaild texture uuid\"", new[] { texture }); return Failure("Invaild texture uuid\"", [texture]);
} }
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID); KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID);
if (reply.Key == false) if (reply.Key == false)
{ {
return Failure("Requesting avatar details [Retry later]", new[] { texture }); return Failure("Requesting avatar details [Retry later]", [texture]);
} }
Avatar.AvatarProperties props = reply.Value; Avatar.AvatarProperties props = reply.Value;
props.ProfileImage = textureUUID; props.ProfileImage = textureUUID;
@ -151,12 +148,12 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { avatar }); return Failure("Invaild avatar uuid", [avatar]);
} }
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid); KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(avataruuid);
if (reply.Key == false) if (reply.Key == false)
{ {
return Failure("Requesting avatar details [Retry later]", new[] { avatar }); return Failure("Requesting avatar details [Retry later]", [avatar]);
} }
return BasicReply(reply.Value.AboutText.ToString()); return BasicReply(reply.Value.AboutText.ToString());
} }
@ -171,16 +168,16 @@ namespace SecondBotEvents.Commands
{ {
if(abouttext.Length < 10) if(abouttext.Length < 10)
{ {
return Failure("About text to short", new string[] { abouttext }); return Failure("About text to short", [abouttext]);
} }
else if (abouttext.Length > 300) else if (abouttext.Length > 300)
{ {
return Failure("About text to long", new string[] { abouttext }); return Failure("About text to long", [abouttext]);
} }
KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID); KeyValuePair<bool, Avatar.AvatarProperties> reply = master.DataStoreService.GetAvatarAvatarProperties(GetClient().Self.AgentID);
if (reply.Key == false) if (reply.Key == false)
{ {
return Failure("Requesting avatar details [Retry later]", new[] { abouttext }); return Failure("Requesting avatar details [Retry later]", [abouttext]);
} }
Avatar.AvatarProperties props = reply.Value; Avatar.AvatarProperties props = reply.Value;
props.AboutText = abouttext; props.AboutText = abouttext;
@ -199,7 +196,7 @@ namespace SecondBotEvents.Commands
{ {
return BasicReply("Error not in a sim"); return BasicReply("Error not in a sim");
} }
Dictionary<UUID, string> NearMe = new Dictionary<UUID, string>(); Dictionary<UUID, string> NearMe = [];
Dictionary<uint, Avatar> avcopy = GetClient().Network.CurrentSim.ObjectsAvatars.Copy(); Dictionary<uint, Avatar> avcopy = GetClient().Network.CurrentSim.ObjectsAvatars.Copy();
foreach (Avatar av in avcopy.Values) foreach (Avatar av in avcopy.Values)
{ {

View file

@ -5,12 +5,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Text based interaction,message status and history")] [ClassInfo("Text based interaction,message status and history")]
public class Chat : CommandsAPI public class Chat(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Chat(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("fetchs the last localchat messages")] [About("fetchs the last localchat messages")]
[ReturnHints("json encoded array")] [ReturnHints("json encoded array")]
public object LocalChatHistory() public object LocalChatHistory()
@ -27,11 +23,11 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.isempty(message) == true) if (SecondbotHelpers.isempty(message) == true)
{ {
return Failure("Message empty", new [] { channel, message }); return Failure("Message empty", [channel, message]);
} }
if(int.TryParse(channel,out int channelnum) == false) if(int.TryParse(channel,out int channelnum) == false)
{ {
return Failure("Invaild channel", new [] { channel, message }); return Failure("Invaild channel", [channel, message]);
} }
master.DataStoreService.BotRecordLocalchatReply(message); master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Normal); GetClient().Self.Chat(message, channelnum, ChatType.Normal);
@ -47,11 +43,11 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.isempty(message) == true) if (SecondbotHelpers.isempty(message) == true)
{ {
return Failure("Message empty", new[] { channel, message }); return Failure("Message empty", [channel, message]);
} }
if (int.TryParse(channel, out int channelnum) == false) if (int.TryParse(channel, out int channelnum) == false)
{ {
return Failure("Invaild channel", new[] { channel, message }); return Failure("Invaild channel", [channel, message]);
} }
master.DataStoreService.BotRecordLocalchatReply(message); master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Shout); GetClient().Self.Chat(message, channelnum, ChatType.Shout);
@ -67,11 +63,11 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.isempty(message) == true) if (SecondbotHelpers.isempty(message) == true)
{ {
return Failure("Message empty", new[] { channel, message }); return Failure("Message empty", [channel, message]);
} }
if (int.TryParse(channel, out int channelnum) == false) if (int.TryParse(channel, out int channelnum) == false)
{ {
return Failure("Invaild channel", new[] { channel, message }); return Failure("Invaild channel", [channel, message]);
} }
master.DataStoreService.BotRecordLocalchatReply(message); master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Whisper); GetClient().Self.Chat(message, channelnum, ChatType.Whisper);
@ -91,15 +87,15 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new [] { avatar, message }); return Failure("avatar lookup", [avatar, message]);
} }
if (SecondbotHelpers.isempty(message) == true) if (SecondbotHelpers.isempty(message) == true)
{ {
return Failure("Message empty", new [] { avatar, message }); return Failure("Message empty", [avatar, message]);
} }
master.DataStoreService.OpenChatWindow(false, avataruuid, avataruuid); master.DataStoreService.OpenChatWindow(false, avataruuid, avataruuid);
master.BotClient.SendIM(avataruuid, message); master.BotClient.SendIM(avataruuid, message);
return BasicReply("ok", new [] { avatar, message }); return BasicReply("ok", [avatar, message]);
} }
[About("gets a full list of all avatar chat windows")] [About("gets a full list of all avatar chat windows")]

View file

@ -3,11 +3,8 @@
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Used to test interaction with the bot... hello world for avartars")] [ClassInfo("Used to test interaction with the bot... hello world for avartars")]
public class Core : CommandsAPI public class Core(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Core(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Used to check connections")] [About("Used to check connections")]
[ReturnHints("world")] [ReturnHints("world")]
public object Hello() public object Hello()

View file

@ -5,12 +5,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Script dialog box interaction / events when displayed")] [ClassInfo("Script dialog box interaction / events when displayed")]
public class Dialogs : CommandsAPI public class Dialogs(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Dialogs(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("adds a avatar dialog relay target [or removes if it exists]")] [About("adds a avatar dialog relay target [or removes if it exists]")]
[ReturnHints("added")] [ReturnHints("added")]
[ReturnHints("removed")] [ReturnHints("removed")]
@ -79,7 +75,7 @@ namespace SecondBotEvents.Commands
{ {
if (int.TryParse(dialogid, out int dialogidnum) == false) if (int.TryParse(dialogid, out int dialogidnum) == false)
{ {
return Failure("bad dialog id", new [] { dialogid, buttontext }); return Failure("bad dialog id", [dialogid, buttontext]);
} }
return BasicReply(master.DialogService.DialogAction(dialogidnum, buttontext)); return BasicReply(master.DialogService.DialogAction(dialogidnum, buttontext));
} }

View file

@ -6,11 +6,8 @@ using System.Linq;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Control discord from the grid")] [ClassInfo("Control discord from the grid")]
public class DiscordCommands : CommandsAPI public class DiscordCommands(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public DiscordCommands(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Adds a discord server role to the selected member")] [About("Adds a discord server role to the selected member")]
[ReturnHintsFailure("Discord client not ready")] [ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")] [ReturnHints("true|false")]
@ -23,7 +20,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.AddRoleToMember(serverid, roleid, memberid).Result.ToString(), new [] { serverid, roleid, memberid }); return BasicReply(master.DiscordService.AddRoleToMember(serverid, roleid, memberid).Result.ToString(), [serverid, roleid, memberid]);
} }
[About("Adds the selected user to the ban list - Disallows rejoining untill they are removed from the list")] [About("Adds the selected user to the ban list - Disallows rejoining untill they are removed from the list")]
@ -41,9 +38,9 @@ namespace SecondBotEvents.Commands
} }
if (SecondbotHelpers.notempty(why) == false) if (SecondbotHelpers.notempty(why) == false)
{ {
return Failure("Why empty", new [] { serverid, memberid, why }); return Failure("Why empty", [serverid, memberid, why]);
} }
return BasicReply(master.DiscordService.BanMember(serverid, memberid, why).Result.ToString(), new [] { serverid, memberid, why }); return BasicReply(master.DiscordService.BanMember(serverid, memberid, why).Result.ToString(), [serverid, memberid, why]);
} }
public object Discord_GetMemberRoles(string serverid, string memberid) public object Discord_GetMemberRoles(string serverid, string memberid)
@ -71,7 +68,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.ClearMessages(serverid, memberid).Result.ToString(), new[] { serverid, memberid }); return BasicReply(master.DiscordService.ClearMessages(serverid, memberid).Result.ToString(), [serverid, memberid]);
} }
[About("Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev")] [About("Sends a message directly to the user [They must be in the server]\n This command requires the SERVER MEMBERS INTENT found in discord app dev")]
@ -86,7 +83,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.MessageMember(serverid, memberid, message).Result.ToString(), new [] { serverid, memberid, message }); return BasicReply(master.DiscordService.MessageMember(serverid, memberid, message).Result.ToString(), [serverid, memberid, message]);
} }
[About("Returns a list of members in a server \n collection is userid: username \n if the user has set a nickname: userid: nickname|username \n" + [About("Returns a list of members in a server \n collection is userid: username \n if the user has set a nickname: userid: nickname|username \n" +
@ -101,7 +98,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.ListMembers(serverid).Result.ToString(), new[] { serverid }); return BasicReply(master.DiscordService.ListMembers(serverid).Result.ToString(), [serverid]);
} }
[About("Sends a message to the selected channel - Optional TTS usage")] [About("Sends a message to the selected channel - Optional TTS usage")]
@ -120,9 +117,9 @@ namespace SecondBotEvents.Commands
} }
if (SecondbotHelpers.notempty(message) == false) if (SecondbotHelpers.notempty(message) == false)
{ {
return Failure("message empty", new [] { serverid, channelid, tts, message }); return Failure("message empty", [serverid, channelid, tts, message]);
} }
return BasicReply(master.DiscordService.MessageChannel(serverid, channelid, message, tts).Result.ToString(), new [] { serverid, channelid, tts, message }); return BasicReply(master.DiscordService.MessageChannel(serverid, channelid, message, tts).Result.ToString(), [serverid, channelid, tts, message]);
} }
[About("Sends a message to the selected channel - Optional TTS usage")] [About("Sends a message to the selected channel - Optional TTS usage")]
@ -137,7 +134,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.MuteMember(serverid, memberid, mode).Result.ToString(), new [] { serverid, memberid, mode }); return BasicReply(master.DiscordService.MuteMember(serverid, memberid, mode).Result.ToString(), [serverid, memberid, mode]);
} }
[About("returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected")] [About("returns a collection of settings for the given role \n This command requires Discord full client mode enabled and connected")]
@ -152,7 +149,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.RoleSettings(serverid, roleid).ToString(), new [] { serverid, roleid }); return BasicReply(master.DiscordService.RoleSettings(serverid, roleid).ToString(), [serverid, roleid]);
} }
[About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" + [About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" +
@ -168,7 +165,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.UpdateRolePerms(serverid, roleid, flagscsv).Result.ToString(), new [] { serverid, roleid, flagscsv }); return BasicReply(master.DiscordService.UpdateRolePerms(serverid, roleid, flagscsv).Result.ToString(), [serverid, roleid, flagscsv]);
} }
[About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" + [About("Updates perm flags for the selected role \n example CSV format: Speak=True,SendMessages=False \n for a full list of perms see output of Discord_Role_GetSettings \n" +
@ -183,7 +180,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.CreateRole(serverid, role).Result.ToString(), new[] { serverid, role }); return BasicReply(master.DiscordService.CreateRole(serverid, role).Result.ToString(), [serverid, role]);
} }
[About("Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected")] [About("Returns a list of roles and their ids in collection \n This command requires Discord full client mode enabled and connected")]
@ -196,7 +193,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.ListRoles(serverid).ToString(), new [] { serverid }); return BasicReply(master.DiscordService.ListRoles(serverid).ToString(), [serverid]);
} }
[About("Remove a role from a server \n This command requires Discord full client mode enabled and connected")] [About("Remove a role from a server \n This command requires Discord full client mode enabled and connected")]
@ -209,7 +206,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Discord client not ready"); return Failure("Discord client not ready");
} }
return BasicReply(master.DiscordService.RemoveRole(serverid, roleid).Result.ToString(), new [] { serverid, roleid }); return BasicReply(master.DiscordService.RemoveRole(serverid, roleid).Result.ToString(), [serverid, roleid]);
} }
[About("Returns a list of text channels in a server")] [About("Returns a list of text channels in a server")]

View file

@ -6,11 +6,8 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Look after a sim as the estate manager")] [ClassInfo("Look after a sim as the estate manager")]
public class Estate : CommandsAPI public class Estate(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Estate(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Sends the message to the current sim")] [About("Sends the message to the current sim")]
[ReturnHints("restarting")] [ReturnHints("restarting")]
[ReturnHintsFailure("Not an estate manager here")] [ReturnHintsFailure("Not an estate manager here")]
@ -22,22 +19,21 @@ namespace SecondBotEvents.Commands
{ {
if (GetClient().Network.CurrentSim.IsEstateManager == false) if (GetClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager here", new [] { delay, mode }); return Failure("Not an estate manager here", [delay, mode]);
} }
bool.TryParse(mode, out bool modeflag); bool.TryParse(mode, out bool modeflag);
if (modeflag == false) if (modeflag == false)
{ {
GetClient().Estate.CancelRestart(); GetClient().Estate.CancelRestart();
return BasicReply("canceled", new [] { delay, mode }); return BasicReply("canceled", [delay, mode]);
} }
int delay_restart = 60; int.TryParse(delay, out int delay_restart);
int.TryParse(delay, out delay_restart);
if ((delay_restart < 30) || (delay_restart > 240)) if ((delay_restart < 30) || (delay_restart > 240))
{ {
delay_restart = 240; delay_restart = 240;
} }
GetClient().Estate.RestartRegion(delay_restart); GetClient().Estate.RestartRegion(delay_restart);
return BasicReply("restarting", new [] { delay, mode }); return BasicReply("restarting", [delay, mode]);
} }
[About("Sends the message to the current sim")] [About("Sends the message to the current sim")]
@ -49,14 +45,14 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(message) == false) if (SecondbotHelpers.notempty(message) == false)
{ {
return Failure("Message empty", new [] { message }); return Failure("Message empty", [message]);
} }
if (GetClient().Network.CurrentSim.IsEstateManager == false) if (GetClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager here", new [] { message }); return Failure("Not an estate manager here", [message]);
} }
GetClient().Estate.SimulatorMessage(message); GetClient().Estate.SimulatorMessage(message);
return BasicReply("ok", new [] { message }); return BasicReply("ok", [message]);
} }
[About("Fetchs the regions map tile")] [About("Fetchs the regions map tile")]
@ -67,9 +63,9 @@ namespace SecondBotEvents.Commands
{ {
if (GetClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false) if (GetClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
{ {
return Failure("Unable to find region", new [] { regionname }); return Failure("Unable to find region", [regionname]);
} }
return BasicReply(region.MapImageID.ToString(), new [] { regionname }); return BasicReply(region.MapImageID.ToString(), [regionname]);
} }
[About("Reclaims ownership of the current parcel")] [About("Reclaims ownership of the current parcel")]
@ -94,12 +90,14 @@ namespace SecondBotEvents.Commands
{ {
if (GetClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false) if (GetClient().Grid.GetGridRegion(regionname, GridLayerType.Objects, out GridRegion region) == false)
{ {
return Failure("Unable to find region", new [] { regionname }); return Failure("Unable to find region", [regionname]);
} }
Dictionary<string, string> reply = new Dictionary<string, string>(); Dictionary<string, string> reply = new()
reply.Add("region", regionname); {
reply.Add("X", region.X.ToString()); { "region", regionname },
reply.Add("Y", region.Y.ToString()); { "X", region.X.ToString() },
{ "Y", region.Y.ToString() }
};
return BasicReply(JsonConvert.SerializeObject(reply)); return BasicReply(JsonConvert.SerializeObject(reply));
} }
@ -124,25 +122,24 @@ namespace SecondBotEvents.Commands
{ {
if (GetClient().Network.CurrentSim.IsEstateManager == false) if (GetClient().Network.CurrentSim.IsEstateManager == false)
{ {
return Failure("Not an estate manager on region " + GetClient().Network.CurrentSim.Name, new [] { avatar, mode, global }); return Failure("Not an estate manager on region " + GetClient().Network.CurrentSim.Name, [avatar, mode, global]);
} }
UUID avataruuid = UUID.Zero; UUID avataruuid = UUID.Zero;
if (UUID.TryParse(avatar, out avataruuid) == false) if (UUID.TryParse(avatar, out avataruuid) == false)
{ {
return Failure("Unable to find avatar UUID", new [] { avatar, mode, global }); return Failure("Unable to find avatar UUID", [avatar, mode, global]);
} }
bool globalban = false; if (bool.TryParse(global, out bool globalban) == false)
if (bool.TryParse(global, out globalban) == false)
{ {
return Failure("Unable to process global value please use true or false", new [] { avatar, mode, global }); return Failure("Unable to process global value please use true or false", [avatar, mode, global]);
} }
if (mode != "add") if (mode != "add")
{ {
GetClient().Estate.UnbanUser(avataruuid, globalban); GetClient().Estate.UnbanUser(avataruuid, globalban);
return BasicReply("Unban request accepted", new [] { avatar, mode, global }); return BasicReply("Unban request accepted", [avatar, mode, global]);
} }
GetClient().Estate.BanUser(avataruuid, globalban); GetClient().Estate.BanUser(avataruuid, globalban);
return BasicReply("Ban request accepted", new [] { avatar, mode, global }); return BasicReply("Ban request accepted", [avatar, mode, global]);
} }
} }
} }

View file

@ -6,12 +6,8 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("The power of friendship")] [ClassInfo("The power of friendship")]
public class Friends : CommandsAPI public class Friends(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Friends(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Gets the location of a friend if map access was given \n also requests a update")] [About("Gets the location of a friend if map access was given \n also requests a update")]
[ReturnHints("a json object of global region X,Y sim X,Y,Z and time it was updated")] [ReturnHints("a json object of global region X,Y sim X,Y,Z and time it was updated")]
[ReturnHintsFailure("avatar lookup")] [ReturnHintsFailure("avatar lookup")]
@ -23,20 +19,20 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new[] { avatar }); return Failure("avatar lookup", [avatar]);
} }
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy(); Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
if(FriendListCopy.ContainsKey(avataruuid) == false) if(FriendListCopy.ContainsKey(avataruuid) == false)
{ {
return Failure("not in friends list (updating)", new[] { avatar }); return Failure("not in friends list (updating)", [avatar]);
} }
GetClient().Friends.MapFriend(avataruuid); GetClient().Friends.MapFriend(avataruuid);
FriendLocations loc = master.DataStoreService.GetFriendMap(avataruuid); FriendLocations loc = master.DataStoreService.GetFriendMap(avataruuid);
if(loc == null) if(loc == null)
{ {
return Failure("no map access or updating", new[] { avatar }); return Failure("no map access or updating", [avatar]);
} }
return BasicReply(JsonConvert.SerializeObject(loc), new[] { avatar }); return BasicReply(JsonConvert.SerializeObject(loc), [avatar]);
} }
[About("Gets the friendslist")] [About("Gets the friendslist")]
@ -44,14 +40,16 @@ namespace SecondBotEvents.Commands
public object Friendslist() public object Friendslist()
{ {
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy(); Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
List< FriendListEntry > CleanedFriendsList = new List< FriendListEntry >(); List< FriendListEntry > CleanedFriendsList = [];
int index = 0; int index = 0;
foreach (FriendInfo A in FriendListCopy.Values) foreach (FriendInfo A in FriendListCopy.Values)
{ {
FriendListEntry entry = new FriendListEntry(); FriendListEntry entry = new()
entry.id = A.UUID.ToString(); {
entry.name = A.Name; id = A.UUID.ToString(),
entry.online = A.IsOnline; name = A.Name,
online = A.IsOnline
};
CleanedFriendsList.Add(entry); CleanedFriendsList.Add(entry);
index++; index++;
} }
@ -71,24 +69,23 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new [] { avatar, state }); return Failure("avatar lookup", [avatar, state]);
} }
bool status = false; if (bool.TryParse(state, out bool status) == false)
if (bool.TryParse(state, out status) == false)
{ {
return Failure("state invaild", new [] { avatar, state }); return Failure("state invaild", [avatar, state]);
} }
if (GetClient().Friends.FriendList.ContainsKey(avataruuid) == false) if (GetClient().Friends.FriendList.ContainsKey(avataruuid) == false)
{ {
return Failure("Not A friend", new [] { avatar, state }); return Failure("Not A friend", [avatar, state]);
} }
if (status == true) if (status == true)
{ {
GetClient().Friends.GrantRights(avataruuid, FriendRights.CanSeeOnline | FriendRights.CanSeeOnMap | FriendRights.CanModifyObjects); GetClient().Friends.GrantRights(avataruuid, FriendRights.CanSeeOnline | FriendRights.CanSeeOnMap | FriendRights.CanModifyObjects);
return BasicReply("granted", new [] { avatar, state }); return BasicReply("granted", [avatar, state]);
} }
GetClient().Friends.GrantRights(avataruuid, FriendRights.None); GetClient().Friends.GrantRights(avataruuid, FriendRights.None);
return BasicReply("removed", new [] { avatar, state }); return BasicReply("removed", [avatar, state]);
} }
[About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")] [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]
@ -105,27 +102,26 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new [] { avatar, state }); return Failure("avatar lookup", [avatar, state]);
} }
bool status = false; if (bool.TryParse(state, out bool status) == false)
if (bool.TryParse(state, out status) == false)
{ {
return Failure("state invaild", new [] { avatar, state }); return Failure("state invaild", [avatar, state]);
} }
if (GetClient().Friends.FriendList.ContainsKey(avataruuid) == true) if (GetClient().Friends.FriendList.ContainsKey(avataruuid) == true)
{ {
if (status == false) if (status == false)
{ {
GetClient().Friends.TerminateFriendship(avataruuid); GetClient().Friends.TerminateFriendship(avataruuid);
return BasicReply("Removed", new [] { avatar, state }); return BasicReply("Removed", [avatar, state]);
} }
} }
if (status == false) if (status == false)
{ {
return Failure("Not in friendslist", new [] { avatar, state }); return Failure("Not in friendslist", [avatar, state]);
} }
GetClient().Friends.OfferFriendship(avataruuid); GetClient().Friends.OfferFriendship(avataruuid);
return BasicReply("Request sent", new [] { avatar, state }); return BasicReply("Request sent", [avatar, state]);
} }
} }

View file

@ -5,11 +5,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Money makes the world go round")] [ClassInfo("Money makes the world go round")]
public class Funds : CommandsAPI public class Funds(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Funds(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Requests the current balance and requests the balance to update.")] [About("Requests the current balance and requests the balance to update.")]
[ReturnHints("Current fund level")] [ReturnHints("Current fund level")]
[ReturnHintsFailure("Funds commands are disabled")] [ReturnHintsFailure("Funds commands are disabled")]
@ -35,24 +32,24 @@ namespace SecondBotEvents.Commands
{ {
if (master.CommandsService.myConfig.GetAllowFundsCommands() == false) if (master.CommandsService.myConfig.GetAllowFundsCommands() == false)
{ {
return Failure("Transfer funds to avatars disabled", new [] { avatar, amount }); return Failure("Transfer funds to avatars disabled", [avatar, amount]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return BasicReply("avatar lookup", new [] { avatar, amount }); return BasicReply("avatar lookup", [avatar, amount]);
} }
if (int.TryParse(amount, out int amountvalue) == false) if (int.TryParse(amount, out int amountvalue) == false)
{ {
return Failure("Invaild amount", new [] { avatar, amount }); return Failure("Invaild amount", [avatar, amount]);
} }
if ((amountvalue < 0) || (amountvalue > GetClient().Self.Balance)) if ((amountvalue < 0) || (amountvalue > GetClient().Self.Balance))
{ {
GetClient().Self.RequestBalance(); GetClient().Self.RequestBalance();
return Failure("Amount out of range current max: "+ GetClient().Self.Balance.ToString(), new [] { avatar, amount }); return Failure("Amount out of range current max: "+ GetClient().Self.Balance.ToString(), [avatar, amount]);
} }
GetClient().Self.GiveAvatarMoney(avataruuid, amountvalue); GetClient().Self.GiveAvatarMoney(avataruuid, amountvalue);
return BasicReply("Accepted", new [] { avatar, amount }); return BasicReply("Accepted", [avatar, amount]);
} }
[About("Makes the bot pay a object")] [About("Makes the bot pay a object")]
@ -69,26 +66,26 @@ namespace SecondBotEvents.Commands
{ {
if (master.CommandsService.myConfig.GetAllowFundsCommands() == false) if (master.CommandsService.myConfig.GetAllowFundsCommands() == false)
{ {
return Failure("Funds commands are disabled", new [] { objectuuid, primname, amount }); return Failure("Funds commands are disabled", [objectuuid, primname, amount]);
} }
if (UUID.TryParse(objectuuid, out UUID objectUUID) == false) if (UUID.TryParse(objectuuid, out UUID objectUUID) == false)
{ {
return Failure("Invaild object UUID", new [] { objectuuid, primname, amount }); return Failure("Invaild object UUID", [objectuuid, primname, amount]);
} }
if (int.TryParse(amount, out int amountvalue) == false) if (int.TryParse(amount, out int amountvalue) == false)
{ {
return Failure("Invaild amount", new [] { objectuuid, primname, amount }); return Failure("Invaild amount", [objectuuid, primname, amount]);
} }
if((amountvalue < 0) || (amountvalue > GetClient().Self.Balance)) if((amountvalue < 0) || (amountvalue > GetClient().Self.Balance))
{ {
return Failure("Amount out of range", new [] { objectuuid, primname, amount }); return Failure("Amount out of range", [objectuuid, primname, amount]);
} }
if(SecondbotHelpers.notempty(primname) == false) if(SecondbotHelpers.notempty(primname) == false)
{ {
return Failure("Primname is empty", new [] { objectuuid, primname, amount }); return Failure("Primname is empty", [objectuuid, primname, amount]);
} }
GetClient().Self.GiveObjectMoney(objectUUID, amountvalue, primname); GetClient().Self.GiveObjectMoney(objectUUID, amountvalue, primname);
return BasicReply("ok", new [] { objectuuid, primname, amount }); return BasicReply("ok", [objectuuid, primname, amount]);
} }
} }
} }

View file

@ -6,12 +6,8 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Control groups with ease")] [ClassInfo("Control groups with ease")]
public class GroupCommands : CommandsAPI public class GroupCommands(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public GroupCommands(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Checks if the given UUID is in the given group<br/>Note: if group membership data is more than 60 secs old this will return Updating<br/>Please wait and retry later")] [About("Checks if the given UUID is in the given group<br/>Note: if group membership data is more than 60 secs old this will return Updating<br/>Please wait and retry later")]
[ReturnHints("Membership reply with [membershipStatus,AvatarUUID,AvatarnameIfKnown,GroupUUID]")] [ReturnHints("Membership reply with [membershipStatus,AvatarUUID,AvatarnameIfKnown,GroupUUID]")]
[ReturnHintsFailure("Updating")] [ReturnHintsFailure("Updating")]
@ -24,7 +20,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, avatar }); return Failure("Invaild group UUID", [group, avatar]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
return BasicReply(master.DataStoreService.IsGroupMember(groupuuid, avataruuid).ToString()); return BasicReply(master.DataStoreService.IsGroupMember(groupuuid, avataruuid).ToString());
@ -41,7 +37,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group }); return Failure("Invaild group UUID", [group]);
} }
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupMembers(groupuuid))); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupMembers(groupuuid)));
} }
@ -60,27 +56,27 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new[] { group, avatar, state }); return Failure("Invaild group UUID", [group, avatar, state]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new[] { group, avatar, state }); return Failure("Unknown group", [group, avatar, state]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Unknown avatar", new[] { group, avatar, state }); return Failure("Unknown avatar", [group, avatar, state]);
} }
GroupBanAction Action = GroupBanAction.Ban; GroupBanAction Action = GroupBanAction.Ban;
if (state == "false") if (state == "false")
{ {
Action = GroupBanAction.Unban; Action = GroupBanAction.Unban;
} }
List<UUID> avatarstoaction = new() List<UUID> avatarstoaction =
{ [
avataruuid avataruuid
}; ];
GetClient().Groups.RequestBanAction(groupuuid, Action, avatarstoaction.ToArray()); GetClient().Groups.RequestBanAction(groupuuid, Action, [.. avatarstoaction]);
return BasicReply("Accepted"); return BasicReply("Accepted");
} }
@ -100,16 +96,16 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, avatar }); return Failure("Invaild group UUID", [group, avatar]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new[] { group, avatar }); return Failure("Unknown group", [group, avatar]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Unknown avatar", new[] { group, avatar}); return Failure("Unknown avatar", [group, avatar]);
} }
GetClient().Groups.EjectUser(groupuuid, avataruuid); GetClient().Groups.EjectUser(groupuuid, avataruuid);
return BasicReply("Accepted"); return BasicReply("Accepted");
@ -129,20 +125,20 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, avatar }); return Failure("Invaild group UUID", [group, avatar]);
} }
if (UUID.TryParse(role, out UUID roleuuid) == false) if (UUID.TryParse(role, out UUID roleuuid) == false)
{ {
return Failure("Invaild role UUID", new [] { group, avatar }); return Failure("Invaild role UUID", [group, avatar]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new[] { group, avatar, role }); return Failure("Unknown group", [group, avatar, role]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(master.DataStoreService.IsGroupMember(groupuuid, avataruuid) == false) if(master.DataStoreService.IsGroupMember(groupuuid, avataruuid) == false)
{ {
GetClient().Groups.Invite(groupuuid, new List<UUID>() { UUID.Zero, roleuuid }, avataruuid); GetClient().Groups.Invite(groupuuid, [UUID.Zero, roleuuid], avataruuid);
return BasicReply("Invite sent"); return BasicReply("Invite sent");
} }
GetClient().Groups.AddToRole(groupuuid, roleuuid, avataruuid); GetClient().Groups.AddToRole(groupuuid, roleuuid, avataruuid);
@ -164,31 +160,31 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, avatar, role }); return Failure("Invaild group UUID", [group, avatar, role]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new[] { group, avatar, role }); return Failure("Unknown group", [group, avatar, role]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new [] { group, avatar, role }); return Failure("avatar lookup", [group, avatar, role]);
} }
List<UUID> roles = new() List<UUID> roles =
{ [
UUID.Zero UUID.Zero
}; ];
if (role != "everyone") if (role != "everyone")
{ {
if (UUID.TryParse(role, out UUID roleuuid) == false) if (UUID.TryParse(role, out UUID roleuuid) == false)
{ {
return Failure("Unable to process role UUID", new[] { group, avatar, role }); return Failure("Unable to process role UUID", [group, avatar, role]);
} }
roles.Add(roleuuid); roles.Add(roleuuid);
} }
GetClient().Groups.Invite(groupuuid, roles, avataruuid); GetClient().Groups.Invite(groupuuid, roles, avataruuid);
return BasicReply("Invite sent", new [] { group, avatar, role }); return BasicReply("Invite sent", [group, avatar, role]);
} }
[About("Sends a group notice (No attachments please use GroupnoticeWithAttachment to attach items!)")] [About("Sends a group notice (No attachments please use GroupnoticeWithAttachment to attach items!)")]
@ -205,19 +201,19 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, title, message }); return Failure("Invaild group UUID", [group, title, message]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new [] { group, title, message }); return Failure("Unknown group", [group, title, message]);
} }
if (SecondbotHelpers.notempty(title) == false) if (SecondbotHelpers.notempty(title) == false)
{ {
return Failure("Title empty", new [] { group, title, message }); return Failure("Title empty", [group, title, message]);
} }
if (SecondbotHelpers.notempty(message) == false) if (SecondbotHelpers.notempty(message) == false)
{ {
return Failure("Message empty", new [] { group, title, message }); return Failure("Message empty", [group, title, message]);
} }
GroupNotice NewNotice = new() GroupNotice NewNotice = new()
{ {
@ -226,7 +222,7 @@ namespace SecondBotEvents.Commands
OwnerID = GetClient().Self.AgentID OwnerID = GetClient().Self.AgentID
}; };
GetClient().Groups.SendGroupNotice(groupuuid, NewNotice); GetClient().Groups.SendGroupNotice(groupuuid, NewNotice);
return BasicReply("Sending notice", new [] { group, title, message }); return BasicReply("Sending notice", [group, title, message]);
} }
[About("Activates the selected title")] [About("Activates the selected title")]
@ -240,18 +236,18 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, role }); return Failure("Invaild group UUID", [group, role]);
} }
if (UUID.TryParse(role, out UUID roleuuid) == false) if (UUID.TryParse(role, out UUID roleuuid) == false)
{ {
return Failure("Invaild role UUID", new [] { group, role }); return Failure("Invaild role UUID", [group, role]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new [] { group, role }); return Failure("Unknown group", [group, role]);
} }
GetClient().Groups.ActivateTitle(groupuuid, roleuuid); GetClient().Groups.ActivateTitle(groupuuid, roleuuid);
return BasicReply("Switching title", new [] { group, role }); return BasicReply("Switching title", [group, role]);
} }
[About("Sets the selected group to the active group")] [About("Sets the selected group to the active group")]
@ -263,14 +259,14 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group }); return Failure("Invaild group UUID", [group]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new[] { group }); return Failure("Unknown group", [group]);
} }
GetClient().Groups.ActivateGroup(groupuuid); GetClient().Groups.ActivateGroup(groupuuid);
return BasicReply("Switching active group", new [] { group }); return BasicReply("Switching active group", [group]);
} }
[About("Sends a group notice with an attachment")] [About("Sends a group notice with an attachment")]
@ -289,23 +285,23 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group, title, message, attachment }); return Failure("Invaild group UUID", [group, title, message, attachment]);
} }
if (UUID.TryParse(attachment, out UUID inventoryuuid) == false) if (UUID.TryParse(attachment, out UUID inventoryuuid) == false)
{ {
return Failure("Invaild inventory UUID", new [] { group, title, message, attachment }); return Failure("Invaild inventory UUID", [group, title, message, attachment]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new [] { group, title, message, attachment }); return Failure("Unknown group", [group, title, message, attachment]);
} }
if (SecondbotHelpers.notempty(title) == false) if (SecondbotHelpers.notempty(title) == false)
{ {
return Failure("Title empty", new [] { group, title, message, attachment }); return Failure("Title empty", [group, title, message, attachment]);
} }
if (SecondbotHelpers.notempty(message) == false) if (SecondbotHelpers.notempty(message) == false)
{ {
return Failure("Message empty", new [] { group, title, message, attachment }); return Failure("Message empty", [group, title, message, attachment]);
} }
GroupNotice NewNotice = new() GroupNotice NewNotice = new()
{ {
@ -315,7 +311,7 @@ namespace SecondBotEvents.Commands
AttachmentID = inventoryuuid AttachmentID = inventoryuuid
}; };
GetClient().Groups.SendGroupNotice(groupuuid, NewNotice); GetClient().Groups.SendGroupNotice(groupuuid, NewNotice);
return BasicReply("Sending notice with attachment", new [] { group, title, message, attachment }); return BasicReply("Sending notice with attachment", [group, title, message, attachment]);
} }
@ -344,11 +340,11 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group UUID", new [] { group }); return Failure("Invaild group UUID", [group]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Unknown group", new [] { group }); return Failure("Unknown group", [group]);
} }
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupRoles(groupuuid))); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupRoles(groupuuid)));
} }
@ -369,11 +365,11 @@ namespace SecondBotEvents.Commands
{ {
if(UUID.TryParse(group,out UUID groupUUID) == false) if(UUID.TryParse(group,out UUID groupUUID) == false)
{ {
return Failure("group value is invaild", new [] { group }); return Failure("group value is invaild", [group]);
} }
if(GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false) if(GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false)
{ {
return Failure("Unknown group", new [] { group }); return Failure("Unknown group", [group]);
} }
return BasicReply(master.DataStoreService.GetGroupChatHasUnread(groupUUID).ToString()); return BasicReply(master.DataStoreService.GetGroupChatHasUnread(groupUUID).ToString());
} }
@ -402,7 +398,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupUUID) == false) if (UUID.TryParse(group, out UUID groupUUID) == false)
{ {
return Failure("Group UUID invaild", new [] { group }); return Failure("Group UUID invaild", [group]);
} }
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupChatHistory(groupUUID))); return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupChatHistory(groupUUID)));
} }
@ -417,15 +413,15 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(group, out UUID groupUUID) == false) if (UUID.TryParse(group, out UUID groupUUID) == false)
{ {
return Failure("group value is invaild", new [] { group, message }); return Failure("group value is invaild", [group, message]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false)
{ {
return Failure("Unknown group", new [] { group, message }); return Failure("Unknown group", [group, message]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false)
{ {
return Failure("Unknown group", new[] { group }); return Failure("Unknown group", [group]);
} }
GetClient().Self.InstantMessageGroup(groupUUID, message); GetClient().Self.InstantMessageGroup(groupUUID, message);
master.DataStoreService.BotRecordReplyIM(groupUUID, message); master.DataStoreService.BotRecordReplyIM(groupUUID, message);

View file

@ -7,20 +7,16 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("What is going on with the bot")] [ClassInfo("What is going on with the bot")]
public class Info : CommandsAPI public class Info(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Info(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Lists objects that are sculpty type in the current sim that the bot can see")] [About("Lists objects that are sculpty type in the current sim that the bot can see")]
[ReturnHints("A json object")] [ReturnHints("A json object")]
public object ListSculptys() public object ListSculptys()
{ {
Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy(); Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy();
Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>(); Dictionary<uint, uint> mapLocalID = [];
Dictionary<uint, Primitive> sculpts = new Dictionary<uint, Primitive>(); Dictionary<uint, Primitive> sculpts = [];
foreach (KeyValuePair<uint, Primitive> Obj in objects_copy) foreach (KeyValuePair<uint, Primitive> Obj in objects_copy)
{ {
mapLocalID.Add(Obj.Value.LocalID, Obj.Key); mapLocalID.Add(Obj.Value.LocalID, Obj.Key);
@ -29,7 +25,7 @@ namespace SecondBotEvents.Commands
sculpts.Add(Obj.Key, Obj.Value); sculpts.Add(Obj.Key, Obj.Value);
} }
} }
List<SculptysInfo> reply = new List<SculptysInfo>(); List<SculptysInfo> reply = [];
foreach (KeyValuePair<uint, Primitive> Obj in sculpts) foreach (KeyValuePair<uint, Primitive> Obj in sculpts)
{ {
Vector3 pos = Obj.Value.Position; Vector3 pos = Obj.Value.Position;
@ -56,12 +52,14 @@ namespace SecondBotEvents.Commands
key = wip.ID; key = wip.ID;
} }
} }
SculptysInfo A = new SculptysInfo(); SculptysInfo A = new()
A.isLinked = asLink.ToString(); {
A.name = name.ToString(); isLinked = asLink.ToString(),
A.owner = owner.ToString(); name = name.ToString(),
A.uuid = key.ToString(); owner = owner.ToString(),
A.pos = pos.ToString(); uuid = key.ToString(),
pos = pos.ToString()
};
reply.Add(A); reply.Add(A);
} }
if (reply.Count == 0) if (reply.Count == 0)
@ -132,10 +130,12 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Error not in a sim"); return Failure("Error not in a sim");
} }
Dictionary<string, int> pos = new Dictionary<string, int>(); Dictionary<string, int> pos = new()
pos.Add("x", (int)Math.Round(GetClient().Self.SimPosition.X)); {
pos.Add("y", (int)Math.Round(GetClient().Self.SimPosition.Y)); { "x", (int)Math.Round(GetClient().Self.SimPosition.X) },
pos.Add("z", (int)Math.Round(GetClient().Self.SimPosition.Z)); { "y", (int)Math.Round(GetClient().Self.SimPosition.Y) },
{ "z", (int)Math.Round(GetClient().Self.SimPosition.Z) }
};
return BasicReply(JsonConvert.SerializeObject(pos)); return BasicReply(JsonConvert.SerializeObject(pos));
} }
} }

View file

@ -12,12 +12,8 @@ using System.Linq;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Inventory controls for sending items and so on")] [ClassInfo("Inventory controls for sending items and so on")]
public class InventoryCommands : CommandsAPI public class InventoryCommands(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public InventoryCommands(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Attachs an event for inventory changes")] [About("Attachs an event for inventory changes")]
[ReturnHints("cleared")] [ReturnHints("cleared")]
[ReturnHints("No action")] [ReturnHints("No action")]
@ -72,15 +68,15 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID targetitem) == false) if (UUID.TryParse(item, out UUID targetitem) == false)
{ {
return Failure("Invaild item UUID: "+ item, new [] { item }); return Failure("Invaild item UUID: "+ item, [item]);
} }
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15)); InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
if (itm == null) if (itm == null)
{ {
return Failure("Unable to find item: " + item, new [] { item }); return Failure("Unable to find item: " + item, [item]);
} }
UUID rezedobject = GetClient().Inventory.RequestRezFromInventory(GetClient().Network.CurrentSim, GetClient().Self.SimRotation, GetClient().Self.RelativePosition, itm); UUID rezedobject = GetClient().Inventory.RequestRezFromInventory(GetClient().Network.CurrentSim, GetClient().Self.SimRotation, GetClient().Self.RelativePosition, itm);
return BasicReply(rezedobject.ToString(), new [] { item }); return BasicReply(rezedobject.ToString(), [item]);
} }
@ -95,20 +91,20 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID target) == false) if (UUID.TryParse(item, out UUID target) == false)
{ {
return Failure("invaild item uuid", new [] { item, newname }); return Failure("invaild item uuid", [item, newname]);
} }
if (newname.Length < 3) if (newname.Length < 3)
{ {
return Failure("Item name is to short", new [] { item, newname }); return Failure("Item name is to short", [item, newname]);
} }
InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), target); InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), target);
if (realitem == null) if (realitem == null)
{ {
return Failure("Unable to find inventory item", new [] { item, newname }); return Failure("Unable to find inventory item", [item, newname]);
} }
realitem.Name = newname; realitem.Name = newname;
GetClient().Inventory.RequestUpdateItem(realitem); GetClient().Inventory.RequestUpdateItem(realitem);
return BasicReply("Ok", new [] { item, newname }); return BasicReply("Ok", [item, newname]);
} }
[About("Attempts to Remove the given inventory item")] [About("Attempts to Remove the given inventory item")]
@ -119,10 +115,10 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID target) == false) if (UUID.TryParse(item, out UUID target) == false)
{ {
return Failure("invaild item uuid", new [] { item }); return Failure("invaild item uuid", [item]);
} }
GetClient().Inventory.Remove(new List<UUID>() { target }, new List<UUID>()); GetClient().Inventory.Remove([target], []);
return BasicReply("Ok", new [] { item }); return BasicReply("Ok", [item]);
} }
[About("Attempts to Remove the given inventory folder")] [About("Attempts to Remove the given inventory folder")]
@ -133,10 +129,10 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(folder, out UUID target) == false) if (UUID.TryParse(folder, out UUID target) == false)
{ {
return Failure("invaild folder uuid", new [] { folder }); return Failure("invaild folder uuid", [folder]);
} }
GetClient().Inventory.Remove(new List<UUID>(), new List<UUID>() { target }); GetClient().Inventory.Remove([], [target]);
return BasicReply("Ok", new [] { folder }); return BasicReply("Ok", [folder]);
} }
[About("Attempts to attach the given inventory item")] [About("Attempts to attach the given inventory item")]
@ -147,11 +143,11 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item,out UUID itemuuid) == false) if (UUID.TryParse(item,out UUID itemuuid) == false)
{ {
return Failure("invaild item uuid", new [] { item }); return Failure("invaild item uuid", [item]);
} }
InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), itemuuid); InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), itemuuid);
GetClient().Appearance.AddAttachments(new List<InventoryItem>() { realitem }, false, false); GetClient().Appearance.AddAttachments([realitem], false, false);
return BasicReply("Ok", new [] { item }); return BasicReply("Ok", [item]);
} }
[About("Attempts to Detach the given inventory item (or attachment point)")] [About("Attempts to Detach the given inventory item (or attachment point)")]
@ -163,7 +159,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID itemuuid) == false) if (UUID.TryParse(item, out UUID itemuuid) == false)
{ {
List<InventoryItem> toBeRemoved = new List<InventoryItem>(); List<InventoryItem> toBeRemoved = [];
foreach (KeyValuePair<UUID, AttachmentPoint> pair in GetClient().Appearance.GetAttachmentsByItemId()) foreach (KeyValuePair<UUID, AttachmentPoint> pair in GetClient().Appearance.GetAttachmentsByItemId())
{ {
if((pair.Value.ToString() != item) || (item == "*")) if((pair.Value.ToString() != item) || (item == "*"))
@ -174,18 +170,18 @@ namespace SecondBotEvents.Commands
} }
if(toBeRemoved.Count == 0) if(toBeRemoved.Count == 0)
{ {
return Failure("invaild item uuid pr invaild attach point", new[] { item }); return Failure("invaild item uuid pr invaild attach point", [item]);
} }
foreach(InventoryItem A in toBeRemoved) foreach(InventoryItem A in toBeRemoved)
{ {
GetClient().Appearance.RemoveFromOutfit(A); GetClient().Appearance.RemoveFromOutfit(A);
} }
return BasicReply("ok", new[] { item }); return BasicReply("ok", [item]);
} }
InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), itemuuid); InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), itemuuid);
GetClient().Appearance.RemoveFromOutfit(realitem); GetClient().Appearance.RemoveFromOutfit(realitem);
return BasicReply("Ok", new [] { item }); return BasicReply("Ok", [item]);
} }
@ -201,13 +197,13 @@ namespace SecondBotEvents.Commands
UUID folderUUID = UUID.Zero; UUID folderUUID = UUID.Zero;
if(UUID.TryParse(folder, out folderUUID) == false) if(UUID.TryParse(folder, out folderUUID) == false)
{ {
return Failure("invaild folder uuid", new[] { folder }); return Failure("invaild folder uuid", [folder]);
} }
List<InventoryBase> contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15)); List<InventoryBase> contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15));
List<InventoryItem> wareables = new(); List<InventoryItem> wareables = [];
if (contents == null) if (contents == null)
{ {
return Failure("target folder is empty or so full I cant get it in 5 secs...", new[] { folder }); return Failure("target folder is empty or so full I cant get it in 5 secs...", [folder]);
} }
foreach (InventoryBase item in contents) foreach (InventoryBase item in contents)
{ {
@ -217,7 +213,7 @@ namespace SecondBotEvents.Commands
} }
} }
master.CurrentOutfitFolder.ReplaceOutfit(wareables); master.CurrentOutfitFolder.ReplaceOutfit(wareables);
return BasicReply("ok", new[] { folder }); return BasicReply("ok", [folder]);
} }
[About("Replaces the current avatar outfit with the Clothing/[NAME] folder<br/>Please note: This does not use the outfits folder!<br/>Please do not use links in the folder!")] [About("Replaces the current avatar outfit with the Clothing/[NAME] folder<br/>Please note: This does not use the outfits folder!<br/>Please do not use links in the folder!")]
@ -231,7 +227,7 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(name) == false) if (SecondbotHelpers.notempty(name) == false)
{ {
return Failure("Named folder value is empty", new [] { name }); return Failure("Named folder value is empty", [name]);
} }
// uses the Clothing folder // uses the Clothing folder
// must be a full outfit (shapes/eyes ect) // must be a full outfit (shapes/eyes ect)
@ -248,7 +244,7 @@ namespace SecondBotEvents.Commands
} }
if (AA == null) if (AA == null)
{ {
return Failure("Cant find Clothing folder", new [] { name }); return Failure("Cant find Clothing folder", [name]);
} }
T = GetClient().Inventory.Store.GetContents(AA); T = GetClient().Inventory.Store.GetContents(AA);
AA = null; AA = null;
@ -262,13 +258,13 @@ namespace SecondBotEvents.Commands
} }
if (AA == null) if (AA == null)
{ {
return Failure("Cant find target folder", new [] { name }); return Failure("Cant find target folder", [name]);
} }
List<InventoryBase> contents = GetClient().Inventory.FolderContents(AA.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15)); List<InventoryBase> contents = GetClient().Inventory.FolderContents(AA.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(15));
List<InventoryItem> wareables = new(); List<InventoryItem> wareables = [];
if (contents == null) if (contents == null)
{ {
return Failure("target folder is empty or so full I cant get it in 5 secs...", new [] { name }); return Failure("target folder is empty or so full I cant get it in 5 secs...", [name]);
} }
foreach (InventoryBase item in contents) foreach (InventoryBase item in contents)
{ {
@ -278,7 +274,7 @@ namespace SecondBotEvents.Commands
} }
} }
GetClient().Appearance.ReplaceOutfit(wareables, false); GetClient().Appearance.ReplaceOutfit(wareables, false);
return BasicReply("ok", new [] { name }); return BasicReply("ok", [name]);
} }
@ -302,7 +298,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Unable to find notecard folder"); return Failure("Unable to find notecard folder");
} }
List<UUID> purge_notecards = new(); List<UUID> purge_notecards = [];
List<InventoryBase> contents = GetClient().Inventory.FolderContents(NotecardFolder.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByDate, TimeSpan.FromSeconds(15)); List<InventoryBase> contents = GetClient().Inventory.FolderContents(NotecardFolder.UUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByDate, TimeSpan.FromSeconds(15));
foreach (InventoryBase C in contents) foreach (InventoryBase C in contents)
{ {
@ -318,7 +314,7 @@ namespace SecondBotEvents.Commands
} }
if (purge_notecards.Count > 0) if (purge_notecards.Count > 0)
{ {
GetClient().Inventory.Remove(purge_notecards, new List<UUID>()); GetClient().Inventory.Remove(purge_notecards, []);
} }
return BasicReply("Ok"); return BasicReply("Ok");
} }
@ -331,10 +327,10 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID itemUUID) == false) if (UUID.TryParse(item, out UUID itemUUID) == false)
{ {
return Failure("Invaild item uuid", new [] { item }); return Failure("Invaild item uuid", [item]);
} }
UUID reply = HelperInventory.GetAssetUUID(GetClient(), itemUUID); UUID reply = HelperInventory.GetAssetUUID(GetClient(), itemUUID);
return BasicReply(reply.ToString(), new [] { item }); return BasicReply(reply.ToString(), [item]);
} }
[About("sends a item to an avatar via a path")] [About("sends a item to an avatar via a path")]
@ -349,20 +345,20 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { path, avatar }); return Failure("Invaild avatar uuid", [path, avatar]);
} }
UUID targetitem = GetClient().Inventory.FindObjectByPath(GetClient().Inventory.Store.RootFolder.UUID, GetClient().Self.AgentID, path, TimeSpan.FromSeconds(15)); UUID targetitem = GetClient().Inventory.FindObjectByPath(GetClient().Inventory.Store.RootFolder.UUID, GetClient().Self.AgentID, path, TimeSpan.FromSeconds(15));
if(targetitem == UUID.Zero) if(targetitem == UUID.Zero)
{ {
return Failure("Unable to find item via path", new[] { path, avatar }); return Failure("Unable to find item via path", [path, avatar]);
} }
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15)); InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
if (itm == null) if (itm == null)
{ {
return Failure("Unable to find item with found uuid", new[] { path, avatar }); return Failure("Unable to find item with found uuid", [path, avatar]);
} }
GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false); GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false);
return BasicReply("ok", new[] { path, avatar }); return BasicReply("ok", [path, avatar]);
} }
[About("sends a item to an avatar")] [About("sends a item to an avatar")]
@ -378,19 +374,19 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new [] { item, avatar }); return Failure("Invaild avatar uuid", [item, avatar]);
} }
if (UUID.TryParse(item, out UUID targetitem) == false) if (UUID.TryParse(item, out UUID targetitem) == false)
{ {
return Failure("Invaild item uuid", new [] { item, avatar }); return Failure("Invaild item uuid", [item, avatar]);
} }
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15)); InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
if (itm == null) if (itm == null)
{ {
return Failure("Unable to find item", new [] { item, avatar }); return Failure("Unable to find item", [item, avatar]);
} }
GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false); GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false);
return BasicReply("ok", new [] { item, avatar }); return BasicReply("ok", [item, avatar]);
} }
[About("Sends a folder to an avatar")] [About("Sends a folder to an avatar")]
[ReturnHints("ok")] [ReturnHints("ok")]
@ -403,15 +399,15 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { path, avatar }); return Failure("Invaild avatar uuid", [path, avatar]);
} }
InventoryFolder FindFolderHelper = HelperInventory.FindFolderByPath(GetClient(), path); InventoryFolder FindFolderHelper = HelperInventory.FindFolderByPath(GetClient(), path);
if (FindFolderHelper == null) if (FindFolderHelper == null)
{ {
return Failure("Unable to find folder", new[] { path, avatar }); return Failure("Unable to find folder", [path, avatar]);
} }
GetClient().Inventory.GiveFolder(FindFolderHelper.UUID, FindFolderHelper.Name, avataruuid, false); GetClient().Inventory.GiveFolder(FindFolderHelper.UUID, FindFolderHelper.Name, avataruuid, false);
return BasicReply("ok", new[] { path, avatar }); return BasicReply("ok", [path, avatar]);
} }
@ -428,19 +424,19 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new [] { folder, avatar }); return Failure("Invaild avatar uuid", [folder, avatar]);
} }
if (UUID.TryParse(folder, out UUID targetfolder) == false) if (UUID.TryParse(folder, out UUID targetfolder) == false)
{ {
return Failure("Invaild folder uuid", new [] { folder, avatar }); return Failure("Invaild folder uuid", [folder, avatar]);
} }
InventoryBase FindFolderHelper = HelperInventory.FindFolder(GetClient(), GetClient().Inventory.Store.RootFolder, targetfolder); InventoryBase FindFolderHelper = HelperInventory.FindFolder(GetClient(), GetClient().Inventory.Store.RootFolder, targetfolder);
if (FindFolderHelper == null) if (FindFolderHelper == null)
{ {
return Failure("Unable to find folder", new [] { folder, avatar }); return Failure("Unable to find folder", [folder, avatar]);
} }
GetClient().Inventory.GiveFolder(FindFolderHelper.UUID, FindFolderHelper.Name, avataruuid, false); GetClient().Inventory.GiveFolder(FindFolderHelper.UUID, FindFolderHelper.Name, avataruuid, false);
return BasicReply("ok", new [] { folder, avatar }); return BasicReply("ok", [folder, avatar]);
} }
[About("Transfers a item [ARG 2] to a objects inventory [ARG 1] (And if set with the script running state [ARG 3])")] [About("Transfers a item [ARG 2] to a objects inventory [ARG 1] (And if set with the script running state [ARG 3])")]
@ -458,21 +454,21 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID itemuuid) == false) if (UUID.TryParse(item, out UUID itemuuid) == false)
{ {
return Failure("Invaild item uuid", new [] { item, objectuuid, running }); return Failure("Invaild item uuid", [item, objectuuid, running]);
} }
if (UUID.TryParse(objectuuid, out UUID objectUUID) == false) if (UUID.TryParse(objectuuid, out UUID objectUUID) == false)
{ {
return Failure("Invaild object uuid", new [] { item, objectuuid, running }); return Failure("Invaild object uuid", [item, objectuuid, running]);
} }
if (bool.TryParse(running, out bool runscript) == false) if (bool.TryParse(running, out bool runscript) == false)
{ {
return Failure("Invaild running", new [] { item, objectuuid, running }); return Failure("Invaild running", [item, objectuuid, running]);
} }
InventoryItem itm = GetClient().Inventory.FetchItem(itemuuid, GetClient().Self.AgentID, TimeSpan.FromSeconds(15)); InventoryItem itm = GetClient().Inventory.FetchItem(itemuuid, GetClient().Self.AgentID, TimeSpan.FromSeconds(15));
if (itm == null) if (itm == null)
{ {
return Failure("Unable to find inventory", new [] { item, objectuuid, running }); return Failure("Unable to find inventory", [item, objectuuid, running]);
} }
Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy(); Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy();
KeyValuePair<uint, Primitive> RealObject = new(0, null); KeyValuePair<uint, Primitive> RealObject = new(0, null);
@ -495,7 +491,7 @@ namespace SecondBotEvents.Commands
break; break;
} }
} }
return Failure("Unable to find object", new [] { item, objectuuid, running }); return Failure("Unable to find object", [item, objectuuid, running]);
} }
bool scriptState = runscript; bool scriptState = runscript;
if (itm.AssetType != AssetType.LSLText) if (itm.AssetType != AssetType.LSLText)
@ -505,10 +501,10 @@ namespace SecondBotEvents.Commands
if (itm.AssetType == AssetType.LSLText) if (itm.AssetType == AssetType.LSLText)
{ {
GetClient().Inventory.CopyScriptToTask(RealObject.Key, itm, scriptState); GetClient().Inventory.CopyScriptToTask(RealObject.Key, itm, scriptState);
return BasicReply("Transfering script [state: "+scriptState.ToString()+"]", new [] { item, objectuuid, running }); return BasicReply("Transfering script [state: "+scriptState.ToString()+"]", [item, objectuuid, running]);
} }
GetClient().Inventory.UpdateTaskInventory(RealObject.Key, itm); GetClient().Inventory.UpdateTaskInventory(RealObject.Key, itm);
return BasicReply("Transfering inventory", new [] { item, objectuuid, running }); return BasicReply("Transfering inventory", [item, objectuuid, running]);
} }
[About("Requests the inventory folder layout as a json object InventoryMapFolder<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>subfolders: InventoryMapFolder[]</li></ul>")] [About("Requests the inventory folder layout as a json object InventoryMapFolder<br/>Formated as follows<br/>InventoryMapItem<br/><ul><li>id: UUID</li><li>name: String</li><li>subfolders: InventoryMapFolder[]</li></ul>")]
@ -540,9 +536,9 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(folderUUID, out UUID folder) == false) if (UUID.TryParse(folderUUID, out UUID folder) == false)
{ {
return Failure("Invaild folder UUID", new [] { folderUUID }); return Failure("Invaild folder UUID", [folderUUID]);
} }
return BasicReply(HelperInventory.MapFolderInventoryJson(GetClient(), folder), new [] { folderUUID }); return BasicReply(HelperInventory.MapFolderInventoryJson(GetClient(), folder), [folderUUID]);
} }
[About("creates a folder in a folder")] [About("creates a folder in a folder")]
@ -555,15 +551,15 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(parentFolder, out UUID parentFolderUUID) == false) if (UUID.TryParse(parentFolder, out UUID parentFolderUUID) == false)
{ {
return Failure("invaild parent folder UUID", new[] { parentFolder }); return Failure("invaild parent folder UUID", [parentFolder]);
} }
if (folderName.Length < 3) if (folderName.Length < 3)
{ {
return Failure("new folder name is too short, must be longer than 3 characters.", new[] { folderName }); return Failure("new folder name is too short, must be longer than 3 characters.", [folderName]);
} }
UUID folder = GetClient().Inventory.CreateFolder(parentFolderUUID, folderName); UUID folder = GetClient().Inventory.CreateFolder(parentFolderUUID, folderName);
string uuid = folder.ToString(); string uuid = folder.ToString();
return BasicReply("Ok", new string[] { uuid }); return BasicReply("Ok", [uuid]);
} }
@ -577,14 +573,14 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(item, out UUID itemUUID) == false) if (UUID.TryParse(item, out UUID itemUUID) == false)
{ {
return Failure("invaild item uuid", new[] { item, folder }); return Failure("invaild item uuid", [item, folder]);
} }
if (UUID.TryParse(folder, out UUID folderUUID) == false) if (UUID.TryParse(folder, out UUID folderUUID) == false)
{ {
return Failure("invaild folder uuid", new[] { item, folder }); return Failure("invaild folder uuid", [item, folder]);
} }
GetClient().Inventory.MoveItem(itemUUID, folderUUID); GetClient().Inventory.MoveItem(itemUUID, folderUUID);
return BasicReply("Ok", new string[] { item }); return BasicReply("Ok", [item]);
} }
[About("moves a folder to another folder")] [About("moves a folder to another folder")]
@ -597,14 +593,14 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(sourceFolder, out UUID sourceFolderUUID) == false) if (UUID.TryParse(sourceFolder, out UUID sourceFolderUUID) == false)
{ {
return Failure("invaild source folder uuid", new[] { sourceFolder, destFolder }); return Failure("invaild source folder uuid", [sourceFolder, destFolder]);
} }
if (UUID.TryParse(destFolder, out UUID destFolderUUID) == false) if (UUID.TryParse(destFolder, out UUID destFolderUUID) == false)
{ {
return Failure("invaild dest folder uuid", new[] { sourceFolder, destFolder }); return Failure("invaild dest folder uuid", [sourceFolder, destFolder]);
} }
GetClient().Inventory.MoveFolder(sourceFolderUUID, destFolderUUID); GetClient().Inventory.MoveFolder(sourceFolderUUID, destFolderUUID);
return BasicReply("Ok", new string[] { sourceFolder, destFolder }); return BasicReply("Ok", [sourceFolder, destFolder]);
} }
} }
} }

View file

@ -8,12 +8,8 @@ using System.Threading;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Dont like this place lets try somewhere else")] [ClassInfo("Dont like this place lets try somewhere else")]
public class Movement : CommandsAPI public class Movement(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Movement(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Adjusts Hover height")] [About("Adjusts Hover height")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHintsFailure("Convert to float has failed")] [ReturnHintsFailure("Convert to float has failed")]
@ -23,14 +19,14 @@ namespace SecondBotEvents.Commands
{ {
if (double.TryParse(height, out double level) == false) if (double.TryParse(height, out double level) == false)
{ {
return Failure("Convert to float has failed", new[] { height }); return Failure("Convert to float has failed", [height]);
} }
if (SecondbotHelpers.inrange(level, -2.0, 2.0) == false) if (SecondbotHelpers.inrange(level, -2.0, 2.0) == false)
{ {
return Failure("height value out of range(-2.0 to 2.0)", new[] { height }); return Failure("height value out of range(-2.0 to 2.0)", [height]);
} }
GetClient().Self.SetHoverHeight(level); GetClient().Self.SetHoverHeight(level);
return BasicReply("ok", new[] { height }); return BasicReply("ok", [height]);
} }
[About("uses the AutoPilot to move to a location")] [About("uses the AutoPilot to move to a location")]
@ -45,27 +41,26 @@ namespace SecondBotEvents.Commands
{ {
if (Vector3.TryParse("<" + x + "," + y + "," + z + ">", out Vector3 pos) == false) if (Vector3.TryParse("<" + x + "," + y + "," + z + ">", out Vector3 pos) == false)
{ {
return Failure("Convert to vector has failed", new [] { x, y, z }); return Failure("Convert to vector has failed", [x, y, z]);
} }
if (SecondbotHelpers.inrange(pos.X, 0, 255) == false) if (SecondbotHelpers.inrange(pos.X, 0, 255) == false)
{ {
return Failure("x value out of range 0-255", new [] { x, y, z }); return Failure("x value out of range 0-255", [x, y, z]);
} }
if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false) if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false)
{ {
return Failure("y value out of range 0-255", new [] { x, y, z }); return Failure("y value out of range 0-255", [x, y, z]);
} }
if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false) if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false)
{ {
return Failure("z value out of range 0-5000", new [] { x, y, z }); return Failure("z value out of range 0-5000", [x, y, z]);
} }
GetClient().Self.AutoPilotCancel(); GetClient().Self.AutoPilotCancel();
GetClient().Self.Movement.TurnToward(pos, true); GetClient().Self.Movement.TurnToward(pos, true);
Thread.Sleep(500); Thread.Sleep(500);
uint Globalx, Globaly; Utils.LongToUInts(GetClient().Network.CurrentSim.Handle, out uint Globalx, out uint Globaly);
Utils.LongToUInts(GetClient().Network.CurrentSim.Handle, out Globalx, out Globaly);
GetClient().Self.AutoPilot((ulong)(Globalx + pos.X), (ulong)(Globaly + pos.Y), pos.Z); GetClient().Self.AutoPilot((ulong)(Globalx + pos.X), (ulong)(Globaly + pos.Y), pos.Z);
return BasicReply("ok", new [] { x, y, z }); return BasicReply("ok", [x, y, z]);
} }
[About("Stop the auto pilot system from walking")] [About("Stop the auto pilot system from walking")]
@ -85,10 +80,10 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar UUID", new [] { avatar }); return Failure("Invaild avatar UUID", [avatar]);
} }
GetClient().Self.SendTeleportLure(avataruuid); GetClient().Self.SendTeleportLure(avataruuid);
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
[About("Sends a teleport request (Move the bot to the avatar)")] [About("Sends a teleport request (Move the bot to the avatar)")]
@ -100,11 +95,11 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar UUID", new [] { avatar }); return Failure("Invaild avatar UUID", [avatar]);
} }
// @todo action from event log with accept // @todo action from event log with accept
GetClient().Self.SendTeleportLureRequest(avataruuid, "I would like to teleport to you"); GetClient().Self.SendTeleportLureRequest(avataruuid, "I would like to teleport to you");
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
[About("Makes the bot fly (or not)")] [About("Makes the bot fly (or not)")]
@ -115,11 +110,11 @@ namespace SecondBotEvents.Commands
{ {
if (bool.TryParse(mode, out bool flymode) == false) if (bool.TryParse(mode, out bool flymode) == false)
{ {
return Failure("Invaild mode", new [] { mode }); return Failure("Invaild mode", [mode]);
} }
GetClient().Self.Movement.Fly = flymode; GetClient().Self.Movement.Fly = flymode;
GetClient().Self.Movement.SendUpdate(); GetClient().Self.Movement.SendUpdate();
return BasicReply("ok", new [] { mode }); return BasicReply("ok", [mode]);
} }
[About("Rotates the bot to face a vector from its current location")] [About("Rotates the bot to face a vector from its current location")]
@ -131,21 +126,21 @@ namespace SecondBotEvents.Commands
{ {
if (Vector3.TryParse(vector, out Vector3 pos) == false) if (Vector3.TryParse(vector, out Vector3 pos) == false)
{ {
return Failure("Invaild vector", new [] { vector }); return Failure("Invaild vector", [vector]);
} }
if (SecondbotHelpers.inrange(pos.X, 0, 255) == false) if (SecondbotHelpers.inrange(pos.X, 0, 255) == false)
{ {
return Failure("Vector x value is out of range 0-255", new [] { vector }); return Failure("Vector x value is out of range 0-255", [vector]);
} }
if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false) if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false)
{ {
return Failure("Vector y value is out of range 0-255", new [] { vector }); return Failure("Vector y value is out of range 0-255", [vector]);
} }
if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false) if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false)
{ {
return Failure("Vector z value is out of range 0-5000", new [] { vector }); return Failure("Vector z value is out of range 0-5000", [vector]);
} }
return BasicReply(GetClient().Self.Movement.TurnToward(pos, true).ToString(), new [] { vector }); return BasicReply(GetClient().Self.Movement.TurnToward(pos, true).ToString(), [vector]);
} }
[About("Rotates the bot to face a avatar")] [About("Rotates the bot to face a avatar")]
@ -158,13 +153,13 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar UUID", new [] { avatar }); return Failure("Invaild avatar UUID", [avatar]);
} }
if (GetClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false) if (GetClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false)
{ {
return Failure("Unable to see avatar", new [] { avatar }); return Failure("Unable to see avatar", [avatar]);
} }
return BasicReply(GetClient().Self.Movement.TurnToward(GetClient().Network.CurrentSim.AvatarPositions[avataruuid], true).ToString(), new [] { avatar }); return BasicReply(GetClient().Self.Movement.TurnToward(GetClient().Network.CurrentSim.AvatarPositions[avataruuid], true).ToString(), [avatar]);
} }
[About("Rotates the avatar to face a rotation from north in Degrees")] [About("Rotates the avatar to face a rotation from north in Degrees")]
@ -175,7 +170,7 @@ namespace SecondBotEvents.Commands
{ {
if (float.TryParse(deg, out float target_yaw) == true) if (float.TryParse(deg, out float target_yaw) == true)
{ {
return Failure("Unable to process rotation", new [] { deg }); return Failure("Unable to process rotation", [deg]);
} }
float yaw = target_yaw; float yaw = target_yaw;
GetClient().Self.Movement.BodyRotation.GetEulerAngles(out float roll, out float pitch, out _); GetClient().Self.Movement.BodyRotation.GetEulerAngles(out float roll, out float pitch, out _);
@ -198,7 +193,7 @@ namespace SecondBotEvents.Commands
result.Z = cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2; result.Z = cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2;
GetClient().Self.Movement.BodyRotation = result; GetClient().Self.Movement.BodyRotation = result;
GetClient().Self.Movement.SendUpdate(); GetClient().Self.Movement.SendUpdate();
return BasicReply("ok", new [] { deg }); return BasicReply("ok", [deg]);
} }
@ -215,9 +210,9 @@ namespace SecondBotEvents.Commands
bool status = TeleportRequest(region+"/"+x+"/"+y+"/"+z); bool status = TeleportRequest(region+"/"+x+"/"+y+"/"+z);
if (status == false) if (status == false)
{ {
return Failure("Error Unable to Teleport to location", new [] { region, x, y, z }); return Failure("Error Unable to Teleport to location", [region, x, y, z]);
} }
return BasicReply("Accepted", new [] { region, x, y, z }); return BasicReply("Accepted", [region, x, y, z]);
} }
@ -229,16 +224,16 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(slurl) == false) if (SecondbotHelpers.notempty(slurl) == false)
{ {
return Failure("slurl is empty", new [] { slurl }); return Failure("slurl is empty", [slurl]);
} }
return BasicReply(TeleportRequest(slurl).ToString(), new [] { slurl }); return BasicReply(TeleportRequest(slurl).ToString(), [slurl]);
} }
protected bool TeleportRequest(string url) protected bool TeleportRequest(string url)
{ {
// Viserion/66/166/23 // Viserion/66/166/23
GetClient().Self.AutoPilotCancel(); GetClient().Self.AutoPilotCancel();
SimSlURL A = new SimSlURL(url); SimSlURL A = new(url);
if(A.name == null) if(A.name == null)
{ {
return false; return false;

View file

@ -7,12 +7,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Why this is not a built in script command I will never know, but its due to needing this that the bot was made")] [ClassInfo("Why this is not a built in script command I will never know, but its due to needing this that the bot was made")]
public class Notecard : CommandsAPI public class Notecard(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Notecard(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Reads the notecards content, if it is able to read the notecard will give a json reply of notecarduuid name and contents")] [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("Not a vaild UUID")]
[ReturnHintsFailure("Unable to find inventory item")] [ReturnHintsFailure("Unable to find inventory item")]
@ -27,28 +23,30 @@ namespace SecondBotEvents.Commands
{ {
return Failure("replytarget not set"); return Failure("replytarget not set");
} }
NotecardReadReply reply = new NotecardReadReply(); NotecardReadReply reply = new()
reply.uuid = notecardInventoryUUID; {
reply.name = "?"; uuid = notecardInventoryUUID,
reply.status = false; name = "?",
reply.content = "Not a vaild UUID"; status = false,
content = "Not a vaild UUID"
};
if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false) if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false)
{ {
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead"); master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID }); return Failure(reply.content, [notecardInventoryUUID]);
} }
reply.content = "Unable to find inventory item"; reply.content = "Unable to find inventory item";
InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30)); InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30));
if (item == null) if (item == null)
{ {
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead"); master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID }); return Failure(reply.content, [notecardInventoryUUID]);
} }
reply.content = "Inventory item is not a notecard"; reply.content = "Inventory item is not a notecard";
if (item.InventoryType != InventoryType.Notecard) if (item.InventoryType != InventoryType.Notecard)
{ {
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead"); master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID }); ; return Failure(reply.content, [notecardInventoryUUID]); ;
} }
InventoryNotecard notecard = (InventoryNotecard)item; InventoryNotecard notecard = (InventoryNotecard)item;
GetClient().Assets.RequestInventoryAsset(notecard, true, UUID.Random(), (AssetDownload transfer, Asset asset) => GetClient().Assets.RequestInventoryAsset(notecard, true, UUID.Random(), (AssetDownload transfer, Asset asset) =>
@ -95,14 +93,14 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", new [] { collection, content }); return Failure("Collection value is empty", [collection, content]);
} }
if (SecondbotHelpers.notempty(content) == false) if (SecondbotHelpers.notempty(content) == false)
{ {
return Failure("Content value is empty", new [] { collection, content }); return Failure("Content value is empty", [collection, content]);
} }
master.DataStoreService.AppendKeyValue("notecard_"+collection, content); master.DataStoreService.AppendKeyValue("notecard_"+collection, content);
return BasicReply("ok", new [] { collection, master.DataStoreService.GetKeyValue("notecard_"+collection).Length.ToString() }); return BasicReply("ok", [collection, master.DataStoreService.GetKeyValue("notecard_"+collection).Length.ToString()]);
} }
[About("Clears the contents of a collection")] [About("Clears the contents of a collection")]
@ -113,7 +111,7 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", new [] { collection }); return Failure("Collection value is empty", [collection]);
} }
master.DataStoreService.ClearKeyValue("notecard_" + collection); master.DataStoreService.ClearKeyValue("notecard_" + collection);
return BasicReply("ok"); return BasicReply("ok");
@ -132,26 +130,26 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(collection) == false) if (SecondbotHelpers.notempty(collection) == false)
{ {
return Failure("Collection value is empty", new [] { avatar, collection, notecardname }); return Failure("Collection value is empty", [avatar, collection, notecardname]);
} }
if (SecondbotHelpers.notempty(notecardname) == false) if (SecondbotHelpers.notempty(notecardname) == false)
{ {
return Failure("Notecardname value is empty", new [] { avatar, collection, notecardname }); return Failure("Notecardname value is empty", [avatar, collection, notecardname]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new [] { avatar, collection, notecardname }); return Failure("Invaild avatar uuid", [avatar, collection, notecardname]);
} }
string content = master.DataStoreService.GetKeyValue("notecard_" + collection); string content = master.DataStoreService.GetKeyValue("notecard_" + collection);
if(content.Length <= 3) if(content.Length <= 3)
{ {
return Failure("No content in notecard storage ?", new[] { avatar, collection, notecardname }); return Failure("No content in notecard storage ?", [avatar, collection, notecardname]);
} }
bool result = master.BotClient.SendNotecard(notecardname, content, avataruuid); bool result = master.BotClient.SendNotecard(notecardname, content, avataruuid);
if (result == false) if (result == false)
{ {
return Failure("Failed to create/send notecard", new[] { avatar, content, notecardname }); return Failure("Failed to create/send notecard", [avatar, content, notecardname]);
} }
master.DataStoreService.ClearKeyValue("notecard_" + collection); master.DataStoreService.ClearKeyValue("notecard_" + collection);
return BasicReply("ok"); return BasicReply("ok");
@ -169,21 +167,21 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(notecardname) == false) if (SecondbotHelpers.notempty(notecardname) == false)
{ {
return Failure("notecardname value is empty", new[] { avatar, content, notecardname }); return Failure("notecardname value is empty", [avatar, content, notecardname]);
} }
if (SecondbotHelpers.notempty(content) == false) if (SecondbotHelpers.notempty(content) == false)
{ {
return Failure("content value is empty", new[] { avatar, content, notecardname }); return Failure("content value is empty", [avatar, content, notecardname]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar uuid", new[] { avatar, content, notecardname }); return Failure("Invaild avatar uuid", [avatar, content, notecardname]);
} }
bool result = master.BotClient.SendNotecard(notecardname, content, avataruuid); bool result = master.BotClient.SendNotecard(notecardname, content, avataruuid);
if(result == false) if(result == false)
{ {
return Failure("Failed to create/send notecard", new[] { avatar, content, notecardname }); return Failure("Failed to create/send notecard", [avatar, content, notecardname]);
} }
return BasicReply("ok"); return BasicReply("ok");
} }

View file

@ -13,12 +13,12 @@ using static OpenMetaverse.Stats.UtilizationStatistics;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
public class parcelPacketReply public class ParcelPacketReply
{ {
public List<string> groupuuids = new List<string>(); public List<string> groupuuids = [];
public List<parcelPacketData> parcels = new List<parcelPacketData>(); public List<ParcelPacketData> parcels = [];
} }
public class parcelPacketData public class ParcelPacketData
{ {
public int area; public int area;
public int groupindex; public int groupindex;
@ -30,12 +30,8 @@ namespace SecondBotEvents.Commands
} }
[ClassInfo("Control the land under our feet")] [ClassInfo("Control the land under our feet")]
public partial class ParcelCommands : CommandsAPI public partial class ParcelCommands(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public ParcelCommands(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("Requests the bot update its list of parcels ready for other commands")] [About("Requests the bot update its list of parcels ready for other commands")]
[ReturnHints("ok")] [ReturnHints("ok")]
public object UpdateListOfParcels() public object UpdateListOfParcels()
@ -47,8 +43,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("json encoded object")] [ReturnHints("json encoded object")]
public object GetParcelListSnapshots() public object GetParcelListSnapshots()
{ {
Dictionary<string, string> reply = new Dictionary<string, string>(); Dictionary<string, string> reply = [];
List<Parcel> Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList(); List<Parcel> Parcels = [.. GetClient().Network.CurrentSim.Parcels.Copy().Values];
foreach (Parcel A in Parcels) foreach (Parcel A in Parcels)
{ {
reply.Add(A.Name, A.SnapshotID.ToString()); reply.Add(A.Name, A.SnapshotID.ToString());
@ -61,26 +57,26 @@ namespace SecondBotEvents.Commands
public object GetSimParcelLayers() public object GetSimParcelLayers()
{ {
Dictionary<int, Parcel> data = GetClient().Network.CurrentSim.Parcels.Copy(); Dictionary<int, Parcel> data = GetClient().Network.CurrentSim.Parcels.Copy();
Dictionary<string, Vector4> parcelbox = new Dictionary<string, Vector4>(); Dictionary<string, Vector4> parcelbox = [];
uint SimWidth = GetClient().Network.CurrentSim.SizeX; uint SimWidth = GetClient().Network.CurrentSim.SizeX;
uint SimHeight = GetClient().Network.CurrentSim.SizeY; uint SimHeight = GetClient().Network.CurrentSim.SizeY;
Dictionary<int,string> maps = new Dictionary<int,string>(); Dictionary<int,string> maps = [];
int lastparcelid = 0; int lastparcelid = 0;
uint lowX = 0; uint lowX = 0;
uint lowY = 0; uint lowY = 0;
Random rnd = new Random(); Random rnd = new();
uint startX = 4; uint startX = 4;
string svg = "<svg width=\"" + SimWidth + "\" height=\"" + SimHeight + "\" xmlns=\"http://www.w3.org/2000/svg\">"; string svg = "<svg width=\"" + SimWidth + "\" height=\"" + SimHeight + "\" xmlns=\"http://www.w3.org/2000/svg\">";
uint boxheight = 0; uint boxheight = 0;
var color = ""; var color = "";
Parcel P = null; Parcel P = null;
string parcelname = "?";
int checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, 4, 20)); int checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, 4, 20));
while (startX < SimWidth) while (startX < SimWidth)
{ {
uint startY = 4; uint startY = 4;
string parcelname;
while (startY < SimHeight) while (startY < SimHeight)
{ {
checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, startY, 20)); checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, startY, 20));
@ -140,7 +136,7 @@ namespace SecondBotEvents.Commands
lastparcelid = 0; lastparcelid = 0;
startX += 4; startX += 4;
} }
svg = svg + "</svg>"; svg += "</svg>";
return BasicReply(svg); return BasicReply(svg);
} }
@ -149,8 +145,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("json encoded object")] [ReturnHints("json encoded object")]
public object GetListOfParcels() public object GetListOfParcels()
{ {
parcelPacketReply reply = new parcelPacketReply(); ParcelPacketReply reply = new();
List<Parcel> Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList(); List<Parcel> Parcels = [.. GetClient().Network.CurrentSim.Parcels.Copy().Values];
foreach (Parcel A in Parcels) foreach (Parcel A in Parcels)
{ {
int index = reply.groupuuids.IndexOf(A.GroupID.ToString()); int index = reply.groupuuids.IndexOf(A.GroupID.ToString());
@ -159,14 +155,16 @@ namespace SecondBotEvents.Commands
reply.groupuuids.Add(A.GroupID.ToString()); reply.groupuuids.Add(A.GroupID.ToString());
index = reply.groupuuids.IndexOf(A.GroupID.ToString()); index = reply.groupuuids.IndexOf(A.GroupID.ToString());
} }
parcelPacketData R = new parcelPacketData(); ParcelPacketData R = new()
R.groupindex = index; {
R.area = A.Area; groupindex = index,
R.startbox = A.AABBMin.ToString(); area = A.Area,
R.endbox = A.AABBMax.ToString(); startbox = A.AABBMin.ToString(),
R.currentprims = A.TotalPrims; endbox = A.AABBMax.ToString(),
R.maxprims = A.MaxPrims; currentprims = A.TotalPrims,
R.name = A.Name; maxprims = A.MaxPrims,
name = A.Name
};
reply.parcels.Add(R); reply.parcels.Add(R);
} }
return BasicReply(JsonConvert.SerializeObject(reply)); return BasicReply(JsonConvert.SerializeObject(reply));
@ -201,11 +199,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if(tests.Key == false) if(tests.Key == false)
{ {
return Failure(tests.Value, new [] { amount, avatar }); return Failure(tests.Value, [amount, avatar]);
} }
if (int.TryParse(amount,out int amountvalue) == false) if (int.TryParse(amount,out int amountvalue) == false)
{ {
return Failure("Invaild amount", new [] { amount, avatar }); return Failure("Invaild amount", [amount, avatar]);
} }
int minAmount = 1; int minAmount = 1;
@ -220,14 +218,14 @@ namespace SecondBotEvents.Commands
} }
if ((amountvalue < minAmount) || (amountvalue > 9999999)) if ((amountvalue < minAmount) || (amountvalue > 9999999))
{ {
return Failure("Invaild amount", new [] { amount, avatar }); return Failure("Invaild amount", [amount, avatar]);
} }
targetparcel.SalePrice = amountvalue; targetparcel.SalePrice = amountvalue;
targetparcel.AuthBuyerID = avataruuid; targetparcel.AuthBuyerID = avataruuid;
ParcelStatic.ParcelSetFlag(ParcelFlags.ForSale, targetparcel, true); ParcelStatic.ParcelSetFlag(ParcelFlags.ForSale, targetparcel, true);
ParcelStatic.ParcelSetFlag(ParcelFlags.ForSaleObjects, targetparcel, false); ParcelStatic.ParcelSetFlag(ParcelFlags.ForSaleObjects, targetparcel, false);
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { amount, avatar }); return BasicReply("ok", [amount, avatar]);
} }
@ -257,7 +255,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure(tests.Value); return Failure(tests.Value);
} }
Dictionary<string, string> collection = new Dictionary<string, string>(); Dictionary<string, string> collection = [];
collection.Add("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString()); collection.Add("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString());
collection.Add("Cost", targetparcel.SalePrice.ToString()); collection.Add("Cost", targetparcel.SalePrice.ToString());
collection.Add("SaleTarget", targetparcel.AuthBuyerID.ToString()); collection.Add("SaleTarget", targetparcel.AuthBuyerID.ToString());
@ -320,8 +318,8 @@ namespace SecondBotEvents.Commands
{ {
return Failure("timeout must be >= 2000 and <= 7000"); return Failure("timeout must be >= 2000 and <= 7000");
} }
AutoResetEvent landresultsTimeout = new AutoResetEvent(false); AutoResetEvent landresultsTimeout = new(false);
List<string> collection = new List<string>(); List<string> collection = [];
void LandSearchResultsReply(object sender, DirLandReplyEventArgs e) void LandSearchResultsReply(object sender, DirLandReplyEventArgs e)
{ {
int counter = (100 * GetpageNum); int counter = (100 * GetpageNum);
@ -344,7 +342,7 @@ namespace SecondBotEvents.Commands
GetClient().Directory.DirLandReply -= LandSearchResultsReply; GetClient().Directory.DirLandReply -= LandSearchResultsReply;
string reply = JsonConvert.SerializeObject(collection); string reply = JsonConvert.SerializeObject(collection);
return BasicReply(reply, new string[] { filterRegion, filterPrice, filterArea, pageNum, timeout }); return BasicReply(reply, [filterRegion, filterPrice, filterArea, pageNum, timeout]);
} }
@ -361,24 +359,24 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { x, y, z }); return Failure(tests.Value, [x, y, z]);
} }
if(int.TryParse(x,out int X) == false) if(int.TryParse(x,out int X) == false)
{ {
return Failure("Unable to process landing point x value", new [] { x, y, z }); return Failure("Unable to process landing point x value", [x, y, z]);
} }
if (int.TryParse(y, out int Y) == false) if (int.TryParse(y, out int Y) == false)
{ {
return Failure("Unable to process landing point y value", new [] { x, y, z }); return Failure("Unable to process landing point y value", [x, y, z]);
} }
if (int.TryParse(z, out int Z) == false) if (int.TryParse(z, out int Z) == false)
{ {
return Failure("Unable to process landing point z value", new [] { x, y, z }); return Failure("Unable to process landing point z value", [x, y, z]);
} }
targetparcel.Landing = LandingType.LandingPoint; targetparcel.Landing = LandingType.LandingPoint;
targetparcel.UserLocation = new Vector3(X, Y, Z); targetparcel.UserLocation = new Vector3(X, Y, Z);
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { x, y, z }); return BasicReply("ok", [x, y, z]);
} }
@ -393,15 +391,15 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { name }); return Failure(tests.Value, [name]);
} }
if (SecondbotHelpers.notempty(name) == false) if (SecondbotHelpers.notempty(name) == false)
{ {
return Failure("Parcel name is empty", new [] { name }); return Failure("Parcel name is empty", [name]);
} }
targetparcel.Name = name; targetparcel.Name = name;
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { name }); return BasicReply("ok", [name]);
} }
[About("Updates the current parcels description")] [About("Updates the current parcels description")]
@ -414,11 +412,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { desc }); return Failure(tests.Value, [desc]);
} }
targetparcel.Desc = desc; targetparcel.Desc = desc;
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { desc }); return BasicReply("ok", [desc]);
} }
[About("Fetchs the current parcels desc")] [About("Fetchs the current parcels desc")]
@ -447,7 +445,7 @@ namespace SecondBotEvents.Commands
return Failure(tests.Value); return Failure(tests.Value);
} }
Dictionary<string, ParcelFlags> flags = ParcelStatic.GetFlagsList(); Dictionary<string, ParcelFlags> flags = ParcelStatic.GetFlagsList();
Dictionary<string, string> collection = new(); Dictionary<string, string> collection = [];
foreach (ParcelFlags cfg in flags.Values) foreach (ParcelFlags cfg in flags.Values)
{ {
collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString()); collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString());
@ -464,10 +462,10 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar", new [] { avatar }); return Failure("Invaild avatar", [avatar]);
} }
GetClient().Parcels.EjectUser(avataruuid, false); GetClient().Parcels.EjectUser(avataruuid, false);
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
[About("Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner")] [About("Abandons the parcel the bot is currently on, returning it to Linden's or Estate owner")]
@ -496,12 +494,12 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { avatar }); return Failure(tests.Value, [avatar]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar", new [] { avatar }); return Failure("Invaild avatar", [avatar]);
} }
bool alreadyBanned = false; bool alreadyBanned = false;
foreach (ParcelAccessEntry E in targetparcel.AccessBlackList) foreach (ParcelAccessEntry E in targetparcel.AccessBlackList)
@ -514,7 +512,7 @@ namespace SecondBotEvents.Commands
} }
if (alreadyBanned == true) if (alreadyBanned == true)
{ {
return BasicReply("Avatar is in the blacklist", new [] { avatar }); return BasicReply("Avatar is in the blacklist", [avatar]);
} }
ParcelAccessEntry entry = new() ParcelAccessEntry entry = new()
{ {
@ -524,7 +522,7 @@ namespace SecondBotEvents.Commands
}; };
targetparcel.AccessBlackList.Add(entry); targetparcel.AccessBlackList.Add(entry);
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
[About("Unbans an avatar from a parcel")] [About("Unbans an avatar from a parcel")]
@ -539,12 +537,12 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { avatar }); return Failure(tests.Value, [avatar]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar", new [] { avatar }); return Failure("Invaild avatar", [avatar]);
} }
bool alreadyBanned = false; bool alreadyBanned = false;
ParcelAccessEntry removeentry = new(); ParcelAccessEntry removeentry = new();
@ -559,11 +557,11 @@ namespace SecondBotEvents.Commands
} }
if (alreadyBanned == false) if (alreadyBanned == false)
{ {
return BasicReply("Avatar is already unbanned", new [] { avatar }); return BasicReply("Avatar is already unbanned", [avatar]);
} }
targetparcel.AccessBlackList.Remove(removeentry); targetparcel.AccessBlackList.Remove(removeentry);
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
@ -577,10 +575,10 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { musicurl }); return Failure(tests.Value, [musicurl]);
} }
bool status = ParcelStatic.SetParcelMusic(GetClient(), targetparcel, musicurl); bool status = ParcelStatic.SetParcelMusic(GetClient(), targetparcel, musicurl);
return BasicReply(status.ToString(), new [] { musicurl }); return BasicReply(status.ToString(), [musicurl]);
} }
[About("Updates the current parcels name")] [About("Updates the current parcels name")]
@ -598,13 +596,13 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { escapedflagdata }); return Failure(tests.Value, [escapedflagdata]);
} }
List<string> acceptablewords = new(); List<string> acceptablewords = [];
Dictionary<string, ParcelFlags> flags = ParcelStatic.GetFlagsList(); Dictionary<string, ParcelFlags> flags = ParcelStatic.GetFlagsList();
acceptablewords.AddRange(new[] { "True", "False" }); acceptablewords.AddRange(["True", "False"]);
Dictionary<string, bool> setflags = new(); Dictionary<string, bool> setflags = [];
string[] args = escapedflagdata.Split(":::"); string[] args = escapedflagdata.Split(":::");
foreach (string a in args) foreach (string a in args)
{ {
@ -627,11 +625,11 @@ namespace SecondBotEvents.Commands
} }
if (setflags.Count == 0) if (setflags.Count == 0)
{ {
return Failure("No accepted flags", new [] { escapedflagdata }); return Failure("No accepted flags", [escapedflagdata]);
} }
if (ParcelStatic.HasParcelPerm(targetparcel, GetClient()) == false) if (ParcelStatic.HasParcelPerm(targetparcel, GetClient()) == false)
{ {
return Failure("Incorrect perms to control parcel", new [] { escapedflagdata }); return Failure("Incorrect perms to control parcel", [escapedflagdata]);
} }
foreach (KeyValuePair<string, bool> cfg in setflags) foreach (KeyValuePair<string, bool> cfg in setflags)
{ {
@ -641,7 +639,7 @@ namespace SecondBotEvents.Commands
} }
} }
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("Applying perms", new [] { escapedflagdata }); return BasicReply("Applying perms", [escapedflagdata]);
} }
[About("Returns all objects from the current parcel for the selected avatar")] [About("Returns all objects from the current parcel for the selected avatar")]
@ -655,15 +653,15 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { avatar }); return Failure(tests.Value, [avatar]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar UUID", new [] { avatar }); return Failure("Invaild avatar UUID", [avatar]);
} }
GetClient().Parcels.ReturnObjects(GetClient().Network.CurrentSim, targetparcel.LocalID, ObjectReturnType.None, new List<UUID>() { avataruuid }); GetClient().Parcels.ReturnObjects(GetClient().Network.CurrentSim, targetparcel.LocalID, ObjectReturnType.None, [avataruuid]);
return BasicReply("ok", new [] { avatar }); return BasicReply("ok", [avatar]);
} }
@ -679,22 +677,22 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { group }); return Failure(tests.Value, [group]);
} }
if (UUID.TryParse(group, out UUID groupuuid) == false) if (UUID.TryParse(group, out UUID groupuuid) == false)
{ {
return Failure("Invaild group uuid", new [] { group }); return Failure("Invaild group uuid", [group]);
} }
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false) if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{ {
return Failure("Not in group", new [] { group }); return Failure("Not in group", [group]);
} }
ParcelStatic.ParcelSetFlag(ParcelFlags.AllowDeedToGroup, targetparcel, true); ParcelStatic.ParcelSetFlag(ParcelFlags.AllowDeedToGroup, targetparcel, true);
targetparcel.GroupID = groupuuid; targetparcel.GroupID = groupuuid;
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
Thread.Sleep(500); Thread.Sleep(500);
GetClient().Parcels.DeedToGroup(GetClient().Network.CurrentSim, targetparcel.LocalID, groupuuid); GetClient().Parcels.DeedToGroup(GetClient().Network.CurrentSim, targetparcel.LocalID, groupuuid);
return BasicReply("ok", new [] { group }); return BasicReply("ok", [group]);
} }
[About("Attempts to buy the parcel the bot is standing on, the amount must match the sale price for the land!")] [About("Attempts to buy the parcel the bot is standing on, the amount must match the sale price for the land!")]
@ -712,11 +710,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { amount }); return Failure(tests.Value, [amount]);
} }
if ((targetparcel.AuthBuyerID != UUID.Zero) && (targetparcel.AuthBuyerID != GetClient().Self.AgentID)) if ((targetparcel.AuthBuyerID != UUID.Zero) && (targetparcel.AuthBuyerID != GetClient().Self.AgentID))
{ {
return Failure("Parcel sale locked to other avatars", new[] { amount }); return Failure("Parcel sale locked to other avatars", [amount]);
} }
int minAmount = 1; int minAmount = 1;
if (targetparcel.AuthBuyerID == GetClient().Self.AgentID) if (targetparcel.AuthBuyerID == GetClient().Self.AgentID)
@ -725,22 +723,22 @@ namespace SecondBotEvents.Commands
} }
if (int.TryParse(amount, out int amountvalue) == false) if (int.TryParse(amount, out int amountvalue) == false)
{ {
return Failure("Invaild amount", new [] { amount }); return Failure("Invaild amount", [amount]);
} }
if (amountvalue < minAmount) if (amountvalue < minAmount)
{ {
return Failure("Invaild amount", new [] { amount }); return Failure("Invaild amount", [amount]);
}; };
if (targetparcel.Flags.HasFlag(ParcelFlags.ForSale) == false) if (targetparcel.Flags.HasFlag(ParcelFlags.ForSale) == false)
{ {
return Failure("Parcel not for sale", new [] { amount }); return Failure("Parcel not for sale", [amount]);
} }
if (targetparcel.SalePrice != amountvalue) if (targetparcel.SalePrice != amountvalue)
{ {
return Failure("Parcel sale price and amount do not match", new [] { amount }); return Failure("Parcel sale price and amount do not match", [amount]);
} }
GetClient().Parcels.Buy(GetClient().Network.CurrentSim, targetparcel.LocalID, false, UUID.Zero, false, targetparcel.Area, amountvalue); GetClient().Parcels.Buy(GetClient().Network.CurrentSim, targetparcel.LocalID, false, UUID.Zero, false, targetparcel.Area, amountvalue);
return BasicReply("ok", new [] { amount }); return BasicReply("ok", [amount]);
} }
[About("Freezes an avatar")] [About("Freezes an avatar")]
@ -753,15 +751,15 @@ namespace SecondBotEvents.Commands
{ {
if (bool.TryParse(state, out bool freezestate) == false) if (bool.TryParse(state, out bool freezestate) == false)
{ {
return Failure("Invaild state", new [] { avatar, state }); return Failure("Invaild state", [avatar, state]);
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("Invaild avatar UUID", new [] { avatar, state }); return Failure("Invaild avatar UUID", [avatar, state]);
} }
GetClient().Parcels.FreezeUser(avataruuid, freezestate); GetClient().Parcels.FreezeUser(avataruuid, freezestate);
return BasicReply("ok", new [] { avatar, state }); return BasicReply("ok", [avatar, state]);
} }
@ -815,7 +813,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(objectuuid, out UUID targetobject) == false) if (UUID.TryParse(objectuuid, out UUID targetobject) == false)
{ {
return Failure("Invaild object uuid", new [] { objectuuid }); return Failure("Invaild object uuid", [objectuuid]);
} }
bool found = false; bool found = false;
Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy(); Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy();
@ -830,9 +828,9 @@ namespace SecondBotEvents.Commands
} }
if(found == false) if(found == false)
{ {
return Failure("Unable to find object", new [] { objectuuid }); return Failure("Unable to find object", [objectuuid]);
} }
return BasicReply("ok", new [] { objectuuid }); return BasicReply("ok", [objectuuid]);
} }
[About("Updates the current parcels media settings \n" + [About("Updates the current parcels media settings \n" +
@ -854,7 +852,7 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel(); KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false) if (tests.Key == false)
{ {
return Failure(tests.Value, new [] { escapedflagdata }); return Failure(tests.Value, [escapedflagdata]);
} }
string[] args = escapedflagdata.Split(":::"); string[] args = escapedflagdata.Split(":::");
foreach (string A in args) foreach (string A in args)
@ -915,7 +913,7 @@ namespace SecondBotEvents.Commands
} }
} }
targetparcel.Update(GetClient()); targetparcel.Update(GetClient());
return BasicReply("ok", new [] { escapedflagdata }); return BasicReply("ok", [escapedflagdata]);
} }
protected static bool UpdateParcelMediaType(Parcel targetparcel, string value) protected static bool UpdateParcelMediaType(Parcel targetparcel, string value)
@ -952,7 +950,7 @@ namespace SecondBotEvents.Commands
public class GetParcelBanlistObject public class GetParcelBanlistObject
{ {
public Dictionary<UUID, string> entrys = new(); public Dictionary<UUID, string> entrys = [];
public string parcelName = ""; public string parcelName = "";
public string regionName = ""; public string regionName = "";
public int delay = 0; public int delay = 0;

View file

@ -7,12 +7,8 @@ using System.Linq;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("The more we know about our self the better we are")] [ClassInfo("The more we know about our self the better we are")]
public class Self : CommandsAPI public class Self(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Self(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("use the SMTP service to send a email (requires AllowCommandSendMail to be true)")] [About("use the SMTP service to send a email (requires AllowCommandSendMail to be true)")]
[ReturnHints("sending")] [ReturnHints("sending")]
[ReturnHintsFailure("Send was rejected because: X")] [ReturnHintsFailure("Send was rejected because: X")]
@ -57,7 +53,7 @@ namespace SecondBotEvents.Commands
{ {
if (GetClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false) if (GetClient().Network.CurrentSim.AvatarPositions.ContainsKey(avataruuid) == false)
{ {
return Failure("Cant find UUID in sim", new [] { targetUUID }); return Failure("Cant find UUID in sim", [targetUUID]);
} }
ProcessAvatar(targetUUID); ProcessAvatar(targetUUID);
GetClient().Self.Stand(); GetClient().Self.Stand();
@ -66,7 +62,7 @@ namespace SecondBotEvents.Commands
GetClient().Self.AnimationStart(Animations.POINT_YOU, true); GetClient().Self.AnimationStart(Animations.POINT_YOU, true);
GetClient().Self.PointAtEffect(GetClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random()); GetClient().Self.PointAtEffect(GetClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 0), PointAtType.Select, UUID.Random());
GetClient().Self.BeamEffect(GetClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random()); GetClient().Self.BeamEffect(GetClient().Self.AgentID, avataruuid, new Vector3d(0, 0, 2), new Color4(255, 255, 255, 1), (float)3.0, UUID.Random());
return BasicReply("ok", new [] { targetUUID }); return BasicReply("ok", [targetUUID]);
} }
[About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")] [About("Reads a value from the KeyValue storage (temp unless SQL is enabled)")]
@ -88,11 +84,11 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.isempty(Key) == false) if (SecondbotHelpers.isempty(Key) == false)
{ {
return Failure("Key is empty", new[] { Key, Value }); return Failure("Key is empty", [Key, Value]);
} }
if (SecondbotHelpers.isempty(Value) == false) if (SecondbotHelpers.isempty(Value) == false)
{ {
return Failure("Value is empty", new[] { Key, Value }); return Failure("Value is empty", [Key, Value]);
} }
master.DataStoreService.SetKeyValue(Key, Value); master.DataStoreService.SetKeyValue(Key, Value);
return BasicReply("ok"); return BasicReply("ok");
@ -106,7 +102,7 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.isempty(Key) == false) if (SecondbotHelpers.isempty(Key) == false)
{ {
return Failure("Key is empty", new[] { Key }); return Failure("Key is empty", [Key]);
} }
master.DataStoreService.ClearKeyValue(Key); master.DataStoreService.ClearKeyValue(Key);
return BasicReply("ok"); return BasicReply("ok");
@ -121,14 +117,14 @@ namespace SecondBotEvents.Commands
if ((target == "ground") || (target == UUID.Zero.ToString())) if ((target == "ground") || (target == UUID.Zero.ToString()))
{ {
GetClient().Self.SitOnGround(); GetClient().Self.SitOnGround();
return BasicReply("ok", new [] { target }); return BasicReply("ok", [target]);
} }
if(UUID.TryParse(target,out UUID objectuuid) == false) if(UUID.TryParse(target,out UUID objectuuid) == false)
{ {
return Failure("Invaild object uuid and not ground"); return Failure("Invaild object uuid and not ground");
} }
GetClient().Self.RequestSit(objectuuid, Vector3.Zero); GetClient().Self.RequestSit(objectuuid, Vector3.Zero);
return BasicReply("ok", new [] { target }); return BasicReply("ok", [target]);
} }
[About("Makes the bot stand up if sitting (also resets animations)")] [About("Makes the bot stand up if sitting (also resets animations)")]
@ -150,7 +146,7 @@ namespace SecondBotEvents.Commands
{ {
if (UUID.TryParse(target, out UUID objectuuid) == false) if (UUID.TryParse(target, out UUID objectuuid) == false)
{ {
return Failure("Invaild object UUID", new [] { target }); return Failure("Invaild object UUID", [target]);
} }
GetClient().Self.PointAtEffect(GetClient().Self.AgentID, objectuuid, new Vector3d(0, 0, 0), PointAtType.Select, new UUID("1df9eb92-62fa-15e5-4bfb-5931f1525274")); GetClient().Self.PointAtEffect(GetClient().Self.AgentID, objectuuid, new Vector3d(0, 0, 0), PointAtType.Select, new UUID("1df9eb92-62fa-15e5-4bfb-5931f1525274"));
@ -167,7 +163,7 @@ namespace SecondBotEvents.Commands
break; break;
} }
} }
return BasicReply(found_object.ToString(), new [] { target }); return BasicReply(found_object.ToString(), [target]);
} }
[About("Makes the bot kill itself you monster")] [About("Makes the bot kill itself you monster")]
@ -183,7 +179,7 @@ namespace SecondBotEvents.Commands
[ReturnHints("list of commands")] [ReturnHints("list of commands")]
public object GetLastCommands() public object GetLastCommands()
{ {
List<string> reply = new List<string>(); List<string> reply = [];
foreach(CommandHistory A in master.DataStoreService.GetCommandHistory()) foreach(CommandHistory A in master.DataStoreService.GetCommandHistory())
{ {
reply.Add(JsonConvert.SerializeObject(A)); reply.Add(JsonConvert.SerializeObject(A));
@ -192,7 +188,7 @@ namespace SecondBotEvents.Commands
break; break;
} }
} }
return BasicReply("ok", reply.ToArray<string>()); return BasicReply("ok", [.. reply]);
} }
[About("Sets the bot to accept a request type from the avatar (or a object owned by the avatar)\n " + [About("Sets the bot to accept a request type from the avatar (or a object owned by the avatar)\n " +
@ -215,30 +211,28 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar); ProcessAvatar(avatar);
if (avataruuid == UUID.Zero) if (avataruuid == UUID.Zero)
{ {
return Failure("avatar lookup", new [] { avatar, flag, state, sticky }); return Failure("avatar lookup", [avatar, flag, state, sticky]);
} }
bool stateflag = false; if (bool.TryParse(state, out bool stateflag) == false)
bool stickyflag = false;
if(bool.TryParse(state,out stateflag) == false)
{ {
return Failure("Invaild state", new [] { avatar, flag, state, sticky }); return Failure("Invaild state", [avatar, flag, state, sticky]);
} }
if (bool.TryParse(sticky, out stickyflag) == false) if (bool.TryParse(sticky, out bool stickyflag) == false)
{ {
return Failure("Invaild sticky", new [] { avatar, flag, state, sticky }); return Failure("Invaild sticky", [avatar, flag, state, sticky]);
} }
string[] AcceptedFlags = new [] { "friend", "group", "animation", "teleport", "command", "inventory" }; string[] AcceptedFlags = ["friend", "group", "animation", "teleport", "command", "inventory"];
if (AcceptedFlags.Contains(flag) == false) if (AcceptedFlags.Contains(flag) == false)
{ {
return Failure("Invaild flag", new [] { avatar, flag, state, sticky }); return Failure("Invaild flag", [avatar, flag, state, sticky]);
} }
if (stateflag == true) if (stateflag == true)
{ {
// @todo add stick/normal accept dynamic actions // @todo add stick/normal accept dynamic actions
return BasicReply("Added perm: " + flag + " Sticky: " + stickyflag.ToString(), new [] { avatar, flag, state, sticky }); return BasicReply("Added perm: " + flag + " Sticky: " + stickyflag.ToString(), [avatar, flag, state, sticky]);
} }
// @todo remove stick/normal accept dynamic actions // @todo remove stick/normal accept dynamic actions
return BasicReply("Removed perm: " + flag + " Sticky: " + stickyflag.ToString(), new [] { avatar, flag, state, sticky }); return BasicReply("Removed perm: " + flag + " Sticky: " + stickyflag.ToString(), [avatar, flag, state, sticky]);
} }

View file

@ -19,13 +19,9 @@ namespace SecondBotEvents.Commands
"TriggerOnEventService<br/>" + "TriggerOnEventService<br/>" +
"RelayService<br/>" + "RelayService<br/>" +
"ChatGptService")] "ChatGptService")]
public class Services : CommandsAPI public class Services(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public Services(EventsSecondBot setmaster) : base(setmaster) protected List<string> controlable = [
{
}
protected List<string> controlable = new List<string> {
"BotClientService", "BotClientService",
"RLVService", "RLVService",
"HttpService", "HttpService",
@ -37,7 +33,7 @@ namespace SecondBotEvents.Commands
"TriggerOnEventService", "TriggerOnEventService",
"RelayService", "RelayService",
"ChatGptService" "ChatGptService"
}; ];
[About("Marks a service as enabled and starts it")] [About("Marks a service as enabled and starts it")]
[ReturnHints("ok")] [ReturnHints("ok")]

View file

@ -7,13 +7,8 @@ using System;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
[ClassInfo("Interface for streamadmin to create notecards, you will prob never need this")] [ClassInfo("Interface for streamadmin to create notecards, you will prob never need this")]
public class StreamAdmin : CommandsAPI public class StreamAdmin(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{ {
public StreamAdmin(EventsSecondBot setmaster) : base(setmaster)
{
}
[About("A streamadin command")] [About("A streamadin command")]
[ReturnHints("True|False")] [ReturnHints("True|False")]
[ReturnHintsFailure("Bad reply: ...")] [ReturnHintsFailure("Bad reply: ...")]
@ -28,11 +23,11 @@ namespace SecondBotEvents.Commands
{ {
if (SecondbotHelpers.notempty(endpoint) == false) if (SecondbotHelpers.notempty(endpoint) == false)
{ {
return Failure("Endpoint is empty", new [] { endpoint, endpointcode }); return Failure("Endpoint is empty", [endpoint, endpointcode]);
} }
if (SecondbotHelpers.notempty(endpointcode) == false) if (SecondbotHelpers.notempty(endpointcode) == false)
{ {
return Failure("Endpointcode is empty", new [] { endpoint, endpointcode }); return Failure("Endpointcode is empty", [endpoint, endpointcode]);
} }
string attempt_endpoint = endpoint + "sys.php"; string attempt_endpoint = endpoint + "sys.php";
@ -48,34 +43,34 @@ namespace SecondBotEvents.Commands
RestResponse endpoint_checks = client.ExecutePostAsync(request).Result; RestResponse endpoint_checks = client.ExecutePostAsync(request).Result;
if (endpoint_checks.StatusCode != System.Net.HttpStatusCode.OK) if (endpoint_checks.StatusCode != System.Net.HttpStatusCode.OK)
{ {
return Failure("HTTP status code: " + endpoint_checks.StatusCode.ToString(), new [] { endpoint, endpointcode }); return Failure("HTTP status code: " + endpoint_checks.StatusCode.ToString(), [endpoint, endpointcode]);
} }
try try
{ {
NotecardEndpoint server_reply = JsonConvert.DeserializeObject<NotecardEndpoint>(endpoint_checks.Content); NotecardEndpoint server_reply = JsonConvert.DeserializeObject<NotecardEndpoint>(endpoint_checks.Content);
if (server_reply.status == false) if (server_reply.status == false)
{ {
return Failure("Bad reply: " + server_reply.message, new [] { endpoint, endpointcode }); return Failure("Bad reply: " + server_reply.message, [endpoint, endpointcode]);
} }
if (server_reply.NotecardTitle.Length < 3) if (server_reply.NotecardTitle.Length < 3)
{ {
return Failure("Notecard title is to short", new [] { endpoint, endpointcode }); return Failure("Notecard title is to short", [endpoint, endpointcode]);
} }
ProcessAvatar(server_reply.AvatarUUID); ProcessAvatar(server_reply.AvatarUUID);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return Failure("Unable to unpack avatar", new[] { endpoint, endpointcode }); return Failure("Unable to unpack avatar", [endpoint, endpointcode]);
} }
bool result = master.BotClient.SendNotecard(server_reply.NotecardTitle, server_reply.NotecardContent, avataruuid); bool result = master.BotClient.SendNotecard(server_reply.NotecardTitle, server_reply.NotecardContent, avataruuid);
if (result == false) if (result == false)
{ {
return Failure("Failed to create/send notecard", new[] { endpoint, endpointcode }); return Failure("Failed to create/send notecard", [endpoint, endpointcode]);
} }
return BasicReply("ok"); return BasicReply("ok");
} }
catch (Exception e) catch (Exception e)
{ {
return Failure("Error: " + e.Message + "", new [] { endpoint, endpointcode }); return Failure("Error: " + e.Message + "", [endpoint, endpointcode]);
} }
} }

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class BasicConfig : Config public class BasicConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public BasicConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "basic"; filename = "basic";

View file

@ -5,9 +5,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class ChatGptConfig : Config public class ChatGptConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public ChatGptConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "chatgpt"; filename = "chatgpt";

View file

@ -5,9 +5,8 @@ using System.Linq;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class CommandsConfig : Config public class CommandsConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public CommandsConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "commands"; filename = "commands";
@ -22,8 +21,15 @@ namespace SecondBotEvents.Config
settings.Add("Enabled"); settings.Add("Enabled");
settings.Add("ObjectMasterOptout"); settings.Add("ObjectMasterOptout");
settings.Add("AllowServiceControl"); settings.Add("AllowServiceControl");
settings.Add("CommandHistoryLogResults");
settings.Add("HideStatusOutput"); settings.Add("HideStatusOutput");
} }
public bool GetCommandHistoryLogResults()
{
return ReadSettingAsBool("CommandHistoryLogResults", false);
}
public bool GetAllowServiceControl() public bool GetAllowServiceControl()
{ {
return ReadSettingAsBool("AllowServiceControl", false); return ReadSettingAsBool("AllowServiceControl", false);

View file

@ -4,10 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class CustomCommandsConfig : Config public class CustomCommandsConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public CustomCommandsConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "customcommands"; filename = "customcommands";

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class DataStoreConfig : Config public class DataStoreConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public DataStoreConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "datastore"; filename = "datastore";
@ -24,6 +23,7 @@ namespace SecondBotEvents.Config
settings.Add("HideStatusOutput"); settings.Add("HideStatusOutput");
} }
public int GetCommandHistoryLimit() public int GetCommandHistoryLimit()
{ {
return ReadSettingAsInt("CommandHistoryLimit", 30); return ReadSettingAsInt("CommandHistoryLimit", 30);

View file

@ -5,9 +5,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class DialogRelayConfig : Config public class DialogRelayConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public DialogRelayConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "dialogrelay"; filename = "dialogrelay";

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class DiscordConfig : Config public class DiscordConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public DiscordConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "discord"; filename = "discord";

View file

@ -5,9 +5,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class EventsConfig : Config public class EventsConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public EventsConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "events"; filename = "events";

View file

@ -5,9 +5,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class HomeboundConfig : Config public class HomeboundConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public HomeboundConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "homebound"; filename = "homebound";

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class HttpConfig: Config public class HttpConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public HttpConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "http"; filename = "http";

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class InteractionConfig : Config public class InteractionConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public InteractionConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "interaction"; filename = "interaction";

View file

@ -6,9 +6,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class OnEventConfig : Config public class OnEventConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public OnEventConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "onevent"; filename = "onevent";

View file

@ -5,10 +5,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class RelayConfig : Config public class RelayConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public RelayConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "relay"; filename = "relay";
@ -100,13 +98,13 @@ namespace SecondBotEvents.Config
} }
// config not unpacked from string lets unpack it // config not unpacked from string lets unpack it
string config = ReadSettingAsString(relayID.ToString() + "_RelayConfig", ""); string config = ReadSettingAsString(relayID.ToString() + "_RelayConfig", "");
UnpackedConfigs.Add(relayID, new Dictionary<string, string>()); UnpackedConfigs.Add(relayID, []);
if (config == "") if (config == "")
{ {
return UnpackedConfigs[relayID]; return UnpackedConfigs[relayID];
} }
string[] bits = config.Split("{}", StringSplitOptions.RemoveEmptyEntries); string[] bits = config.Split("{}", StringSplitOptions.RemoveEmptyEntries);
Dictionary<string,string> data = new Dictionary<string,string>(); Dictionary<string,string> data = [];
foreach(string A in bits) foreach(string A in bits)
{ {
string[] B = A.Split("::", StringSplitOptions.RemoveEmptyEntries); string[] B = A.Split("::", StringSplitOptions.RemoveEmptyEntries);
@ -122,7 +120,7 @@ namespace SecondBotEvents.Config
{ {
return UnpackedConfigs[relayID]; return UnpackedConfigs[relayID];
} }
List<string> checks = new List<string>() { "sType", "sFilter", "tType", "tConfig" }; List<string> checks = ["sType", "sFilter", "tType", "tConfig"];
bool allfound = true; bool allfound = true;
foreach (string A in checks) foreach (string A in checks)
{ {
@ -139,7 +137,7 @@ namespace SecondBotEvents.Config
return UnpackedConfigs[relayID]; return UnpackedConfigs[relayID];
} }
protected Dictionary<int, Dictionary<string, string>> UnpackedConfigs = new Dictionary<int, Dictionary<string, string>>(); protected Dictionary<int, Dictionary<string, string>> UnpackedConfigs = [];
} }

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class RlvConfig : Config public class RlvConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public RlvConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "rlv"; filename = "rlv";

View file

@ -4,9 +4,8 @@ using System.Text;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
{ {
public class SmtpConfig : Config public class SmtpConfig(bool fromENV, string fromFolder = "") : Config(fromENV, fromFolder)
{ {
public SmtpConfig(bool fromENV, string fromFolder = "") : base(fromENV, fromFolder) { }
protected override void MakeSettings() protected override void MakeSettings()
{ {
filename = "smtp"; filename = "smtp";

View file

@ -12,8 +12,8 @@ namespace SecondBotEvents.Config
{ {
public abstract class Config public abstract class Config
{ {
protected Dictionary<string, string> mysettings = new Dictionary<string, string>(); protected Dictionary<string, string> mysettings = [];
protected List<string> settings = new List<string>(); protected List<string> settings = [];
protected string filename = "config"; protected string filename = "config";
protected bool loaded = false; protected bool loaded = false;
protected bool tryLoadfromEnv = false; protected bool tryLoadfromEnv = false;
@ -60,7 +60,7 @@ namespace SecondBotEvents.Config
protected void MakeSettingsFile(string fromFolder) protected void MakeSettingsFile(string fromFolder)
{ {
Dictionary<string, string> saveMe = new Dictionary<string, string>(); Dictionary<string, string> saveMe = [];
Type thisType = this.GetType(); Type thisType = this.GetType();
foreach (string setting in settings) foreach (string setting in settings)
{ {
@ -73,7 +73,7 @@ namespace SecondBotEvents.Config
string value = theMethod.Invoke(this, null).ToString(); string value = theMethod.Invoke(this, null).ToString();
saveMe.Add(setting, value); saveMe.Add(setting, value);
} }
SimpleIO IO = new SimpleIO(); SimpleIO IO = new();
IO.ChangeRoot(fromFolder); IO.ChangeRoot(fromFolder);
string writeFile = filename + ".json"; string writeFile = filename + ".json";
IO.WriteFile(writeFile, JsonConvert.SerializeObject(saveMe)); IO.WriteFile(writeFile, JsonConvert.SerializeObject(saveMe));
@ -81,7 +81,7 @@ namespace SecondBotEvents.Config
} }
protected void LoadSettingsFromFile(string fromFolder) protected void LoadSettingsFromFile(string fromFolder)
{ {
SimpleIO IO = new SimpleIO(); SimpleIO IO = new();
IO.ChangeRoot(fromFolder); IO.ChangeRoot(fromFolder);
string readfile = filename + ".json"; string readfile = filename + ".json";
if (IO.Exists(readfile) == false) if (IO.Exists(readfile) == false)

View file

@ -15,7 +15,7 @@ namespace SecondBotEvents
new WikiMake(); new WikiMake();
#endif #endif
LogFormater.Info("Welcome to Secondbot [Events build] version: " + AssemblyInfo.GetGitHash()); LogFormater.Info("Welcome to Secondbot [Events build] version: " + AssemblyInfo.GetGitHash());
EventsSecondBot worker = new EventsSecondBot(args); EventsSecondBot worker = new(args);
while (worker.Exit() == false) while (worker.Exit() == false)
{ {
@ -62,7 +62,7 @@ namespace SecondBotEvents
remove { lock (SystemStatusMessagesEventsLockable) { SystemStatusMessages -= value; } } remove { lock (SystemStatusMessagesEventsLockable) { SystemStatusMessages -= value; } }
} }
private readonly object SystemStatusMessagesEventsLockable = new object(); private readonly object SystemStatusMessagesEventsLockable = new();
public void TriggerSystemStatusMessageEvent(bool change, string message) public void TriggerSystemStatusMessageEvent(bool change, string message)
{ {
@ -76,7 +76,7 @@ namespace SecondBotEvents
add { lock (BotclientEventNoticesLockable) { BotclientEventNotices += value; } } add { lock (BotclientEventNoticesLockable) { BotclientEventNotices += value; } }
remove { lock (BotclientEventNoticesLockable) { BotclientEventNotices -= value; } } remove { lock (BotclientEventNoticesLockable) { BotclientEventNotices -= value; } }
} }
private readonly object BotclientEventNoticesLockable = new object(); private readonly object BotclientEventNoticesLockable = new();
public void TriggerBotClientEvent(bool asRestart,bool asDC) public void TriggerBotClientEvent(bool asRestart,bool asDC)
{ {
@ -118,7 +118,7 @@ namespace SecondBotEvents
StartServices(); StartServices();
} }
protected Dictionary<string, BotServices> services = new Dictionary<string, BotServices>(); protected Dictionary<string, BotServices> services = [];
public BotServices GetService(string classname) public BotServices GetService(string classname)
{ {
@ -157,8 +157,8 @@ namespace SecondBotEvents
public void StartServices() public void StartServices()
{ {
Ready = false; Ready = false;
services = new Dictionary<string, BotServices>(); services = [];
lastStatus = new Dictionary<string, string>(); lastStatus = [];
StopService("RecoveryService"); // kill the recovery service if its still running StopService("RecoveryService"); // kill the recovery service if its still running
RegisterService("BotClientService", false); RegisterService("BotClientService", false);
RegisterService("DataStoreService"); RegisterService("DataStoreService");
@ -187,7 +187,7 @@ namespace SecondBotEvents
Ready = true; Ready = true;
} }
Dictionary<string, string> lastStatus = new Dictionary<string, string>(); Dictionary<string, string> lastStatus = [];
public void Status() public void Status()
{ {
string Output = ""; string Output = "";
@ -277,14 +277,9 @@ namespace SecondBotEvents
} }
} }
public class SystemStatusMessage public class SystemStatusMessage(bool setChanged, string setMessage)
{ {
public bool changed = false; public bool changed = setChanged;
public string message = ""; public string message = setMessage;
public SystemStatusMessage(bool setChanged, string setMessage)
{
changed = setChanged;
message = setMessage;
}
} }
} }

View file

@ -22,13 +22,8 @@ using System;
namespace SecondBotEvents.RLV namespace SecondBotEvents.RLV
{ {
public class RLVEventArgs : EventArgs public class RLVEventArgs(RLVRule rule) : EventArgs
{ {
public RLVRule Rule { set; get; } public RLVRule Rule { set; get; } = rule;
public RLVEventArgs(RLVRule rule)
{
Rule = rule;
}
} }
} }

View file

@ -60,9 +60,11 @@ namespace SecondBotEvents.Services
{ {
running = true; running = true;
LogFormater.Info("Client service [Starting]"); LogFormater.Info("Client service [Starting]");
AutoRestartLoginTimer = new Timer(); AutoRestartLoginTimer = new Timer
AutoRestartLoginTimer.Interval = 30 * 1000; {
AutoRestartLoginTimer.AutoReset = false; Interval = 30 * 1000,
AutoReset = false
};
AutoRestartLoginTimer.Elapsed += RestartTimer; AutoRestartLoginTimer.Elapsed += RestartTimer;
Login(); Login();
} }
@ -137,7 +139,7 @@ namespace SecondBotEvents.Services
{ {
if (Success) if (Success)
{ {
AssetNotecard empty = new AssetNotecard { BodyText = "\n" }; AssetNotecard empty = new() { BodyText = "\n" };
empty.Encode(); empty.Encode();
client.Inventory.RequestUploadNotecardAsset(empty.AssetData, item.UUID, client.Inventory.RequestUploadNotecardAsset(empty.AssetData, item.UUID,
(bool emptySuccess, string emptyStatus, UUID emptyItemID, UUID emptyAssetID) => (bool emptySuccess, string emptyStatus, UUID emptyItemID, UUID emptyAssetID) =>
@ -195,7 +197,7 @@ namespace SecondBotEvents.Services
ResetClient(); ResetClient();
goodticks = 0; goodticks = 0;
master.TriggerBotClientEvent(false, false); master.TriggerBotClientEvent(false, false);
LoginParams loginParams = new LoginParams( LoginParams loginParams = new(
client, client,
basicCfg.GetFirstName(), basicCfg.GetFirstName(),
basicCfg.GetLastName(), basicCfg.GetLastName(),

View file

@ -49,7 +49,7 @@ namespace SecondBotEvents.Services
{ {
try try
{ {
ConfigurationOptions configRedis = new ConfigurationOptions() ConfigurationOptions configRedis = new()
{ {
EndPoints = { myConfig.GetRedisSource() } EndPoints = { myConfig.GetRedisSource() }
}; };
@ -120,7 +120,7 @@ namespace SecondBotEvents.Services
return "Enabled No chat history"; return "Enabled No chat history";
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = ["secondlife", "second life"];
protected void BotLocalchat(object o, ChatEventArgs e) protected void BotLocalchat(object o, ChatEventArgs e)
{ {
if (e.SourceID == GetClient().Self.AgentID) if (e.SourceID == GetClient().Self.AgentID)
@ -220,9 +220,9 @@ namespace SecondBotEvents.Services
} }
} }
Dictionary<UUID, List<KeyValuePair<string, string>>> chatHistoryAI = new Dictionary<UUID, List<KeyValuePair<string, string>>>(); Dictionary<UUID, List<KeyValuePair<string, string>>> chatHistoryAI = [];
Dictionary<UUID, long> ChatHistoryLastAccessed = new Dictionary<UUID, long>(); Dictionary<UUID, long> ChatHistoryLastAccessed = [];
Dictionary<UUID, long> ChatRateLimiter = new Dictionary<UUID, long>(); Dictionary<UUID, long> ChatRateLimiter = [];
protected long lastUpkeep = 0; protected long lastUpkeep = 0;
protected void upkeep() protected void upkeep()
@ -236,7 +236,7 @@ namespace SecondBotEvents.Services
// check for expired chat windows (longer than 2 mins from last message) // check for expired chat windows (longer than 2 mins from last message)
lock (ChatHistoryLastAccessed) lock (chatHistoryAI) lock (ChatRateLimiter) lock (ChatHistoryLastAccessed) lock (chatHistoryAI) lock (ChatRateLimiter)
{ {
List<UUID> needcleaning = new List<UUID>(); List<UUID> needcleaning = [];
long now = SecondbotHelpers.UnixTimeNow(); long now = SecondbotHelpers.UnixTimeNow();
foreach (KeyValuePair<UUID, long> entry in ChatHistoryLastAccessed) foreach (KeyValuePair<UUID, long> entry in ChatHistoryLastAccessed)
{ {
@ -292,7 +292,7 @@ namespace SecondBotEvents.Services
// are we using redis? // are we using redis?
if (RedisLive() == false) if (RedisLive() == false)
{ {
return new List<KeyValuePair<string, string>>(); return [];
} }
// is redis enabled for this message type? // is redis enabled for this message type?
if ((myConfig.GetRedisImchat() == true) && (avatarchat == true)) if ((myConfig.GetRedisImchat() == true) && (avatarchat == true))
@ -311,7 +311,7 @@ namespace SecondBotEvents.Services
return ReadChatFromRedis(store); return ReadChatFromRedis(store);
} }
// Redis is not enabled for this message type, use local storage // Redis is not enabled for this message type, use local storage
return new List<KeyValuePair<string, string>>(); return [];
} }
@ -319,7 +319,7 @@ namespace SecondBotEvents.Services
{ {
try try
{ {
RedisKey readkey = new RedisKey(myConfig.GetRedisPrefix() + store.Guid.ToString()); RedisKey readkey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
if (redisDb.KeyExists(readkey) == false) if (redisDb.KeyExists(readkey) == false)
{ {
string rawstring = redisDb.StringGet(readkey); string rawstring = redisDb.StringGet(readkey);
@ -343,7 +343,7 @@ namespace SecondBotEvents.Services
{ {
if (chatHistoryAI.ContainsKey(store) == false) if (chatHistoryAI.ContainsKey(store) == false)
{ {
return new List<KeyValuePair<string, string>>(); return [];
} }
return chatHistoryAI[store]; return chatHistoryAI[store];
} }
@ -363,7 +363,7 @@ namespace SecondBotEvents.Services
if (chatHistoryAI.ContainsKey(store) == false) if (chatHistoryAI.ContainsKey(store) == false)
{ {
// totaly new chat build it out // totaly new chat build it out
chatHistoryAI.Add(store, new List<KeyValuePair<string, string>>()); chatHistoryAI.Add(store, []);
string yourname = GetClient().Self.FirstName; string yourname = GetClient().Self.FirstName;
if (myConfig.GetCustomName() != "<!FIRSTNAME!>") if (myConfig.GetCustomName() != "<!FIRSTNAME!>")
{ {
@ -437,7 +437,7 @@ namespace SecondBotEvents.Services
{ {
history.RemoveAt(1); history.RemoveAt(1);
} }
RedisKey writekey = new RedisKey(myConfig.GetRedisPrefix() + store.Guid.ToString()); RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
try try
{ {
string savestring = JsonConvert.SerializeObject(history); string savestring = JsonConvert.SerializeObject(history);
@ -446,7 +446,7 @@ namespace SecondBotEvents.Services
LogFormater.Warn("Redis failed to convert history into savable format"); LogFormater.Warn("Redis failed to convert history into savable format");
return false; return false;
} }
RedisValue storeme = new RedisValue(savestring); RedisValue storeme = new(savestring);
if(redisDb.StringSet(writekey, storeme) == true) if(redisDb.StringSet(writekey, storeme) == true)
{ {
return redisDb.KeyExpire(writekey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins())); return redisDb.KeyExpire(writekey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins()));
@ -506,7 +506,7 @@ namespace SecondBotEvents.Services
{ {
ChatRateLimiter[user] = SecondbotHelpers.UnixTimeNow() + 1; ChatRateLimiter[user] = SecondbotHelpers.UnixTimeNow() + 1;
} }
List<ChatMessage> messages = new List<ChatMessage>(); List<ChatMessage> messages = [];
lock (chatHistoryAI) lock (ChatHistoryLastAccessed) lock (chatHistoryAI) lock (ChatHistoryLastAccessed)
{ {
// convert history into the AI format while adding the new message // convert history into the AI format while adding the new message
@ -646,7 +646,7 @@ namespace SecondBotEvents.Services
} }
} }
private static readonly Random _random = new Random(); private static readonly Random _random = new();
public static double EstimateTypingTime(string input, double randomizationFactor) public static double EstimateTypingTime(string input, double randomizationFactor)
{ {

View file

@ -13,19 +13,13 @@ using System.ComponentModel.DataAnnotations;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
public class BotCommandNotice public class BotCommandNotice(string Setcommand, string Setargs, string Setsource, bool Setaccepted, string Setresults)
{ {
public string command; public string command = Setcommand;
public string args; public string args = Setargs;
public string source; public string source = Setsource;
public bool accepted; public bool accepted = Setaccepted;
public BotCommandNotice(string Setcommand, string Setargs, string Setsource, bool Setaccepted) public string results = Setresults;
{
command = Setcommand;
args = Setargs;
source = Setsource;
accepted = Setaccepted;
}
} }
public class CommandsService : BotServices public class CommandsService : BotServices
{ {
@ -35,10 +29,10 @@ namespace SecondBotEvents.Services
add { lock (BotCommandNoticeLockable) { BotclientCommandEventNotices += value; } } add { lock (BotCommandNoticeLockable) { BotclientCommandEventNotices += value; } }
remove { lock (BotCommandNoticeLockable) { BotclientCommandEventNotices -= value; } } remove { lock (BotCommandNoticeLockable) { BotclientCommandEventNotices -= value; } }
} }
private readonly object BotCommandNoticeLockable = new object(); private readonly object BotCommandNoticeLockable = new();
public CommandsConfig myConfig = null; public new CommandsConfig myConfig = null;
public bool acceptNewCommands = false; public bool acceptNewCommands = false;
public CommandsService(EventsSecondBot setMaster) : base(setMaster) public CommandsService(EventsSecondBot setMaster) : base(setMaster)
{ {
@ -66,7 +60,7 @@ namespace SecondBotEvents.Services
protected virtual void LoadCommandEndpoint(Type endpointtype) protected virtual void LoadCommandEndpoint(Type endpointtype)
{ {
CommandsAPI controler = (CommandsAPI)Activator.CreateInstance(endpointtype, args: new object[] { master }); CommandsAPI controler = (CommandsAPI)Activator.CreateInstance(endpointtype, args: [master]);
commandEndpoints.Add(endpointtype.Name, controler); commandEndpoints.Add(endpointtype.Name, controler);
foreach (MethodInfo M in endpointtype.GetMethods()) foreach (MethodInfo M in endpointtype.GetMethods())
{ {
@ -221,7 +215,7 @@ namespace SecondBotEvents.Services
{ {
source = "customcommand"; source = "customcommand";
} }
SignedCommand C = new SignedCommand(this,source,message,requireSigning,myConfig.GetEnforceTimeWindow(),myConfig.GetTimeWindowSecs(),myConfig.GetSharedSecret()); SignedCommand C = new(this,source,message,requireSigning,myConfig.GetEnforceTimeWindow(),myConfig.GetTimeWindowSecs(),myConfig.GetSharedSecret());
if (C.accepted == false) if (C.accepted == false)
{ {
return new KeyValuePair<bool, string>(false, "Not accepted via signing"); return new KeyValuePair<bool, string>(false, "Not accepted via signing");
@ -276,7 +270,7 @@ namespace SecondBotEvents.Services
} }
else if (mode == "HTTP") else if (mode == "HTTP")
{ {
Dictionary<string, string> values = new Dictionary<string, string> Dictionary<string, string> values = new()
{ {
{ "reply", output }, { "reply", output },
{ "command", command }, { "command", command },
@ -301,7 +295,7 @@ namespace SecondBotEvents.Services
} }
} }
} }
protected HttpClient HTTPclient = new HttpClient(); protected HttpClient HTTPclient = new();
protected KeyValuePair<bool, string> RunBaseCommand(SignedCommand C, string source) protected KeyValuePair<bool, string> RunBaseCommand(SignedCommand C, string source)
{ {
@ -311,10 +305,10 @@ namespace SecondBotEvents.Services
MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command); MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command);
if (theMethod != null) if (theMethod != null)
{ {
List<string> argsList = C.args.ToList(); List<string> argsList = [.. C.args];
string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Count().ToString() + " but got: " + argsList.Count.ToString(); string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Length.ToString() + " but got: " + argsList.Count.ToString();
bool status = false; bool status = false;
if (argsList.Count == theMethod.GetParameters().Count()) if (argsList.Count == theMethod.GetParameters().Length)
{ {
status = true; status = true;
try try
@ -323,23 +317,23 @@ namespace SecondBotEvents.Services
{ {
return new KeyValuePair<bool, string>(false, "Endpoint is null"); return new KeyValuePair<bool, string>(false, "Endpoint is null");
} }
object[] argsWorker = argsList.ToArray<object>(); object[] argsWorker = [.. argsList];
object processed = theMethod.Invoke(Endpoint, argsWorker); object processed = theMethod.Invoke(Endpoint, argsWorker);
reply = "Error"; reply = "Error";
if (processed != null) if (processed != null)
{ {
reply = JsonConvert.SerializeObject(processed); reply = JsonConvert.SerializeObject(processed);
} }
CommandNotice(C.command, source, String.Join("@@@", C.args), true); CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply);
return new KeyValuePair<bool, string>(status, reply); return new KeyValuePair<bool, string>(status, reply);
} }
catch (Exception e) catch (Exception e)
{ {
CommandNotice(C.command, source+" ~~ Failure: "+e.Message, String.Join("@@@", C.args), false); CommandNotice(C.command, source+" ~~ Failure: "+e.Message, String.Join("@@@", C.args), false, e.Message);
return new KeyValuePair<bool, string>(false, e.Message); return new KeyValuePair<bool, string>(false, e.Message);
} }
} }
CommandNotice(C.command, source + " ~~ Failure: incorrect number of args expected: "+ theMethod.GetParameters().Count().ToString()+" but got "+ argsList.Count.ToString()+"", String.Join("@@@", C.args), false); CommandNotice(C.command, source + " ~~ Failure: incorrect number of args expected: "+ theMethod.GetParameters().Length.ToString()+" but got "+ argsList.Count.ToString()+"", String.Join("@@@", C.args), false, "no results");
return new KeyValuePair<bool, string>(status, reply); return new KeyValuePair<bool, string>(status, reply);
} }
return new KeyValuePair<bool, string>(false, "theMethod is null"); return new KeyValuePair<bool, string>(false, "theMethod is null");
@ -392,17 +386,17 @@ namespace SecondBotEvents.Services
public string[] GetFullListOfCommands() public string[] GetFullListOfCommands()
{ {
List<string> output = new List<string>(); List<string> output = [];
foreach (string A in endpointcommandmap.Keys) foreach (string A in endpointcommandmap.Keys)
{ {
output.Add(A.ToLowerInvariant()); output.Add(A.ToLowerInvariant());
} }
return output.ToArray(); return [.. output];
} }
protected Dictionary<string, CommandsAPI> commandEndpoints = new Dictionary<string, CommandsAPI>(); protected Dictionary<string, CommandsAPI> commandEndpoints = [];
protected Dictionary<string, string> endpointcommandmap = new Dictionary<string, string>(); // command = endpoint protected Dictionary<string, string> endpointcommandmap = []; // command = endpoint
protected Dictionary<string, string> commandnameLowerToReal = new Dictionary<string, string>(); protected Dictionary<string, string> commandnameLowerToReal = [];
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
@ -440,9 +434,13 @@ namespace SecondBotEvents.Services
LogFormater.Info("Commands service [accepting IM commands]"); LogFormater.Info("Commands service [accepting IM commands]");
} }
public void CommandNotice(string command,string source, string args,bool accepted) public void CommandNotice(string command,string source, string args,bool accepted, string results)
{ {
BotCommandNotice e = new BotCommandNotice(command, args, source, accepted); if(myConfig.GetCommandHistoryLogResults() == false)
{
results = "";
}
BotCommandNotice e = new(command, args, source, accepted, results);
EventHandler<BotCommandNotice> handler = BotclientCommandEventNotices; EventHandler<BotCommandNotice> handler = BotclientCommandEventNotices;
handler?.Invoke(this, e); handler?.Invoke(this, e);
if(master.BotClient.basicCfg.GetLogCommands() == true) if(master.BotClient.basicCfg.GetLogCommands() == true)
@ -561,7 +559,7 @@ namespace SecondBotEvents.Services
command = bits[0]; command = bits[0];
// command // command
// args~#~args~#~args // args~#~args~#~args
args = new string[] { }; args = [];
if(bits.Length == 2) if(bits.Length == 2)
{ {
args = bits[1].Split("~#~"); args = bits[1].Split("~#~");

View file

@ -12,23 +12,19 @@ using static SecondBotEvents.Services.RLVService;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
public class CurrentOutfitFolder : BotServices public class CurrentOutfitFolder(EventsSecondBot setMaster) : BotServices(setMaster)
{ {
#region Fields #region Fields
private bool InitiCOF = false; private bool InitiCOF = false;
private bool AppearanceSent = false; private bool AppearanceSent = false;
private bool COFReady = false; private bool COFReady = false;
private bool InitialUpdateDone = false; private bool InitialUpdateDone = false;
public Dictionary<UUID, InventoryItem> Content = new Dictionary<UUID, InventoryItem>(); public Dictionary<UUID, InventoryItem> Content = [];
public InventoryFolder COF; public InventoryFolder COF;
protected bool botConnected = false; protected bool botConnected = false;
#endregion Fields #endregion Fields
#region Construction and disposal #region Construction and disposal
public CurrentOutfitFolder(EventsSecondBot setMaster) : base(setMaster)
{
}
public override string Status() public override string Status()
{ {
@ -156,7 +152,7 @@ namespace SecondBotEvents.Services
} }
} }
private readonly object FolderSync = new object(); private readonly object FolderSync = new();
private void Inventory_FolderUpdated(object sender, FolderUpdatedEventArgs e) private void Inventory_FolderUpdated(object sender, FolderUpdatedEventArgs e)
{ {
@ -170,8 +166,8 @@ namespace SecondBotEvents.Services
lock (Content) Content.Clear(); lock (Content) Content.Clear();
List<UUID> items = new List<UUID>(); List<UUID> items = [];
List<UUID> owners = new List<UUID>(); List<UUID> owners = [];
foreach (var link in ContentLinks()) foreach (var link in ContentLinks())
{ {
@ -198,8 +194,7 @@ namespace SecondBotEvents.Services
{ {
if (GetClient().Network.CurrentSim != e.Simulator) return; if (GetClient().Network.CurrentSim != e.Simulator) return;
Primitive prim = null; if (GetClient().Network.CurrentSim.ObjectsPrimitives.TryGetValue(e.ObjectLocalID, out Primitive prim))
if (GetClient().Network.CurrentSim.ObjectsPrimitives.TryGetValue(e.ObjectLocalID, out prim))
{ {
UUID invItem = GetAttachmentItem(prim); UUID invItem = GetAttachmentItem(prim);
if (invItem != UUID.Zero) if (invItem != UUID.Zero)
@ -417,7 +412,7 @@ namespace SecondBotEvents.Services
/// <param name="itemID">ID of the target inventory item for which we want link to be removed</param> /// <param name="itemID">ID of the target inventory item for which we want link to be removed</param>
public void RemoveLink(UUID itemID) public void RemoveLink(UUID itemID)
{ {
RemoveLink(new List<UUID>(1) { itemID }); RemoveLink([itemID]);
} }
/// <summary> /// <summary>
@ -539,7 +534,7 @@ namespace SecondBotEvents.Services
/// <param name="replace">Should existing wearable of the same type be removed</param> /// <param name="replace">Should existing wearable of the same type be removed</param>
public void AddToOutfit(InventoryItem item, bool replace) public void AddToOutfit(InventoryItem item, bool replace)
{ {
AddToOutfit(new List<InventoryItem>(1) { item }, replace); AddToOutfit([item], replace);
} }
/// <summary> /// <summary>
@ -607,7 +602,7 @@ namespace SecondBotEvents.Services
/// <param name="item">Item to remove</param> /// <param name="item">Item to remove</param>
public void RemoveFromOutfit(InventoryItem item) public void RemoveFromOutfit(InventoryItem item)
{ {
RemoveFromOutfit(new List<InventoryItem>(1) { item }); RemoveFromOutfit([item]);
} }
/// <summary> /// <summary>

View file

@ -13,7 +13,7 @@ namespace SecondBotEvents.Services
{ {
protected new CustomCommandsConfig myConfig; protected new CustomCommandsConfig myConfig;
protected bool botConnected = false; protected bool botConnected = false;
protected Dictionary<string, CustomCommand> commands = new Dictionary<string, CustomCommand>(); protected Dictionary<string, CustomCommand> commands = [];
public bool HasCommand(string C) public bool HasCommand(string C)
{ {
return commands.ContainsKey(C); return commands.ContainsKey(C);
@ -57,9 +57,11 @@ namespace SecondBotEvents.Services
int loop = 1; int loop = 1;
while(loop <= myConfig.GetCount()) while(loop <= myConfig.GetCount())
{ {
CustomCommand C = new CustomCommand(); CustomCommand C = new()
C.trigger = myConfig.GetCommandTrigger(loop); {
C.args = myConfig.GetCommandArgs(loop); trigger = myConfig.GetCommandTrigger(loop),
args = myConfig.GetCommandArgs(loop)
};
int loop2 = 1; int loop2 = 1;
while(loop2 <= myConfig.GetCommandSteps(loop)) while(loop2 <= myConfig.GetCommandSteps(loop))
{ {
@ -127,6 +129,6 @@ namespace SecondBotEvents.Services
{ {
public string trigger = ""; public string trigger = "";
public int args = 0; public int args = 0;
public List<string> steps = new List<string>(); public List<string> steps = [];
} }
} }

View file

@ -21,25 +21,25 @@ namespace SecondBotEvents.Services
myConfig = new DataStoreConfig(master.fromEnv,master.fromFolder); myConfig = new DataStoreConfig(master.fromEnv,master.fromFolder);
} }
protected Dictionary<string, UUID> avatarsName2Key = new(); protected Dictionary<string, UUID> avatarsName2Key = [];
protected Dictionary<UUID, long> avatarLastUsed = new(); protected Dictionary<UUID, long> avatarLastUsed = [];
protected Dictionary<UUID, string> groupsKey2Name = new(); protected Dictionary<UUID, string> groupsKey2Name = [];
protected Dictionary<UUID, List<UUID>> groupMembers = new(); protected Dictionary<UUID, List<UUID>> groupMembers = [];
protected Dictionary<UUID, Dictionary<UUID, GroupRole>> groupRoles = new(); protected Dictionary<UUID, Dictionary<UUID, GroupRole>> groupRoles = [];
protected List<string> localChatHistory = new(); protected List<string> localChatHistory = [];
protected Dictionary<UUID, List<string>> chatWindows = new(); // sess, list chat protected Dictionary<UUID, List<string>> chatWindows = []; // sess, list chat
protected Dictionary<UUID, bool> chatWindowsUnread = new(); // sess, bool protected Dictionary<UUID, bool> chatWindowsUnread = []; // sess, bool
protected Dictionary<UUID, bool> chatWindowsIsGroup = new(); // sess, bool protected Dictionary<UUID, bool> chatWindowsIsGroup = []; // sess, bool
protected Dictionary<UUID, UUID> chatWindowsOwner = new(); // sess, owner id protected Dictionary<UUID, UUID> chatWindowsOwner = []; // sess, owner id
protected Dictionary<string, string> KeyValueStore = new(); protected Dictionary<string, string> KeyValueStore = [];
protected Dictionary<string, long> KeyValueStoreLastUsed = new(); protected Dictionary<string, long> KeyValueStoreLastUsed = [];
protected List<CommandHistory> commandHistories = new(); protected List<CommandHistory> commandHistories = [];
@ -47,8 +47,8 @@ namespace SecondBotEvents.Services
protected long lastCleanupKeyValueStore = 0; protected long lastCleanupKeyValueStore = 0;
protected long lastCleanupAvatarStore = 0; protected long lastCleanupAvatarStore = 0;
protected List<string> acceptedStores = new List<string>() { "FriendRequest", "InventoryOffer", "GroupInvite", "Teleport" }; protected List<string> acceptedStores = ["FriendRequest", "InventoryOffer", "GroupInvite", "Teleport"];
protected Dictionary<string, List<UUID>> AcceptNextStore = new Dictionary<string, List<UUID>>(); protected Dictionary<string, List<UUID>> AcceptNextStore = [];
public bool KnownStoreType(string storeType) public bool KnownStoreType(string storeType)
{ {
return acceptedStores.Contains(storeType); return acceptedStores.Contains(storeType);
@ -82,7 +82,7 @@ namespace SecondBotEvents.Services
} }
if(AcceptNextStore.ContainsKey(store) == false) if(AcceptNextStore.ContainsKey(store) == false)
{ {
AcceptNextStore.Add(store, new List<UUID>()); AcceptNextStore.Add(store, []);
} }
if(AcceptNextStore[store].Contains(avatar) == true) if(AcceptNextStore[store].Contains(avatar) == true)
{ {
@ -155,7 +155,7 @@ namespace SecondBotEvents.Services
if (dif > 125) if (dif > 125)
{ {
lastCleanupKeyValueStore = unixtime; lastCleanupKeyValueStore = unixtime;
List<string> clearentrys = new(); List<string> clearentrys = [];
foreach (KeyValuePair<string, long> entry in KeyValueStoreLastUsed) foreach (KeyValuePair<string, long> entry in KeyValueStoreLastUsed)
{ {
dif = unixtime - entry.Value; dif = unixtime - entry.Value;
@ -185,7 +185,7 @@ namespace SecondBotEvents.Services
if (dif > 75) if (dif > 75)
{ {
lastCleanupAvatarStore = unixtime; lastCleanupAvatarStore = unixtime;
Dictionary<UUID, string> clearLinks = new(); Dictionary<UUID, string> clearLinks = [];
foreach (KeyValuePair<string, UUID> entry in avatarsName2Key) foreach (KeyValuePair<string, UUID> entry in avatarsName2Key)
{ {
dif = unixtime - avatarLastUsed[entry.Value]; dif = unixtime - avatarLastUsed[entry.Value];
@ -212,11 +212,11 @@ namespace SecondBotEvents.Services
return sum.ToString(); return sum.ToString();
} }
public void AddCommandToHistory(bool status, string command, string[] args) public void AddCommandToHistory(bool status, string command, string[] args, string results=null)
{ {
lock (commandHistories) lock (commandHistories)
{ {
CommandHistory A = new(status, command, args, SecondbotHelpers.UnixTimeNow()); CommandHistory A = new(status, command, args, SecondbotHelpers.UnixTimeNow(), results);
commandHistories.Add(A); commandHistories.Add(A);
int c = commandHistories.Count; int c = commandHistories.Count;
while (c > myConfig.GetCommandHistoryLimit()) while (c > myConfig.GetCommandHistoryLimit())
@ -290,7 +290,7 @@ namespace SecondBotEvents.Services
public List<UUID> GetAllGroupsChatWithUnread() public List<UUID> GetAllGroupsChatWithUnread()
{ {
List<UUID> reply = new(); List<UUID> reply = [];
foreach(KeyValuePair<UUID, bool> windowState in chatWindowsUnread) foreach(KeyValuePair<UUID, bool> windowState in chatWindowsUnread)
{ {
if(windowState.Value == false) if(windowState.Value == false)
@ -338,7 +338,7 @@ namespace SecondBotEvents.Services
{ {
if(chatWindows.ContainsKey(group) == false) if(chatWindows.ContainsKey(group) == false)
{ {
return new List<string>(); return [];
} }
chatWindowsUnread[group] = false; chatWindowsUnread[group] = false;
return chatWindows[group]; return chatWindows[group];
@ -364,7 +364,7 @@ namespace SecondBotEvents.Services
public Dictionary<UUID, string> GetGroupRoles(UUID group) public Dictionary<UUID, string> GetGroupRoles(UUID group)
{ {
Dictionary<UUID, string> reply = new(); Dictionary<UUID, string> reply = [];
if (groupRoles.ContainsKey(group) == false) if (groupRoles.ContainsKey(group) == false)
{ {
@ -401,7 +401,7 @@ namespace SecondBotEvents.Services
{ {
if (groupMembers.ContainsKey(group) == false) if (groupMembers.ContainsKey(group) == false)
{ {
groupMembers.Add(group, new List<UUID>()); groupMembers.Add(group, []);
} }
if (groupMembers[group].Contains(avatar) == false) if (groupMembers[group].Contains(avatar) == false)
{ {
@ -439,7 +439,7 @@ namespace SecondBotEvents.Services
{ {
if (groupMembers.ContainsKey(Group) == false) if (groupMembers.ContainsKey(Group) == false)
{ {
groupMembers.Add(Group, new List<UUID>()); groupMembers.Add(Group, []);
} }
} }
return groupMembers[Group]; return groupMembers[Group];
@ -544,7 +544,7 @@ namespace SecondBotEvents.Services
} }
return; // chat recovered return; // chat recovered
} }
chatWindows.Add(sessionID, new List<string>()); chatWindows.Add(sessionID, []);
chatWindowsUnread.Add(sessionID, false); chatWindowsUnread.Add(sessionID, false);
chatWindowsIsGroup.Add(sessionID, group); chatWindowsIsGroup.Add(sessionID, group);
chatWindowsOwner.Add(sessionID, ownerID); chatWindowsOwner.Add(sessionID, ownerID);
@ -553,7 +553,7 @@ namespace SecondBotEvents.Services
} }
protected Dictionary<string, KeyValuePair<string, long>> notecardDataStore = new(); protected Dictionary<string, KeyValuePair<string, long>> notecardDataStore = [];
public List<string> GetLocalChat() public List<string> GetLocalChat()
{ {
@ -593,7 +593,7 @@ namespace SecondBotEvents.Services
if (currentHash != ObjectsAvatarsHash) if (currentHash != ObjectsAvatarsHash)
{ {
ObjectsAvatarsHash = currentHash; ObjectsAvatarsHash = currentHash;
List<Avatar> avs = GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values.ToList(); List<Avatar> avs = [.. GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values];
foreach (Avatar A in avs) foreach (Avatar A in avs)
{ {
AddAvatar(A.ID, A.Name); AddAvatar(A.ID, A.Name);
@ -662,7 +662,7 @@ namespace SecondBotEvents.Services
public void GetAvatarNames(List<UUID> avatars) public void GetAvatarNames(List<UUID> avatars)
{ {
List<UUID> lookup = new(); List<UUID> lookup = [];
foreach (UUID id in avatars) foreach (UUID id in avatars)
{ {
if (avatarsName2Key.ContainsValue(id) == false) if (avatarsName2Key.ContainsValue(id) == false)
@ -715,7 +715,7 @@ namespace SecondBotEvents.Services
public Dictionary<UUID,string> GetAvatarImWindows() public Dictionary<UUID,string> GetAvatarImWindows()
{ {
Dictionary<UUID, string> windows = new(); Dictionary<UUID, string> windows = [];
foreach (KeyValuePair<UUID,bool> links in chatWindowsIsGroup) foreach (KeyValuePair<UUID,bool> links in chatWindowsIsGroup)
{ {
if(links.Value == true) if(links.Value == true)
@ -735,7 +735,7 @@ namespace SecondBotEvents.Services
{ {
if (chatWindowsOwner.ContainsValue(avatarId) == false) if (chatWindowsOwner.ContainsValue(avatarId) == false)
{ {
return new List<string>(); return [];
} }
UUID sessionID = UUID.Zero; UUID sessionID = UUID.Zero;
foreach (KeyValuePair<UUID, UUID> links in chatWindowsOwner) foreach (KeyValuePair<UUID, UUID> links in chatWindowsOwner)
@ -748,7 +748,7 @@ namespace SecondBotEvents.Services
} }
if(chatWindowsIsGroup[sessionID] == true) if(chatWindowsIsGroup[sessionID] == true)
{ {
return new List<string>(); return [];
} }
chatWindowsUnread[sessionID] = false; chatWindowsUnread[sessionID] = false;
return chatWindows[sessionID]; return chatWindows[sessionID];
@ -780,7 +780,7 @@ namespace SecondBotEvents.Services
public List<UUID> GetAvatarImWindowsUnread() public List<UUID> GetAvatarImWindowsUnread()
{ {
List<UUID> windows = new(); List<UUID> windows = [];
foreach (KeyValuePair<UUID, bool> links in chatWindowsIsGroup) foreach (KeyValuePair<UUID, bool> links in chatWindowsIsGroup)
{ {
if (links.Value == true) if (links.Value == true)
@ -819,23 +819,23 @@ namespace SecondBotEvents.Services
{ {
lastCleanupKeyValueStore = 0; lastCleanupKeyValueStore = 0;
avatarsName2Key = new Dictionary<string, UUID>(); avatarsName2Key = [];
groupsKey2Name = new Dictionary<UUID, string>(); groupsKey2Name = [];
groupMembers = new Dictionary<UUID, List<UUID>>(); groupMembers = [];
groupRoles = new Dictionary<UUID, Dictionary<UUID, GroupRole>>(); groupRoles = [];
localChatHistory = new List<string>(); localChatHistory = [];
notecardDataStore = new Dictionary<string, KeyValuePair<string, long>>(); notecardDataStore = [];
chatWindows = new Dictionary<UUID, List<string>>(); // sess, list chat chatWindows = []; // sess, list chat
chatWindowsUnread = new Dictionary<UUID, bool>(); // sess, bool chatWindowsUnread = []; // sess, bool
chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool chatWindowsIsGroup = []; // sess, bool
chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id chatWindowsOwner = []; // sess, owner id
estateBanlist = new List<UUID>(); estateBanlist = [];
} }
@ -864,7 +864,7 @@ namespace SecondBotEvents.Services
{ {
if (groupRoles.ContainsKey(e.GroupID) == false) if (groupRoles.ContainsKey(e.GroupID) == false)
{ {
groupRoles.Add(e.GroupID, new Dictionary<UUID, GroupRole>()); groupRoles.Add(e.GroupID, []);
} }
groupRoles[e.GroupID] = e.Roles; groupRoles[e.GroupID] = e.Roles;
} }
@ -878,7 +878,7 @@ namespace SecondBotEvents.Services
{ {
groupMembers.Remove(e.GroupID); groupMembers.Remove(e.GroupID);
} }
groupMembers.Add(e.GroupID, new List<UUID>()); groupMembers.Add(e.GroupID, []);
foreach (KeyValuePair<UUID, GroupMember> a in e.Members) foreach (KeyValuePair<UUID, GroupMember> a in e.Members)
{ {
groupMembers[e.GroupID].Add(a.Value.ID); groupMembers[e.GroupID].Add(a.Value.ID);
@ -890,7 +890,7 @@ namespace SecondBotEvents.Services
{ {
if (estateBanlist == null) if (estateBanlist == null)
{ {
List<UUID> reply = new(); List<UUID> reply = [];
AutoResetEvent fetchEvent = new(false); AutoResetEvent fetchEvent = new(false);
void callback(object sender, EstateBansReplyEventArgs e) void callback(object sender, EstateBansReplyEventArgs e)
{ {
@ -907,8 +907,8 @@ namespace SecondBotEvents.Services
return estateBanlist; return estateBanlist;
} }
List<UUID> estateBanlist = null; protected List<UUID> estateBanlist = null;
Dictionary<UUID, FriendLocations> FriendMapLocations = new Dictionary<UUID, FriendLocations>(); protected Dictionary<UUID, FriendLocations> FriendMapLocations = [];
public FriendLocations GetFriendMap(UUID id) public FriendLocations GetFriendMap(UUID id)
{ {
@ -921,8 +921,7 @@ namespace SecondBotEvents.Services
protected void FindFriendReply(object o, FriendFoundReplyEventArgs e) protected void FindFriendReply(object o, FriendFoundReplyEventArgs e)
{ {
uint x, y; Utils.LongToUInts(e.RegionHandle, out uint x, out uint y);
Utils.LongToUInts(e.RegionHandle, out x, out y);
x /= 256; x /= 256;
y /= 256; y /= 256;
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy(); Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
@ -930,7 +929,7 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
FriendLocations NewEntry = new FriendLocations(FriendListCopy[e.AgentID].Name, e.Location, new Vector3(x,y,10)); FriendLocations NewEntry = new(FriendListCopy[e.AgentID].Name, e.Location, new Vector3(x,y,10));
if(FriendMapLocations.ContainsKey(e.AgentID) == false) if(FriendMapLocations.ContainsKey(e.AgentID) == false)
{ {
FriendMapLocations.Add(e.AgentID, NewEntry); FriendMapLocations.Add(e.AgentID, NewEntry);
@ -955,12 +954,12 @@ namespace SecondBotEvents.Services
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
Thread.Sleep(2000); Thread.Sleep(2000);
attachEventsAfterDelay(); AttachEventsAfterDelay();
}); });
} }
Dictionary<UUID, Avatar.AvatarProperties> avprops = new Dictionary<UUID, Avatar.AvatarProperties>(); Dictionary<UUID, Avatar.AvatarProperties> avprops = [];
public KeyValuePair<bool,Avatar.AvatarProperties> GetAvatarAvatarProperties(UUID agentID) public KeyValuePair<bool,Avatar.AvatarProperties> GetAvatarAvatarProperties(UUID agentID)
{ {
if (avprops.ContainsKey(agentID) == false) if (avprops.ContainsKey(agentID) == false)
@ -980,7 +979,7 @@ namespace SecondBotEvents.Services
avprops[e.AvatarID] = e.Properties; avprops[e.AvatarID] = e.Properties;
} }
protected void attachEventsAfterDelay() protected void AttachEventsAfterDelay()
{ {
GetClient().Groups.CurrentGroups += GroupCurrent; GetClient().Groups.CurrentGroups += GroupCurrent;
GetClient().Groups.GroupJoinedReply += GroupJoin; GetClient().Groups.GroupJoinedReply += GroupJoin;
@ -996,9 +995,9 @@ namespace SecondBotEvents.Services
GetClient().Friends.FriendFoundReply += FindFriendReply; GetClient().Friends.FriendFoundReply += FindFriendReply;
GetClient().Avatars.AvatarPropertiesReply += AvatarDetailsReply; GetClient().Avatars.AvatarPropertiesReply += AvatarDetailsReply;
GetClient().Groups.RequestCurrentGroups(); GetClient().Groups.RequestCurrentGroups();
GetClient().Self.RetrieveInstantMessages(); _ = GetClient().Self.RetrieveInstantMessages();
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = ["secondlife", "second life"];
protected void ChatFromSim(object o, ChatEventArgs e) protected void ChatFromSim(object o, ChatEventArgs e)
{ {
switch(e.Type) switch(e.Type)
@ -1046,7 +1045,7 @@ namespace SecondBotEvents.Services
{ {
lock (groupsKey2Name) lock (groupsKey2Name)
{ {
List<UUID> missingGroups = groupsKey2Name.Keys.ToList(); List<UUID> missingGroups = [.. groupsKey2Name.Keys];
foreach (Group G in e.Groups.Values) foreach (Group G in e.Groups.Values)
{ {
missingGroups.Remove(G.ID); missingGroups.Remove(G.ID);
@ -1217,35 +1216,21 @@ namespace SecondBotEvents.Services
} }
} }
public class CommandHistory public class CommandHistory(bool setStatus, string setCommand, string[] setArgs, long setUnixtime, string Setresults)
{ {
public string Command = ""; public string Command = setCommand;
public string[] Args = Array.Empty<string>(); public string[] Args = setArgs;
public long Unixtime = 0; public long Unixtime = setUnixtime;
public bool status = false; public bool status = setStatus;
public string results = Setresults;
}
public CommandHistory(bool setStatus, string setCommand, string[] setArgs, long setUnixtime) public class FriendLocations(string SetName, Vector3 setPos, Vector3 setRegionPos)
{ {
status = setStatus; public string Name = SetName;
Command = setCommand; public Vector3 Pos = setPos;
Args = setArgs; public Vector3 RegionPos = setRegionPos;
Unixtime = setUnixtime; public long time = SecondbotHelpers.UnixTimeNow();
}
}
public class FriendLocations
{
public string Name;
public Vector3 Pos;
public Vector3 RegionPos;
public long time;
public FriendLocations(string SetName, Vector3 setPos, Vector3 setRegionPos)
{
time = SecondbotHelpers.UnixTimeNow();
Name = SetName;
Pos = setPos;
RegionPos = setRegionPos;
}
} }
} }

View file

@ -138,7 +138,7 @@ namespace SecondBotEvents.Services
lock(DialogWindows) lock(DialogWindows)
{ {
long unixtime = SecondbotHelpers.UnixTimeNow(); long unixtime = SecondbotHelpers.UnixTimeNow();
List<int> removeids = new List<int>(); List<int> removeids = [];
foreach(KeyValuePair<int,long> a in DialogWindowsExpire) foreach(KeyValuePair<int,long> a in DialogWindowsExpire)
{ {
if(a.Value > unixtime) if(a.Value > unixtime)
@ -157,12 +157,12 @@ namespace SecondBotEvents.Services
protected Dictionary<int, ScriptDialogEventArgs> DialogWindows = new Dictionary<int, ScriptDialogEventArgs>(); protected Dictionary<int, ScriptDialogEventArgs> DialogWindows = [];
protected Dictionary<int, long> DialogWindowsExpire = new Dictionary<int, long>(); protected Dictionary<int, long> DialogWindowsExpire = [];
protected int nextDialogWindow = 1; protected int nextDialogWindow = 1;
protected List<int> DialogRelayChannels = new List<int>(); protected List<int> DialogRelayChannels = [];
protected List<UUID> DialogRelayAvatars = new List<UUID>(); protected List<UUID> DialogRelayAvatars = [];
protected List<string> DialogRelayHTTP = new List<string>(); protected List<string> DialogRelayHTTP = [];
protected UUID objectOwnerOnly = UUID.Zero; protected UUID objectOwnerOnly = UUID.Zero;
protected void DialogWindowEvent(object sender, ScriptDialogEventArgs e) protected void DialogWindowEvent(object sender, ScriptDialogEventArgs e)
@ -182,12 +182,14 @@ namespace SecondBotEvents.Services
DialogWindows.Add(windowid, e); DialogWindows.Add(windowid, e);
long expiresAt = SecondbotHelpers.UnixTimeNow() + 440; long expiresAt = SecondbotHelpers.UnixTimeNow() + 440;
DialogWindowsExpire.Add(windowid, expiresAt); DialogWindowsExpire.Add(windowid, expiresAt);
DialogWindow window = new DialogWindow(); DialogWindow window = new()
window.buttons = e.ButtonLabels.ToArray<string>(); {
window.dialogid = windowid; buttons = [.. e.ButtonLabels],
window.message = e.Message; dialogid = windowid,
window.objectname = e.ObjectName; message = e.Message,
window.expires = expiresAt; objectname = e.ObjectName,
expires = expiresAt
};
string eventMessage = JsonConvert.SerializeObject(window); string eventMessage = JsonConvert.SerializeObject(window);
foreach(int a in DialogRelayChannels) foreach(int a in DialogRelayChannels)
{ {

View file

@ -89,7 +89,7 @@ namespace SecondBotEvents.Services
return Task.CompletedTask; return Task.CompletedTask;
} }
private readonly object m_discordEventChatLock = new object(); private readonly object m_discordEventChatLock = new();
private EventHandler<SocketMessage> m_discordChatEvent; private EventHandler<SocketMessage> m_discordChatEvent;
/// <summary>Raised when a scripted object or agent within range sends a public message</summary> /// <summary>Raised when a scripted object or agent within range sends a public message</summary>
@ -104,27 +104,27 @@ namespace SecondBotEvents.Services
if (GetReadyForDiscordActions() == false) if (GetReadyForDiscordActions() == false)
{ {
// bot is not ready this message should not have got here yet. // bot is not ready this message should not have got here yet.
return new KeyValuePair<bool, List<string>>(false, new List<string>() { "not ready" }); return new KeyValuePair<bool, List<string>>(false, ["not ready"]);
} }
if (ulong.TryParse(givenserverid, out ulong serverid) == false) if (ulong.TryParse(givenserverid, out ulong serverid) == false)
{ {
return new KeyValuePair<bool, List<string>>(false, new List<string>() { "invaild server" }); return new KeyValuePair<bool, List<string>>(false, ["invaild server"]);
} }
if (ulong.TryParse(givenmemberid, out ulong memberid) == false) if (ulong.TryParse(givenmemberid, out ulong memberid) == false)
{ {
return new KeyValuePair<bool, List<string>>(false, new List<string>() { "invaild member" }); return new KeyValuePair<bool, List<string>>(false, ["invaild member"]);
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
if (server == null) if (server == null)
{ {
return new KeyValuePair<bool, List<string>>(false, new List<string>() { "Cant get server" }); return new KeyValuePair<bool, List<string>>(false, ["Cant get server"]);
} }
SocketGuildUser user = server.GetUser(memberid); SocketGuildUser user = server.GetUser(memberid);
if (user == null) if (user == null)
{ {
return new KeyValuePair<bool, List<string>>(false, new List<string>() { "Cant get user" }); return new KeyValuePair<bool, List<string>>(false, ["Cant get user"]);
} }
List<string> roleids = new List<string>(); List<string> roleids = [];
foreach (SocketRole role in user.Roles) foreach (SocketRole role in user.Roles)
{ {
roleids.Add(role.Id.ToString()); roleids.Add(role.Id.ToString());
@ -132,7 +132,7 @@ namespace SecondBotEvents.Services
return new KeyValuePair<bool, List<string>>(true, roleids); return new KeyValuePair<bool, List<string>>(true, roleids);
} }
protected HttpClient HTTPclient = new HttpClient(); protected HttpClient HTTPclient = new();
protected bool MessageInteractionEvent(SocketMessage message, SocketChannel socketChannel) protected bool MessageInteractionEvent(SocketMessage message, SocketChannel socketChannel)
{ {
if (myConfig.GetInteractionEnabled() != true) if (myConfig.GetInteractionEnabled() != true)
@ -155,7 +155,7 @@ namespace SecondBotEvents.Services
string getmessage = message.Content.Replace(myConfig.GetInteractionCommandName(), ""); string getmessage = message.Content.Replace(myConfig.GetInteractionCommandName(), "");
long unixtime = SecondbotHelpers.UnixTimeNow(); long unixtime = SecondbotHelpers.UnixTimeNow();
string hash = SecondbotHelpers.GetSHA1(unixtime.ToString() + getmessage + master.CommandsService.myConfig.GetSharedSecret()); string hash = SecondbotHelpers.GetSHA1(unixtime.ToString() + getmessage + master.CommandsService.myConfig.GetSharedSecret());
Dictionary<string, string> values = new Dictionary<string, string> Dictionary<string, string> values = new()
{ {
{ "message", getmessage }, { "message", getmessage },
{ "username", message.Author.Username }, { "username", message.Author.Username },
@ -310,8 +310,7 @@ namespace SecondBotEvents.Services
{ {
// handle group notice // handle group notice
// !notice {Title}@@@{Message}[@@@{Inventory UUID}] // !notice {Title}@@@{Message}[@@@{Inventory UUID}]
List<string> args = new List<string>(); List<string> args = [groupuuid.ToString()];
args.Add(groupuuid.ToString());
cleaned = cleaned.Replace("!notice ", ""); cleaned = cleaned.Replace("!notice ", "");
bits = cleaned.Split("@@@", StringSplitOptions.RemoveEmptyEntries); bits = cleaned.Split("@@@", StringSplitOptions.RemoveEmptyEntries);
args.AddRange(bits); args.AddRange(bits);
@ -321,10 +320,10 @@ namespace SecondBotEvents.Services
ReplyToMessage(message, "Notices require title and a message split with @@@!"); ReplyToMessage(message, "Notices require title and a message split with @@@!");
return; return;
} }
SignedCommand C = new SignedCommand( SignedCommand C = new(
master.CommandsService, master.CommandsService,
"discordapi", "discordapi",
"Groupnotice", null, args.ToArray(), 0, "none", false, 0, "", false); "Groupnotice", null, [.. args], 0, "none", false, 0, "", false);
if (bits.Length == 3) if (bits.Length == 3)
{ {
C.command = "GroupnoticeWithAttachment"; C.command = "GroupnoticeWithAttachment";
@ -336,35 +335,27 @@ namespace SecondBotEvents.Services
{ {
// handle group eject // handle group eject
cleaned = cleaned.Replace("!eject ", ""); cleaned = cleaned.Replace("!eject ", "");
List<string> args = new List<string>(); List<string> args = [groupuuid.ToString(), cleaned];
args.Add(groupuuid.ToString());
args.Add(cleaned);
RunCommandFromMessage(new SignedCommand(master.CommandsService, RunCommandFromMessage(new SignedCommand(master.CommandsService,
"discordapi", "GroupEject", null, args.ToArray(), 0, "none", false, 0, "", false), message); "discordapi", "GroupEject", null, [.. args], 0, "none", false, 0, "", false), message);
return; return;
} }
else if(cleaned.StartsWith("!invite") == true) else if(cleaned.StartsWith("!invite") == true)
{ {
// hangle group invite // hangle group invite
cleaned = cleaned.Replace("!invite ", ""); cleaned = cleaned.Replace("!invite ", "");
List<string> args = new List<string>(); List<string> args = [groupuuid.ToString(), cleaned, "everyone"];
args.Add(groupuuid.ToString());
args.Add(cleaned);
args.Add("everyone");
RunCommandFromMessage(new SignedCommand(master.CommandsService, RunCommandFromMessage(new SignedCommand(master.CommandsService,
"discordapi", "GroupInvite", null, args.ToArray(), 0, "none", false, 0, "", false), message); "discordapi", "GroupInvite", null, [.. args], 0, "none", false, 0, "", false), message);
return; return;
} }
else if(cleaned.StartsWith("!ban") == true) else if(cleaned.StartsWith("!ban") == true)
{ {
// hangle group ban // hangle group ban
cleaned = cleaned.Replace("!ban ", ""); cleaned = cleaned.Replace("!ban ", "");
List<string> args = new List<string>(); List<string> args = [groupuuid.ToString(), cleaned, "true"];
args.Add(groupuuid.ToString());
args.Add(cleaned);
args.Add("true");
RunCommandFromMessage(new SignedCommand(master.CommandsService, RunCommandFromMessage(new SignedCommand(master.CommandsService,
"discordapi", "GroupBan", null, args.ToArray(), 0, "none", false, 0, "", false), message); "discordapi", "GroupBan", null, [.. args], 0, "none", false, 0, "", false), message);
return; return;
} }
if (myConfig.GethideChatterName() == false) if (myConfig.GethideChatterName() == false)
@ -713,20 +704,20 @@ namespace SecondBotEvents.Services
return "group=" + groupuuid.ToString() + "||| !clear !notice {Title}@@@{Message}[@@@{Inventory UUID}] !eject {Avatar} !invite {Avatar} !ban {Avatar}"; return "group=" + groupuuid.ToString() + "||| !clear !notice {Title}@@@{Message}[@@@{Inventory UUID}] !eject {Avatar} !invite {Avatar} !ban {Avatar}";
} }
protected Dictionary<string, ulong> ChannelMap = new Dictionary<string, ulong>(); protected Dictionary<string, ulong> ChannelMap = [];
protected Dictionary<string, ulong> CategoryMap = new Dictionary<string, ulong>(); protected Dictionary<string, ulong> CategoryMap = [];
protected async void DoServerChannelSetup() protected async void DoServerChannelSetup()
{ {
LogFormater.Info("Setting up channels"); LogFormater.Info("Setting up channels");
LoginEvents(); LoginEvents();
Dictionary<string, string> WantedTextChannels = new Dictionary<string, string> Dictionary<string, string> WantedTextChannels = new()
{ {
{ "status", StatusPrefill() }, { "status", StatusPrefill() },
{ "commands", "Send a command to the bot as if you are a master" }, { "commands", "Send a command to the bot as if you are a master" },
{ "localchat", LocalChatPrefill() } { "localchat", LocalChatPrefill() }
}; };
ChannelMap = new Dictionary<string, ulong>(); ChannelMap = [];
SocketGuild server = DiscordClient.GetGuild(myConfig.GetServerID()); SocketGuild server = DiscordClient.GetGuild(myConfig.GetServerID());
foreach (ITextChannel channel in server.TextChannels) foreach (ITextChannel channel in server.TextChannels)
@ -750,12 +741,12 @@ namespace SecondBotEvents.Services
} }
List<string> WantedCategoryChannels = new List<string> List<string> WantedCategoryChannels =
{ [
"bot", "bot",
"im", "im",
"group" "group"
}; ];
foreach (ICategoryChannel category in server.CategoryChannels) foreach (ICategoryChannel category in server.CategoryChannels)
{ {
if (WantedCategoryChannels.Contains(category.Name) == false) if (WantedCategoryChannels.Contains(category.Name) == false)
@ -834,7 +825,7 @@ namespace SecondBotEvents.Services
SendMessageToChannel("localchat", LocalChatPrefill(), ":white_small_square: "+ objectName + ": " + message, "bot"); SendMessageToChannel("localchat", LocalChatPrefill(), ":white_small_square: "+ objectName + ": " + message, "bot");
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = ["secondlife", "second life"];
protected void LocalChat(object o, ChatEventArgs e) protected void LocalChat(object o, ChatEventArgs e)
{ {
switch (e.Type) switch (e.Type)
@ -1093,10 +1084,10 @@ namespace SecondBotEvents.Services
{ {
if (ulong.TryParse(givenserverid, out ulong serverid) == true) if (ulong.TryParse(givenserverid, out ulong serverid) == true)
{ {
return new KeyValuePair<bool, Dictionary<string, string>>(false, new Dictionary<string, string>()); return new KeyValuePair<bool, Dictionary<string, string>>(false, []);
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
Dictionary<string, string> textChannels = new Dictionary<string, string>(); Dictionary<string, string> textChannels = [];
foreach (SocketTextChannel channel in server.TextChannels) foreach (SocketTextChannel channel in server.TextChannels)
{ {
textChannels.Add(channel.Id.ToString(), channel.Name); textChannels.Add(channel.Id.ToString(), channel.Name);
@ -1124,10 +1115,10 @@ namespace SecondBotEvents.Services
{ {
if (ulong.TryParse(givenserverid, out ulong serverid) == false) if (ulong.TryParse(givenserverid, out ulong serverid) == false)
{ {
return new KeyValuePair<bool, Dictionary<string, string>>(false, new Dictionary<string, string>()); return new KeyValuePair<bool, Dictionary<string, string>>(false, []);
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
Dictionary<string, string> rolesList = new Dictionary<string, string>(); Dictionary<string, string> rolesList = [];
foreach (SocketRole role in server.Roles) foreach (SocketRole role in server.Roles)
{ {
rolesList.Add(role.Id.ToString(), role.Name); rolesList.Add(role.Id.ToString(), role.Name);
@ -1282,17 +1273,17 @@ namespace SecondBotEvents.Services
{ {
if (ulong.TryParse(givenserverid, out ulong serverid) == false) if (ulong.TryParse(givenserverid, out ulong serverid) == false)
{ {
return new KeyValuePair<bool, Dictionary<string, string>>(false, new Dictionary<string, string>()); return new KeyValuePair<bool, Dictionary<string, string>>(false, []);
} }
if (ulong.TryParse(givenroleid, out ulong roleid) == false) if (ulong.TryParse(givenroleid, out ulong roleid) == false)
{ {
return new KeyValuePair<bool, Dictionary<string, string>>(false, new Dictionary<string, string>()); return new KeyValuePair<bool, Dictionary<string, string>>(false, []);
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
SocketRole role = server.GetRole(roleid); SocketRole role = server.GetRole(roleid);
Dictionary<string, string> settings = new Dictionary<string, string> Dictionary<string, string> settings = new()
{ {
{ "Config|Color", String.Join(",", new byte[3] { role.Color.R, role.Color.G, role.Color.B }) }, { "Config|Color", String.Join(",", [role.Color.R, role.Color.G, role.Color.B]) },
{ "Config|Name", role.Name }, { "Config|Name", role.Name },
{ "Info|AssignedCount", role.Members.ToString() }, { "Info|AssignedCount", role.Members.ToString() },
{ "Perm|AttachFiles", role.Permissions.AttachFiles.ToString() }, { "Perm|AttachFiles", role.Permissions.AttachFiles.ToString() },
@ -1388,11 +1379,11 @@ namespace SecondBotEvents.Services
{ {
if (ulong.TryParse(givenserverid, out ulong serverid) == false) if (ulong.TryParse(givenserverid, out ulong serverid) == false)
{ {
return new KeyValuePair<bool, Dictionary<string, string>>(false, new Dictionary<string, string>()); return new KeyValuePair<bool, Dictionary<string, string>>(false, []);
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
IEnumerable<IGuildUser> users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true); IEnumerable<IGuildUser> users = await server.GetUsersAsync().FlattenAsync().ConfigureAwait(true);
Dictionary<string, string> membersList = new Dictionary<string, string>(); Dictionary<string, string> membersList = [];
foreach (IGuildUser user in users) foreach (IGuildUser user in users)
{ {
@ -1454,13 +1445,13 @@ namespace SecondBotEvents.Services
} }
SocketGuild server = DiscordClient.GetGuild(serverid); SocketGuild server = DiscordClient.GetGuild(serverid);
SocketGuildUser user = server.GetUser(memberid); SocketGuildUser user = server.GetUser(memberid);
TimeSpan somedays = new TimeSpan(13, 22, 59, 59, 0); TimeSpan somedays = new(13, 22, 59, 59, 0);
DateTimeOffset justundertwosweeks = DateTimeOffset.Now; DateTimeOffset justundertwosweeks = DateTimeOffset.Now;
justundertwosweeks = justundertwosweeks.Subtract(somedays); justundertwosweeks = justundertwosweeks.Subtract(somedays);
long unixtimelimit = justundertwosweeks.ToUnixTimeSeconds(); long unixtimelimit = justundertwosweeks.ToUnixTimeSeconds();
foreach (SocketTextChannel channel in server.TextChannels) foreach (SocketTextChannel channel in server.TextChannels)
{ {
List<IMessage> DeleteMessages = new List<IMessage>(); List<IMessage> DeleteMessages = [];
IEnumerable<IMessage> messages = await channel.GetMessagesAsync(100).FlattenAsync(); IEnumerable<IMessage> messages = await channel.GetMessagesAsync(100).FlattenAsync();
foreach (IMessage message in messages) foreach (IMessage message in messages)
{ {

View file

@ -17,9 +17,9 @@ namespace SecondBotEvents.Services
protected bool botConnected = false; protected bool botConnected = false;
protected string lastSimName = ""; protected string lastSimName = "";
protected UUID TrackGroupUUID = UUID.Zero; protected UUID TrackGroupUUID = UUID.Zero;
protected List<UUID> GroupMembers = new List<UUID>(); protected List<UUID> GroupMembers = [];
protected bool GroupLoaded = false; protected bool GroupLoaded = false;
protected List<UUID> AvatarsOnSim = new List<UUID>(); protected List<UUID> AvatarsOnSim = [];
protected bool GuestListLoaded = false; protected bool GuestListLoaded = false;
protected string lastparcelname = ""; protected string lastparcelname = "";
protected UUID OutputAvatar = UUID.Zero; protected UUID OutputAvatar = UUID.Zero;
@ -67,12 +67,12 @@ namespace SecondBotEvents.Services
} }
} }
Dictionary<string, List<string>> InventoryEvents = new Dictionary<string, List<string>>(); Dictionary<string, List<string>> InventoryEvents = [];
public void AddInventoryEvent(string inventoryType, string outputTarget) public void AddInventoryEvent(string inventoryType, string outputTarget)
{ {
if(InventoryEvents.ContainsKey(inventoryType) == false) if(InventoryEvents.ContainsKey(inventoryType) == false)
{ {
InventoryEvents.Add(inventoryType, new List<string>()); InventoryEvents.Add(inventoryType, []);
} }
if (InventoryEvents[inventoryType].Contains(outputTarget) == false) if (InventoryEvents[inventoryType].Contains(outputTarget) == false)
{ {
@ -154,7 +154,7 @@ namespace SecondBotEvents.Services
{ {
if ((myConfig.GetGuestTrackingSimname() != GetClient().Network.CurrentSim.Name) || (myConfig.GetGuestTrackingParcelname() != lastparcelname)) if ((myConfig.GetGuestTrackingSimname() != GetClient().Network.CurrentSim.Name) || (myConfig.GetGuestTrackingParcelname() != lastparcelname))
{ {
AvatarsOnSim = new List<UUID>(); AvatarsOnSim = [];
GuestListLoaded = false; GuestListLoaded = false;
return; return;
} }
@ -167,7 +167,7 @@ namespace SecondBotEvents.Services
lastAvUpdate = SecondbotHelpers.UnixTimeNow(); lastAvUpdate = SecondbotHelpers.UnixTimeNow();
string hashstring = ""; string hashstring = "";
List<UUID> avs = new List<UUID>(); List<UUID> avs = [];
foreach(Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values) foreach(Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values)
{ {
avs.Add(A.ID); avs.Add(A.ID);
@ -182,12 +182,8 @@ namespace SecondBotEvents.Services
if (GuestListLoaded == true) if (GuestListLoaded == true)
{ {
List<UUID> joined = new List<UUID>(); List<UUID> joined = [];
List<UUID> tracked = new List<UUID>(); List<UUID> tracked = [.. AvatarsOnSim];
foreach (UUID a in AvatarsOnSim)
{
tracked.Add(a);
}
foreach (UUID a in avs) foreach (UUID a in avs)
{ {
if (tracked.Contains(a) == true) if (tracked.Contains(a) == true)
@ -256,7 +252,7 @@ namespace SecondBotEvents.Services
protected void PushEvent(string eventname, Dictionary<string,string> args) protected void PushEvent(string eventname, Dictionary<string,string> args)
{ {
OnEvent e = new OnEvent( OnEvent e = new(
GetClient().Self.AgentID.ToString(), GetClient().Self.AgentID.ToString(),
eventname, eventname,
args, args,
@ -295,9 +291,11 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("Message", e.Message); {
args.Add("NotificationId", e.NotificationId); { "Message", e.Message },
{ "NotificationId", e.NotificationId }
};
PushEvent("AlertMessage", args); PushEvent("AlertMessage", args);
} }
@ -307,9 +305,11 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("oldparcel", lastparcelname); {
args.Add("newparcel", newparcelname); { "oldparcel", lastparcelname },
{ "newparcel", newparcelname }
};
lastparcelname = newparcelname; lastparcelname = newparcelname;
PushEvent("ChangedParcel", args); PushEvent("ChangedParcel", args);
} }
@ -320,8 +320,10 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("Message", e.message); {
{ "Message", e.message }
};
PushEvent("StatusMessage", args); PushEvent("StatusMessage", args);
} }
@ -333,12 +335,8 @@ namespace SecondBotEvents.Services
} }
if(GroupLoaded == true) if(GroupLoaded == true)
{ {
List<UUID> joined = new List<UUID>(); List<UUID> joined = [];
List<UUID> tracked = new List<UUID>(); List<UUID> tracked = [.. GroupMembers];
foreach (UUID a in GroupMembers)
{
tracked.Add(a);
}
master.DataStoreService.GetAvatarNames(tracked); master.DataStoreService.GetAvatarNames(tracked);
foreach (UUID a in e.Members.Keys) foreach (UUID a in e.Members.Keys)
{ {
@ -365,29 +363,29 @@ namespace SecondBotEvents.Services
} }
} }
GroupMembers = new List<UUID>(); GroupMembers = [.. e.Members.Keys];
foreach (UUID a in e.Members.Keys)
{
GroupMembers.Add(a);
}
GroupLoaded = true; GroupLoaded = true;
} }
protected void GroupMembershipEvent(UUID avatar, string action) protected void GroupMembershipEvent(UUID avatar, string action)
{ {
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("uuid", avatar.ToString()); {
args.Add("name", master.DataStoreService.GetAvatarName(avatar)); { "uuid", avatar.ToString() },
args.Add("action", action); { "name", master.DataStoreService.GetAvatarName(avatar) },
{ "action", action }
};
PushEvent("GroupMembership", args); PushEvent("GroupMembership", args);
} }
protected void GuestTrackingEvent(UUID avatar, string action) protected void GuestTrackingEvent(UUID avatar, string action)
{ {
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("uuid", avatar.ToString()); {
args.Add("name", master.DataStoreService.GetAvatarName(avatar)); { "uuid", avatar.ToString() },
args.Add("action", action); { "name", master.DataStoreService.GetAvatarName(avatar) },
{ "action", action }
};
PushEvent("GuestTracking", args); PushEvent("GuestTracking", args);
} }
@ -397,9 +395,11 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("lastsim", lastSimName); {
args.Add("newsim", GetClient().Network.CurrentSim.Name); { "lastsim", lastSimName },
{ "newsim", GetClient().Network.CurrentSim.Name }
};
PushEvent("ChangedSim", args); PushEvent("ChangedSim", args);
lastSimName = e.PreviousSimulator.Name; lastSimName = e.PreviousSimulator.Name;
} }
@ -410,14 +410,16 @@ namespace SecondBotEvents.Services
{ {
return; return;
} }
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new()
args.Add("fromuuid", e.TransactionInfo.SourceID.ToString()); {
args.Add("touuid", e.TransactionInfo.DestID.ToString()); { "fromuuid", e.TransactionInfo.SourceID.ToString() },
args.Add("amount", e.TransactionInfo.Amount.ToString()); { "touuid", e.TransactionInfo.DestID.ToString() },
args.Add("balance", e.Balance.ToString()); { "amount", e.TransactionInfo.Amount.ToString() },
args.Add("fromname", master.DataStoreService.GetAvatarName(e.TransactionInfo.SourceID)); { "balance", e.Balance.ToString() },
args.Add("toname", master.DataStoreService.GetAvatarName(e.TransactionInfo.DestID)); { "fromname", master.DataStoreService.GetAvatarName(e.TransactionInfo.SourceID) },
args.Add("transactionid", e.TransactionID.ToString()); { "toname", master.DataStoreService.GetAvatarName(e.TransactionInfo.DestID) },
{ "transactionid", e.TransactionID.ToString() }
};
PushEvent("MoneyEvent", args); PushEvent("MoneyEvent", args);
} }
@ -456,7 +458,7 @@ namespace SecondBotEvents.Services
public class OnEvent public class OnEvent
{ {
public string EventName = ""; public string EventName = "";
public Dictionary<string, string> Data = new Dictionary<string, string>(); public Dictionary<string, string> Data = [];
public string Hash = ""; public string Hash = "";
public long Unixtime = 0; public long Unixtime = 0;
public string BotUUID = ""; public string BotUUID = "";

View file

@ -77,7 +77,7 @@ namespace SecondBotEvents.Services
{ {
if (evacWanted == true) if (evacWanted == true)
{ {
BotAlertMessage(null, new AlertMessageEventArgs("restart", "999", new OpenMetaverse.StructuredData.OSDMap())); BotAlertMessage(null, new AlertMessageEventArgs("restart", "999", []));
} }
if (GetClient().Network.CurrentSim.Name == home.name) if (GetClient().Network.CurrentSim.Name == home.name)
{ {

View file

@ -145,14 +145,9 @@ namespace SecondBotEvents.Services
} }
} }
public abstract class CommandsAPI public abstract class CommandsAPI(EventsSecondBot setmaster)
{ {
protected EventsSecondBot master; protected EventsSecondBot master = setmaster;
public CommandsAPI(EventsSecondBot setmaster)
{
master = setmaster;
}
protected UUID avataruuid = UUID.Zero; protected UUID avataruuid = UUID.Zero;
protected Parcel targetparcel = null; protected Parcel targetparcel = null;
@ -241,72 +236,44 @@ namespace SecondBotEvents.Services
} }
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class ClassInfo : Attribute public class ClassInfo(string classinfo) : Attribute
{ {
public string classinfo = ""; public string classinfo = classinfo;
public ClassInfo(string classinfo)
{
this.classinfo = classinfo;
}
} }
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class About : Attribute public class About(string about) : Attribute
{ {
public string about = ""; public string about = about;
public About(string about)
{
this.about = about;
}
} }
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ReturnHints : Attribute public class ReturnHints(string hint) : Attribute
{ {
public string hint = ""; public string hint = hint;
public ReturnHints(string hint)
{
this.hint = hint;
}
} }
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ReturnHintsFailure : Attribute public class ReturnHintsFailure(string hint) : Attribute
{ {
public string hint = ""; public string hint = hint;
public ReturnHintsFailure(string hint)
{
this.hint = hint;
}
} }
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ArgHints : Attribute public class ArgHints(string name, string about) : Attribute
{ {
public string name = ""; public string name = name;
public string about = ""; public string about = about;
public ArgHints(string name, string about)
{
this.name = name;
this.about = about;
}
} }
public class SecondbotWebApi : WebApiController public class SecondbotWebApi(EventsSecondBot setmaster) : WebApiController
{ {
protected EventsSecondBot master; protected EventsSecondBot master = setmaster;
public SecondbotWebApi(EventsSecondBot setmaster)
{
master = setmaster;
}
} }
public class HttpWebBot : SecondbotWebApi public class HttpWebBot(EventsSecondBot setmaster) : SecondbotWebApi(setmaster)
{ {
public HttpWebBot(EventsSecondBot setmaster) : base(setmaster) { }
[About("Runs a command on the bot")] [About("Runs a command on the bot")]
[ReturnHints("command reply")] [ReturnHints("command reply")]
[ReturnHintsFailure("Bad token signing")] [ReturnHintsFailure("Bad token signing")]

View file

@ -48,7 +48,7 @@ namespace SecondBotEvents.Services
{ {
if (misc == null) if (misc == null)
{ {
misc = new Dictionary<string, string>(); misc = [];
} }
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
@ -160,8 +160,10 @@ namespace SecondBotEvents.Services
protected void JsonOuputCleaner(string misc, string source) protected void JsonOuputCleaner(string misc, string source)
{ {
Dictionary<string, string> reply = new Dictionary<string, string>(); Dictionary<string, string> reply = new()
reply.Add("value", misc); {
{ "value", misc }
};
JsonOuputCleaner(reply, source); JsonOuputCleaner(reply, source);
} }
@ -198,8 +200,10 @@ namespace SecondBotEvents.Services
mode = "Teleport Av to Bot"; mode = "Teleport Av to Bot";
markTeleport = false; markTeleport = false;
} }
Dictionary<string,string> misc = new Dictionary<string, string>(); Dictionary<string,string> misc = new()
misc.Add("mode", mode); {
{ "mode", mode }
};
if (ProcessRequest(myConfig.GetAcceptTeleports(),myConfig.GetTeleportRequestLevel(), e.IM.FromAgentName, "Teleport", e.IM.FromAgentID, misc) == false) if (ProcessRequest(myConfig.GetAcceptTeleports(),myConfig.GetTeleportRequestLevel(), e.IM.FromAgentName, "Teleport", e.IM.FromAgentID, misc) == false)
{ {
// rejected requests // rejected requests
@ -226,9 +230,11 @@ namespace SecondBotEvents.Services
protected void BotGroupInviteOffer(object o, GroupInvitationEventArgs e) protected void BotGroupInviteOffer(object o, GroupInvitationEventArgs e)
{ {
Dictionary<string, string> reply = new Dictionary<string, string>(); Dictionary<string, string> reply = new()
reply.Add("message", e.Message); {
reply.Add("fromuuid", e.AgentID.ToString()); { "message", e.Message },
{ "fromuuid", e.AgentID.ToString() }
};
if (ProcessRequest(myConfig.GetAcceptGroupInvites(),myConfig.GetGroupInviteLevel(), e.FromName, "GroupInvite", e.AgentID, reply) == false) if (ProcessRequest(myConfig.GetAcceptGroupInvites(),myConfig.GetGroupInviteLevel(), e.FromName, "GroupInvite", e.AgentID, reply) == false)
{ {
return; return;
@ -240,7 +246,7 @@ namespace SecondBotEvents.Services
protected void BotInventoryAdd(object o, InventoryObjectAddedEventArgs e) protected void BotInventoryAdd(object o, InventoryObjectAddedEventArgs e)
{ {
InventoryItem F = (InventoryItem)e.Obj; InventoryItem F = (InventoryItem)e.Obj;
Dictionary<string, string> details = new Dictionary<string, string> Dictionary<string, string> details = new()
{ {
{ "itemname", e.Obj.Name }, { "itemname", e.Obj.Name },
{ "itemuuid", e.Obj.UUID.ToString() }, { "itemuuid", e.Obj.UUID.ToString() },
@ -255,7 +261,7 @@ namespace SecondBotEvents.Services
protected void BotInventoryOffer(object o, InventoryObjectOfferedEventArgs e) protected void BotInventoryOffer(object o, InventoryObjectOfferedEventArgs e)
{ {
Dictionary<string, string> details = new Dictionary<string, string> Dictionary<string, string> details = new()
{ {
{ "transactionid", e.Offer.IMSessionID.ToString() }, { "transactionid", e.Offer.IMSessionID.ToString() },
{ "itemtype", e.AssetType.ToString() }, { "itemtype", e.AssetType.ToString() },
@ -285,8 +291,10 @@ namespace SecondBotEvents.Services
protected void BotFriendRequested(object o, FriendshipOfferedEventArgs e) protected void BotFriendRequested(object o, FriendshipOfferedEventArgs e)
{ {
Dictionary<string, string> misc = new Dictionary<string, string>(); Dictionary<string, string> misc = new()
misc.Add("fromName", e.AgentName); {
{ "fromName", e.AgentName }
};
if (ProcessRequest(myConfig.GetAcceptFriendRequests(),myConfig.GetFriendRequestLevel(), e.AgentName, "FriendRequest", e.AgentID, misc) == false) if (ProcessRequest(myConfig.GetAcceptFriendRequests(),myConfig.GetFriendRequestLevel(), e.AgentName, "FriendRequest", e.AgentID, misc) == false)
{ {
return; return;
@ -370,7 +378,7 @@ namespace SecondBotEvents.Services
public string eventType = "?"; public string eventType = "?";
public bool accepted = false; public bool accepted = false;
public string info = ""; public string info = "";
public Dictionary<string, string> misc = new Dictionary<string, string>(); public Dictionary<string, string> misc = [];
public InteractionEvent(string setFrom, string setType, bool setAccepted, string setInfo, Dictionary<string, string> setMisc = null) public InteractionEvent(string setFrom, string setType, bool setAccepted, string setInfo, Dictionary<string, string> setMisc = null)
{ {
accepted = setAccepted; accepted = setAccepted;

View file

@ -17,7 +17,7 @@ namespace SecondBotEvents.Services
{ {
public class RLVService : BotServices public class RLVService : BotServices
{ {
protected RlvConfig myConfig; protected new RlvConfig myConfig;
protected bool botConnected = false; protected bool botConnected = false;
protected CurrentOutfitFolder CurrentOutfitFolder = null; protected CurrentOutfitFolder CurrentOutfitFolder = null;
@ -77,11 +77,11 @@ namespace SecondBotEvents.Services
CurrentOutfitFolder = master.CurrentOutfitFolder; CurrentOutfitFolder = master.CurrentOutfitFolder;
botConnected = true; botConnected = true;
// attach events // attach events
RLVWearables = new List<RLVWearable>(); RLVWearables = [];
RLVAttachments = new List<RLVAttachment> RLVAttachments =
{ [
new RLVAttachment() {Name = "none", Point = AttachmentPoint.Default} new RLVAttachment() {Name = "none", Point = AttachmentPoint.Default}
}; ];
foreach (WearableType wear in Enum.GetValues(typeof(WearableType))) foreach (WearableType wear in Enum.GetValues(typeof(WearableType)))
{ {
if (wear.Equals(WearableType.Invalid)) continue; if (wear.Equals(WearableType.Invalid)) continue;
@ -178,7 +178,7 @@ namespace SecondBotEvents.Services
} }
/// <summary>Thread sync lock object</summary> /// <summary>Thread sync lock object</summary>
private readonly object m_RLVRuleChangedLock = new object(); private readonly object m_RLVRuleChangedLock = new();
/// <summary>Triggered when an RLVRuleChangedUpdate packet is received, /// <summary>Triggered when an RLVRuleChangedUpdate packet is received,
/// telling us what our avatar is currently wearing /// telling us what our avatar is currently wearing
@ -239,8 +239,8 @@ namespace SecondBotEvents.Services
GridClient client => instance.BotClient.GetClient(); GridClient client => instance.BotClient.GetClient();
EventsSecondBot instance = null; EventsSecondBot instance = null;
readonly Regex rlv_regex = new Regex(@"(?<behaviour>[^:=]+)(:(?<option>[^=]*))?=(?<param>\w+)", RegexOptions.Compiled); readonly Regex rlv_regex = new(@"(?<behaviour>[^:=]+)(:(?<option>[^=]*))?=(?<param>\w+)", RegexOptions.Compiled);
readonly List<RLVRule> rules = new List<RLVRule>(); readonly List<RLVRule> rules = [];
System.Timers.Timer CleanupTimer; System.Timers.Timer CleanupTimer;
void StartTimer() void StartTimer()
@ -459,13 +459,11 @@ namespace SecondBotEvents.Services
case "getsitid": case "getsitid":
if (int.TryParse(rule.Param, out chan) && chan > 0) if (int.TryParse(rule.Param, out chan) && chan > 0)
{ {
Avatar me; if (client.Network.CurrentSim.ObjectsAvatars.TryGetValue(client.Self.LocalID, out Avatar me))
if (client.Network.CurrentSim.ObjectsAvatars.TryGetValue(client.Self.LocalID, out me))
{ {
if (me.ParentID != 0) if (me.ParentID != 0)
{ {
Primitive seat; if (client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(me.ParentID, out Primitive seat))
if (client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(me.ParentID, out seat))
{ {
Respond(chan, seat.ID.ToString()); Respond(chan, seat.ID.ToString());
break; break;
@ -522,8 +520,8 @@ namespace SecondBotEvents.Services
{ {
UUID.TryParse(rule.Option, out sitTarget); UUID.TryParse(rule.Option, out sitTarget);
} }
string[] args = { sitTarget.ToString() }; string[] args = [sitTarget.ToString()];
SignedCommand C = new SignedCommand(master.CommandsService, "rlv", "Sit", null, args, 0, "", false, 0, "", false); SignedCommand C = new(master.CommandsService, "rlv", "Sit", null, args, 0, "", false, 0, "", false);
master.CommandsService.RunCommand("RLV",C); master.CommandsService.RunCommand("RLV",C);
} }
break; break;
@ -532,7 +530,7 @@ namespace SecondBotEvents.Services
if (rule.Param == "force") if (rule.Param == "force")
{ {
// stand // stand
SignedCommand C = new SignedCommand(master.CommandsService, "rlv", "Stand", null, new string[] { }, 0, "", false, 0, "", false); SignedCommand C = new(master.CommandsService, "rlv", "Stand", null, [], 0, "", false, 0, "", false);
master.CommandsService.RunCommand("RLV", C); master.CommandsService.RunCommand("RLV", C);
} }
break; break;
@ -558,8 +556,7 @@ namespace SecondBotEvents.Services
float gx = float.Parse(coord[0], Utils.EnUsCulture); float gx = float.Parse(coord[0], Utils.EnUsCulture);
float gy = float.Parse(coord[1], Utils.EnUsCulture); float gy = float.Parse(coord[1], Utils.EnUsCulture);
float z = float.Parse(coord[2], Utils.EnUsCulture); float z = float.Parse(coord[2], Utils.EnUsCulture);
float x = 0, y = 0; ulong h = Helpers.GlobalPosToRegionHandle(gx, gy, out float x, out float y);
ulong h = Helpers.GlobalPosToRegionHandle(gx, gy, out x, out y);
client.Self.RequestTeleport(h, new Vector3(x, y, z)); client.Self.RequestTeleport(h, new Vector3(x, y, z));
} }
else if ( else if (
@ -572,8 +569,7 @@ namespace SecondBotEvents.Services
float y = float.Parse(coord[2], Utils.EnUsCulture); float y = float.Parse(coord[2], Utils.EnUsCulture);
float z = float.Parse(coord[3], Utils.EnUsCulture); float z = float.Parse(coord[3], Utils.EnUsCulture);
GridRegion r; client.Grid.GetGridRegion(n, GridLayerType.Objects, out GridRegion r);
client.Grid.GetGridRegion(n, GridLayerType.Objects, out r);
client.Self.RequestTeleport(r.RegionHandle, new Vector3(x, y, z)); client.Self.RequestTeleport(r.RegionHandle, new Vector3(x, y, z));
} }
} }
@ -701,7 +697,7 @@ namespace SecondBotEvents.Services
InventoryNode folder = FindFolder(rule.Option); InventoryNode folder = FindFolder(rule.Option);
if (folder != null) if (folder != null)
{ {
List<InventoryItem> allItems = new List<InventoryItem>(); List<InventoryItem> allItems = [];
AllSubfolderWearables(folder, ref allItems); AllSubfolderWearables(folder, ref allItems);
List<InventoryItem> allSubfolderWorn = allItems.Where(n => CurrentOutfitFolder.CanBeWorn(n)).ToList(); List<InventoryItem> allSubfolderWorn = allItems.Where(n => CurrentOutfitFolder.CanBeWorn(n)).ToList();
master.CurrentOutfitFolder.RemoveFromOutfit(allSubfolderWorn); master.CurrentOutfitFolder.RemoveFromOutfit(allSubfolderWorn);
@ -719,7 +715,7 @@ namespace SecondBotEvents.Services
var folder = client.Inventory.Store.Items[CurrentOutfitFolder.GetAttachmentItem(attachment)].Parent; var folder = client.Inventory.Store.Items[CurrentOutfitFolder.GetAttachmentItem(attachment)].Parent;
if (folder != null) if (folder != null)
{ {
List<InventoryItem> outfit = new List<InventoryItem>(); List<InventoryItem> outfit = [];
GetAllItems(folder, true, ref outfit); GetAllItems(folder, true, ref outfit);
master.CurrentOutfitFolder.RemoveFromOutfit(outfit); master.CurrentOutfitFolder.RemoveFromOutfit(outfit);
} }
@ -755,7 +751,7 @@ namespace SecondBotEvents.Services
if (folder != null) if (folder != null)
{ {
UUID folderload = GetFolderFromPath(rule.Option); UUID folderload = GetFolderFromPath(rule.Option);
List<InventoryItem> outfit = new List<InventoryItem>(); List<InventoryItem> outfit = [];
if (rule.Behaviour == "attachall" || rule.Behaviour == "attachallover") if (rule.Behaviour == "attachall" || rule.Behaviour == "attachallover")
{ {
GetAllItems(folder, true, ref outfit); GetAllItems(folder, true, ref outfit);
@ -814,9 +810,9 @@ namespace SecondBotEvents.Services
case "findfolders": case "findfolders":
if (int.TryParse(rule.Param, out chan) && chan > 0) if (int.TryParse(rule.Param, out chan) && chan > 0)
{ {
StringBuilder response = new StringBuilder(); StringBuilder response = new();
string[] keywordsArray = rule.Option.Split(new string[] { "&&" }, StringSplitOptions.None); string[] keywordsArray = rule.Option.Split(["&&"], StringSplitOptions.None);
if (keywordsArray.Any()) if (keywordsArray.Any())
{ {
List<InventoryNode> matching_nodes = FindFoldersKeyword(keywordsArray); List<InventoryNode> matching_nodes = FindFoldersKeyword(keywordsArray);
@ -1031,7 +1027,7 @@ namespace SecondBotEvents.Services
var root = RLVRootFolder(); var root = RLVRootFolder();
if (root != null) if (root != null)
{ {
FindFoldersKeywordsInternal(root, keywords, new List<string>(), ref matchingNodes); FindFoldersKeywordsInternal(root, keywords, [], ref matchingNodes);
} }
return matchingNodes; return matchingNodes;
@ -1084,7 +1080,7 @@ namespace SecondBotEvents.Services
public List<string> GetOptions(string behaviour) public List<string> GetOptions(string behaviour)
{ {
List<string> ret = new List<string>(); List<string> ret = [];
foreach (var rule in rules.FindAll(r => r.Behaviour == behaviour && !string.IsNullOrEmpty(r.Option)) foreach (var rule in rules.FindAll(r => r.Behaviour == behaviour && !string.IsNullOrEmpty(r.Option))
.Where(rule => !ret.Contains(rule.Option))) .Where(rule => !ret.Contains(rule.Option)))

View file

@ -4,14 +4,10 @@ using System.Threading;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
public class RecoveryService : BotServices public class RecoveryService(EventsSecondBot setMaster) : BotServices(setMaster)
{ {
protected Timer AutoRestartLoginTimer; protected Timer AutoRestartLoginTimer;
protected new BasicConfig myConfig; protected new BasicConfig myConfig = new BasicConfig(false);
public RecoveryService(EventsSecondBot setMaster) : base(setMaster)
{
myConfig = new BasicConfig(false);
}
public override string Status() public override string Status()
{ {

View file

@ -74,7 +74,7 @@ namespace SecondBotEvents.Services
triggerRelayEvent("discord", e.Source.ToString(), e.Channel.ToString(), e.Author.Username, e.CleanContent); triggerRelayEvent("discord", e.Source.ToString(), e.Channel.ToString(), e.Author.Username, e.CleanContent);
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = ["secondlife", "second life"];
protected void LocalChat(object o, ChatEventArgs e) protected void LocalChat(object o, ChatEventArgs e)
{ {
@ -157,11 +157,13 @@ namespace SecondBotEvents.Services
return; return;
} }
message = "{Relay} " + message; message = "{Relay} " + message;
relayEvent a = new relayEvent(); relayEvent a = new()
a.message = message; {
a.name = name; message = message,
a.sourcetype = source; name = name,
a.sourceoption = filter; sourcetype = source,
sourceoption = filter
};
string eventMessage = JsonConvert.SerializeObject(a); string eventMessage = JsonConvert.SerializeObject(a);
while (loop <= myConfig.GetRelayCount()) while (loop <= myConfig.GetRelayCount())
{ {

View file

@ -6,15 +6,11 @@ using SecondBotEvents.Config;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
public abstract class BotServices public abstract class BotServices(EventsSecondBot setMaster)
{ {
public EventsSecondBot master; public EventsSecondBot master = setMaster;
protected Config.Config myConfig; protected Config.Config myConfig;
protected bool running = false; protected bool running = false;
public BotServices(EventsSecondBot setMaster)
{
master = setMaster;
}
public void enableAndStart() public void enableAndStart()
{ {

View file

@ -116,7 +116,7 @@ namespace SecondBotEvents.Services
} }
try try
{ {
MimeMessage message = new MimeMessage(); MimeMessage message = new();
message.From.Add(new MailboxAddress(myConfig.GetMailReplyAddress() + " via secondbot", myConfig.GetMailReplyAddress())); message.From.Add(new MailboxAddress(myConfig.GetMailReplyAddress() + " via secondbot", myConfig.GetMailReplyAddress()));
message.To.Add(new MailboxAddress(to, to)); message.To.Add(new MailboxAddress(to, to));
message.Subject = subject; message.Subject = subject;

View file

@ -16,14 +16,14 @@ namespace SecondBotEvents.Services
{ {
protected new OnEventConfig myConfig; protected new OnEventConfig myConfig;
protected bool botConnected = false; protected bool botConnected = false;
Dictionary<string,List<CustomOnEvent>> MyCustomEvents = new Dictionary<string, List<CustomOnEvent>>(); Dictionary<string,List<CustomOnEvent>> MyCustomEvents = [];
Dictionary<string, long> lockouts = new Dictionary<string, long>(); Dictionary<string, long> lockouts = [];
List<UUID> trackEventGroups = new List<UUID>(); List<UUID> trackEventGroups = [];
public TriggerOnEventService(EventsSecondBot setMaster) : base(setMaster) public TriggerOnEventService(EventsSecondBot setMaster) : base(setMaster)
{ {
myConfig = new OnEventConfig(master.fromEnv, master.fromFolder); myConfig = new OnEventConfig(master.fromEnv, master.fromFolder);
int loop = 1; int loop = 1;
string[] delimiterChars = new string[] { "{IS}", "{NOT}", "{IS_UUD}", "{MISSING}", "{CONTAINS}", "{IN_GROUP}", "{NOT_IN_GROUP}", "{LESSTHAN}", "{MORETHAN}", "{LOCKOUT}" }; string[] delimiterChars = ["{IS}", "{NOT}", "{IS_UUD}", "{MISSING}", "{CONTAINS}", "{IN_GROUP}", "{NOT_IN_GROUP}", "{LESSTHAN}", "{MORETHAN}", "{LOCKOUT}"];
if(myConfig.GetCount() == 0) if(myConfig.GetCount() == 0)
{ {
myConfig.setEnabled(false); myConfig.setEnabled(false);
@ -37,9 +37,11 @@ namespace SecondBotEvents.Services
loop++; loop++;
continue; continue;
} }
CustomOnEvent Event = new CustomOnEvent(); CustomOnEvent Event = new()
Event.Source = myConfig.GetSource(loop); {
Event.MonitorFlags = myConfig.GetSourceMonitor(loop).Split("=#=").ToList(); Source = myConfig.GetSource(loop),
MonitorFlags = [.. myConfig.GetSourceMonitor(loop).Split("=#=")]
};
bool eventWhereOk = true; bool eventWhereOk = true;
int loop2 = 1; int loop2 = 1;
while(loop2 <= myConfig.GetWhereCount(loop)) while(loop2 <= myConfig.GetWhereCount(loop))
@ -76,7 +78,7 @@ namespace SecondBotEvents.Services
continue; continue;
} }
Event.Source = myConfig.GetSource(loop); Event.Source = myConfig.GetSource(loop);
Event.MonitorFlags = myConfig.GetSourceMonitor(loop).Split("=#=").ToList(); Event.MonitorFlags = [.. myConfig.GetSourceMonitor(loop).Split("=#=")];
if ((Event.Source == "GroupMemberJoin") || (Event.Source == "GroupMemberLeave")) if ((Event.Source == "GroupMemberJoin") || (Event.Source == "GroupMemberLeave"))
{ {
UUID groupUUID = UUID.Zero; UUID groupUUID = UUID.Zero;
@ -137,7 +139,7 @@ namespace SecondBotEvents.Services
} }
if(MyCustomEvents.ContainsKey(Event.Source) == false) if(MyCustomEvents.ContainsKey(Event.Source) == false)
{ {
MyCustomEvents.Add(Event.Source, new List<CustomOnEvent>()); MyCustomEvents.Add(Event.Source, []);
} }
MyCustomEvents[Event.Source].Add(Event); MyCustomEvents[Event.Source].Add(Event);
LogFormater.Info("OnEvent Service - Event " + loop.ToString() + " is being tracked"); LogFormater.Info("OnEvent Service - Event " + loop.ToString() + " is being tracked");
@ -269,15 +271,15 @@ namespace SecondBotEvents.Services
continue; continue;
} }
GroupNames.Add(G.ID, G.Name); GroupNames.Add(G.ID, G.Name);
GroupMembership.Add(G.ID, new List<UUID>()); GroupMembership.Add(G.ID, []);
GroupMembershipUpdated.Add(G.ID, 0); GroupMembershipUpdated.Add(G.ID, 0);
} }
} }
} }
protected Dictionary<UUID, List<UUID>> GroupMembership = new Dictionary<UUID, List<UUID>>(); protected Dictionary<UUID, List<UUID>> GroupMembership = [];
protected Dictionary<UUID, string> GroupNames = new Dictionary<UUID, string>(); protected Dictionary<UUID, string> GroupNames = [];
protected Dictionary<UUID, long> GroupMembershipUpdated = new Dictionary<UUID, long>(); protected Dictionary<UUID, long> GroupMembershipUpdated = [];
protected long lastGroupMembershipUpdate = 0; protected long lastGroupMembershipUpdate = 0;
// request group membership updates max of once per 60 secs // request group membership updates max of once per 60 secs
// request membership update for group once every 15 mins // request membership update for group once every 15 mins
@ -333,12 +335,8 @@ namespace SecondBotEvents.Services
} }
return; return;
} }
List<UUID> joined = new List<UUID>(); List<UUID> joined = [];
List<UUID> tracked = new List<UUID>(); List<UUID> tracked = [.. GroupMembership[e.GroupID]];
foreach (UUID a in GroupMembership[e.GroupID])
{
tracked.Add(a);
}
master.DataStoreService.GetAvatarNames(tracked); master.DataStoreService.GetAvatarNames(tracked);
foreach (UUID a in e.Members.Keys) foreach (UUID a in e.Members.Keys)
{ {
@ -438,7 +436,7 @@ namespace SecondBotEvents.Services
long now = SecondbotHelpers.UnixTimeNow(); long now = SecondbotHelpers.UnixTimeNow();
lock (lockouts) lock (lockouts)
{ {
List<string> toberemoved = new List<string>(); List<string> toberemoved = [];
foreach(KeyValuePair<string, long> pair in lockouts) foreach(KeyValuePair<string, long> pair in lockouts)
{ {
if(pair.Value > now) if(pair.Value > now)
@ -478,7 +476,7 @@ namespace SecondBotEvents.Services
} }
if (myConfig.GetDebugMe() == true) if (myConfig.GetDebugMe() == true)
{ {
StringBuilder debugoutme = new StringBuilder(); StringBuilder debugoutme = new();
string debugoutmeaddon = ""; string debugoutmeaddon = "";
foreach(KeyValuePair<string,string> Ar in args) foreach(KeyValuePair<string,string> Ar in args)
{ {
@ -502,8 +500,8 @@ namespace SecondBotEvents.Services
List<int> AvPos = GetAvPos(avataruuid); List<int> AvPos = GetAvPos(avataruuid);
Vector3 A = GetClient().Self.SimPosition; Vector3 A = GetClient().Self.SimPosition;
List<int> BotPos = new List<int>() { (int)Math.Round(A.X), (int)Math.Round(A.Y), (int)Math.Round(A.Z) }; List<int> BotPos = [(int)Math.Round(A.X), (int)Math.Round(A.Y), (int)Math.Round(A.Z)];
Dictionary<string, string> values = new Dictionary<string, string> Dictionary<string, string> values = new()
{ {
{ "alertmessage", inArgsOrDefault("alertmessage", args, "none") }, { "alertmessage", inArgsOrDefault("alertmessage", args, "none") },
{ "message", inArgsOrDefault("message", args, "none") }, { "message", inArgsOrDefault("message", args, "none") },
@ -672,7 +670,7 @@ namespace SecondBotEvents.Services
{ {
if (UUID.TryParse(avataruuid, out UUID avUUID) == false) if (UUID.TryParse(avataruuid, out UUID avUUID) == false)
{ {
return new List<int>() { -1, -1, -1, -1 }; return [-1, -1, -1, -1];
} }
foreach (Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values) foreach (Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values)
{ {
@ -682,9 +680,9 @@ namespace SecondBotEvents.Services
} }
Vector3 avpos = A.Position; Vector3 avpos = A.Position;
int dist = (int)Math.Round(Vector3.Distance(avpos, GetClient().Self.SimPosition)); int dist = (int)Math.Round(Vector3.Distance(avpos, GetClient().Self.SimPosition));
return new List<int>() { (int)Math.Round(A.Position.X), (int)Math.Round(A.Position.Y), (int)Math.Round(A.Position.Z), dist }; return [(int)Math.Round(A.Position.X), (int)Math.Round(A.Position.Y), (int)Math.Round(A.Position.Z), dist];
} }
return new List<int>() { -1, -1, -1, -1 }; return [-1, -1, -1, -1];
} }
protected string GetAvParcel(string avataruuid) protected string GetAvParcel(string avataruuid)
@ -721,7 +719,7 @@ namespace SecondBotEvents.Services
string avatarhash = ""; string avatarhash = "";
bool GuestListLoaded = false; bool GuestListLoaded = false;
protected List<UUID> AvatarsOnSim = new List<UUID>(); protected List<UUID> AvatarsOnSim = [];
protected void TrackAvatarsOnParcel() protected void TrackAvatarsOnParcel()
{ {
long dif = SecondbotHelpers.UnixTimeNow() - lastAvUpdate; long dif = SecondbotHelpers.UnixTimeNow() - lastAvUpdate;
@ -732,7 +730,7 @@ namespace SecondBotEvents.Services
} }
lastAvUpdate = SecondbotHelpers.UnixTimeNow(); lastAvUpdate = SecondbotHelpers.UnixTimeNow();
string hashstring = ""; string hashstring = "";
List<UUID> avs = new List<UUID>(); List<UUID> avs = [];
foreach (Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values) foreach (Avatar A in GetClient().Network.CurrentSim.ObjectsAvatars.Copy().Values)
{ {
avs.Add(A.ID); avs.Add(A.ID);
@ -749,12 +747,8 @@ namespace SecondBotEvents.Services
if (GuestListLoaded == true) if (GuestListLoaded == true)
{ {
List<UUID> joined = new List<UUID>(); List<UUID> joined = [];
List<UUID> tracked = new List<UUID>(); List<UUID> tracked = [.. AvatarsOnSim];
foreach (UUID a in AvatarsOnSim)
{
tracked.Add(a);
}
foreach (UUID a in avs) foreach (UUID a in avs)
{ {
if (tracked.Contains(a) == true) if (tracked.Contains(a) == true)
@ -766,7 +760,7 @@ namespace SecondBotEvents.Services
} }
if ((tracked.Count > 0) || (joined.Count > 0)) if ((tracked.Count > 0) || (joined.Count > 0))
{ {
List<UUID> seen = new List<UUID>(); List<UUID> seen = [];
if (tracked.Count > 0) if (tracked.Count > 0)
{ {
@ -807,7 +801,7 @@ namespace SecondBotEvents.Services
return; return;
} }
lastClockEvent = SecondbotHelpers.UnixTimeNow(); lastClockEvent = SecondbotHelpers.UnixTimeNow();
TriggerEvent("Clock", new Dictionary<string, string>()); TriggerEvent("Clock", []);
} }
long lastAvUpdate = 0; long lastAvUpdate = 0;
@ -909,10 +903,10 @@ namespace SecondBotEvents.Services
public class CustomOnEvent public class CustomOnEvent
{ {
public string Source = ""; public string Source = "";
public List<string> MonitorFlags = new List<string>(); public List<string> MonitorFlags = [];
public List<string> WhereChecksLeft = new List<string>(); public List<string> WhereChecksLeft = [];
public List<string> WhereChecksCenter = new List<string>(); public List<string> WhereChecksCenter = [];
public List<string> WhereChecksRight = new List<string>(); public List<string> WhereChecksRight = [];
public List<string> Actions = new List<string>(); public List<string> Actions = [];
} }
} }

View file

@ -32,7 +32,7 @@ namespace SecondBotEvents
string[] files = targetenv.GetManifestResourceNames(); string[] files = targetenv.GetManifestResourceNames();
string resourceName = files.Single(str => str.EndsWith(filename)); string resourceName = files.Single(str => str.EndsWith(filename));
using (Stream stream = targetenv.GetManifestResourceStream(resourceName)) using (Stream stream = targetenv.GetManifestResourceStream(resourceName))
using (BinaryReader br = new BinaryReader(stream)) using (BinaryReader br = new(stream))
{ {
const int bufferSize = 4096; const int bufferSize = 4096;
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
@ -59,7 +59,7 @@ namespace SecondBotEvents
string resourceName = files.Single(str => str.EndsWith(filename)); string resourceName = files.Single(str => str.EndsWith(filename));
string result = ""; string result = "";
using (Stream stream = targetenv.GetManifestResourceStream(resourceName)) using (Stream stream = targetenv.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream)) using (StreamReader reader = new(stream))
{ {
result = reader.ReadToEnd(); result = reader.ReadToEnd();
} }

View file

@ -11,7 +11,7 @@ namespace BetterSecondBot.Static
{ {
public string id; public string id;
public string name; public string name;
public List<InventoryMapFolder> subfolders = new List<InventoryMapFolder>(); public List<InventoryMapFolder> subfolders = [];
} }
public class InventoryMapItem public class InventoryMapItem
{ {
@ -116,12 +116,14 @@ namespace BetterSecondBot.Static
public static List<InventoryMapItem> getfolderinventory(GridClient bot, UUID folder) public static List<InventoryMapItem> getfolderinventory(GridClient bot, UUID folder)
{ {
List<InventoryMapItem> entrys = new List<InventoryMapItem>(); List<InventoryMapItem> entrys = [];
InventoryNode node = bot.Inventory.Store.GetNodeFor(folder); InventoryNode node = bot.Inventory.Store.GetNodeFor(folder);
InventoryMapItem mapitem = new InventoryMapItem(); InventoryMapItem mapitem = new()
mapitem.name = node.Data.Name; {
mapitem.id = node.Data.UUID.ToString(); name = node.Data.Name,
mapitem.typename = "Folder"; id = node.Data.UUID.ToString(),
typename = "Folder"
};
entrys.Add(mapitem); entrys.Add(mapitem);
List<InventoryBase> contents = bot.Inventory.FolderContents(folder, bot.Self.AgentID, true, true, InventorySortOrder.ByDate, TimeSpan.FromSeconds(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 != null)
@ -130,10 +132,12 @@ namespace BetterSecondBot.Static
{ {
foreach (InventoryBase item in contents) foreach (InventoryBase item in contents)
{ {
mapitem = new InventoryMapItem(); mapitem = new InventoryMapItem
mapitem.name = item.Name; {
mapitem.id = item.UUID.ToString(); name = item.Name,
mapitem.typename = item.GetType().Name; id = item.UUID.ToString(),
typename = item.GetType().Name
};
entrys.Add(mapitem); entrys.Add(mapitem);
} }
} }
@ -147,7 +151,7 @@ namespace BetterSecondBot.Static
public static KeyValuePair<string,string> MapFolderInventoryHumanReadable(GridClient bot, UUID folder) public static KeyValuePair<string,string> MapFolderInventoryHumanReadable(GridClient bot, UUID folder)
{ {
StringBuilder output = new StringBuilder(); StringBuilder output = new();
string foldername = "Unknown"; string foldername = "Unknown";
foreach(InventoryMapItem mitem in getfolderinventory(bot, folder)) foreach(InventoryMapItem mitem in getfolderinventory(bot, folder))
{ {
@ -197,10 +201,12 @@ namespace BetterSecondBot.Static
public static InventoryMapFolder DoMapFolderJson(GridClient bot, InventoryFolder folder, bool subfolders=true) public static InventoryMapFolder DoMapFolderJson(GridClient bot, InventoryFolder folder, bool subfolders=true)
{ {
InventoryMapFolder ReplyFolder = new InventoryMapFolder(); InventoryMapFolder ReplyFolder = new()
ReplyFolder.id = folder.UUID.ToString(); {
ReplyFolder.name = folder.Name; id = folder.UUID.ToString(),
Dictionary<string, string> foldernode = new Dictionary<string, string>(); name = folder.Name
};
Dictionary<string, string> foldernode = [];
List<InventoryBase> T = bot.Inventory.Store.GetContents(folder); List<InventoryBase> T = bot.Inventory.Store.GetContents(folder);
foreach (InventoryBase R in T) foreach (InventoryBase R in T)
{ {
@ -219,7 +225,7 @@ namespace BetterSecondBot.Static
public static string MapFolderHumanReadable(GridClient bot) public static string MapFolderHumanReadable(GridClient bot)
{ {
StringBuilder B = new StringBuilder(); StringBuilder B = new();
DoMapFolderHumanReadable(bot, 0, bot.Inventory.Store.RootFolder, B); DoMapFolderHumanReadable(bot, 0, bot.Inventory.Store.RootFolder, B);
return B.ToString(); return B.ToString();
} }
@ -237,7 +243,7 @@ namespace BetterSecondBot.Static
} }
public static string Spaces(int counter) public static string Spaces(int counter)
{ {
StringBuilder reply = new StringBuilder(); StringBuilder reply = new();
while (counter > 0) while (counter > 0)
{ {
reply.Append(" "); reply.Append(" ");

View file

@ -57,7 +57,7 @@ namespace SecondBotEvents
public static string GetClockStamp() public static string GetClockStamp()
{ {
var date = DateTime.Now; var date = DateTime.Now;
StringBuilder n = new StringBuilder(); StringBuilder n = new();
n.Append("["); n.Append("[");
if (date.Hour < 10) if (date.Hour < 10)
{ {
@ -77,7 +77,7 @@ namespace SecondBotEvents
private static string Add(string message, ConsoleLogLogLevel Level, bool send_to_console = true) private static string Add(string message, ConsoleLogLogLevel Level, bool send_to_console = true)
{ {
StringBuilder n = new StringBuilder(); StringBuilder n = new();
n.Append(GetClockStamp()); n.Append(GetClockStamp());
switch (Level) switch (Level)
{ {

View file

@ -9,25 +9,27 @@ namespace SecondBotEvents
{ {
public static Dictionary<string, Type> getCommandModules() public static Dictionary<string, Type> getCommandModules()
{ {
Dictionary<string, Type> reply = new Dictionary<string, Type>(); Dictionary<string, Type> reply = new()
reply.Add("animation", typeof(AnimationCommands)); {
reply.Add("avatars", typeof(Avatars)); { "animation", typeof(AnimationCommands) },
reply.Add("chat", typeof(Chat)); { "avatars", typeof(Avatars) },
reply.Add("core", typeof(Core)); { "chat", typeof(Chat) },
reply.Add("dialogs", typeof(Dialogs)); { "core", typeof(Core) },
reply.Add("discord", typeof(DiscordCommands)); { "dialogs", typeof(Dialogs) },
reply.Add("estate", typeof(Estate)); { "discord", typeof(DiscordCommands) },
reply.Add("friends", typeof(Friends)); { "estate", typeof(Estate) },
reply.Add("funds", typeof(Funds)); { "friends", typeof(Friends) },
reply.Add("group", typeof(GroupCommands)); { "funds", typeof(Funds) },
reply.Add("info", typeof(Info)); { "group", typeof(GroupCommands) },
reply.Add("inventory", typeof(InventoryCommands)); { "info", typeof(Info) },
reply.Add("movement", typeof(Movement)); { "inventory", typeof(InventoryCommands) },
reply.Add("notecard", typeof(Notecard)); { "movement", typeof(Movement) },
reply.Add("parcel", typeof(ParcelCommands)); { "notecard", typeof(Notecard) },
reply.Add("self", typeof(Self)); { "parcel", typeof(ParcelCommands) },
reply.Add("streamadmin", typeof(StreamAdmin)); { "self", typeof(Self) },
reply.Add("services", typeof(SecondBotEvents.Commands.Services)); { "streamadmin", typeof(StreamAdmin) },
{ "services", typeof(SecondBotEvents.Commands.Services) }
};
return reply; return reply;
} }
} }

View file

@ -59,7 +59,7 @@ namespace SecondBotEvents
System.Type enumType = typeof(ParcelFlags); System.Type enumType = typeof(ParcelFlags);
List<string> flagnames = new(System.Enum.GetNames(enumType)); List<string> flagnames = new(System.Enum.GetNames(enumType));
flagnames.Remove("None"); flagnames.Remove("None");
return flagnames.ToArray(); return [.. flagnames];
} }
public static Dictionary<string, string> GetMediaList() public static Dictionary<string, string> GetMediaList()
@ -79,7 +79,7 @@ namespace SecondBotEvents
} }
public static Dictionary<string, ParcelFlags> GetFlagsList() public static Dictionary<string, ParcelFlags> GetFlagsList()
{ {
Dictionary<string, ParcelFlags> flags = new(); Dictionary<string, ParcelFlags> flags = [];
Type enumType = typeof(ParcelFlags); Type enumType = typeof(ParcelFlags);
Array enumValues = Enum.GetValues(enumType); Array enumValues = Enum.GetValues(enumType);
Array enumNames = Enum.GetNames(enumType); Array enumNames = Enum.GetNames(enumType);

View file

@ -16,7 +16,7 @@ namespace SecondBotEvents
{ {
public class WikiMake public class WikiMake
{ {
protected SimpleIO IO = new SimpleIO(); protected SimpleIO IO = new();
protected string version = ""; protected string version = "";
protected string htmltemplate = ""; protected string htmltemplate = "";
public WikiMake() public WikiMake()
@ -106,7 +106,7 @@ namespace SecondBotEvents
+ "<hr/>"; + "<hr/>";
Dictionary<string,string> hints = new Dictionary<string,string>(); Dictionary<string,string> hints = [];
foreach (ArgHints At in method.GetCustomAttributes<ArgHints>()) foreach (ArgHints At in method.GetCustomAttributes<ArgHints>())
{ {
hints.Add(At.name, At.about); hints.Add(At.name, At.about);