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_ObjectMasterOptout='false' \
commands_AllowServiceControl='false' \
commands_CommandHistoryLogResults='false' \
datastore_AutoCleanAvatars='true' \
datastore_AvatarsCleanAfterMins=10 \
datastore_LocalChatHistoryLimit=120 \

View file

@ -7,14 +7,8 @@ using System.Linq;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("Granted perm animation")]
[ReturnHints("Removed perm animation")]
@ -25,7 +19,7 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return BasicReply("avatar lookup", new [] { avatar });
return BasicReply("avatar lookup", [avatar]);
}
// @todo accept storage
return Failure("@todo");
@ -39,18 +33,18 @@ namespace SecondBotEvents.Commands
{
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));
GetClient().Self.PlayGesture(itm.AssetUUID);
return BasicReply("Accepted", new [] { gesture });
return BasicReply("Accepted", [gesture]);
}
[About("Resets the animation stack for the bot")]
[ReturnHints("Accepted - X stopped animations")]
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)
{
GetClient().Self.AnimationStop(anim, true);

View file

@ -8,13 +8,8 @@ using System.Threading.Tasks;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("ok")]
[ReturnHintsFailure("Invaild avatar uuid")]
@ -28,7 +23,7 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar uuid", new[] { store, avatar, remove });
return Failure("Invaild avatar uuid", [store, avatar, remove]);
}
bool toberemoved = false;
if((remove == "true") || (remove == "True"))
@ -37,13 +32,13 @@ namespace SecondBotEvents.Commands
}
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)
{
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")]
[ReturnHints("true")]
@ -57,17 +52,17 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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)
{
return Failure("Unknown store type", new[] { store, avatar });
return Failure("Unknown store type", [store, avatar]);
}
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");
}
List<NearMeDetails> BetterNearMe = new List<NearMeDetails>();
List<NearMeDetails> BetterNearMe = [];
Dictionary<uint, Avatar> avcopy = GetClient().Network.CurrentSim.ObjectsAvatars.Copy();
foreach (Avatar av in avcopy.Values)
{
if (av.ID != GetClient().Self.AgentID)
{
NearMeDetails details = new NearMeDetails();
details.id = av.ID.ToString();
details.name = av.Name;
details.x = (int)Math.Round(av.Position.X);
details.y = (int)Math.Round(av.Position.Y);
details.z = (int)Math.Round(av.Position.Z);
details.range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition));
NearMeDetails details = new()
{
id = av.ID.ToString(),
name = av.Name,
x = (int)Math.Round(av.Position.X),
y = (int)Math.Round(av.Position.Y),
z = (int)Math.Round(av.Position.Z),
range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition))
};
BetterNearMe.Add(details);
}
}
@ -109,12 +106,12 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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);
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());
}
@ -128,12 +125,12 @@ namespace SecondBotEvents.Commands
{
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);
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;
props.ProfileImage = textureUUID;
@ -151,12 +148,12 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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);
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());
}
@ -171,16 +168,16 @@ namespace SecondBotEvents.Commands
{
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)
{
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);
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;
props.AboutText = abouttext;
@ -199,7 +196,7 @@ namespace SecondBotEvents.Commands
{
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();
foreach (Avatar av in avcopy.Values)
{

View file

@ -5,12 +5,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("json encoded array")]
public object LocalChatHistory()
@ -27,11 +23,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Invaild channel", new [] { channel, message });
return Failure("Invaild channel", [channel, message]);
}
master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Normal);
@ -47,11 +43,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Invaild channel", new[] { channel, message });
return Failure("Invaild channel", [channel, message]);
}
master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Shout);
@ -67,11 +63,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Invaild channel", new[] { channel, message });
return Failure("Invaild channel", [channel, message]);
}
master.DataStoreService.BotRecordLocalchatReply(message);
GetClient().Self.Chat(message, channelnum, ChatType.Whisper);
@ -91,15 +87,15 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if(avataruuid == UUID.Zero)
{
return Failure("avatar lookup", new [] { avatar, message });
return Failure("avatar lookup", [avatar, message]);
}
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.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")]

View file

@ -3,11 +3,8 @@
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("world")]
public object Hello()

View file

@ -5,12 +5,8 @@ using SecondBotEvents.Services;
namespace SecondBotEvents.Commands
{
[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]")]
[ReturnHints("added")]
[ReturnHints("removed")]
@ -79,7 +75,7 @@ namespace SecondBotEvents.Commands
{
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));
}

View file

@ -6,11 +6,8 @@ using System.Linq;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHintsFailure("Discord client not ready")]
[ReturnHints("true|false")]
@ -23,7 +20,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -41,9 +38,9 @@ namespace SecondBotEvents.Commands
}
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)
@ -71,7 +68,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -86,7 +83,7 @@ namespace SecondBotEvents.Commands
{
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" +
@ -101,7 +98,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -120,9 +117,9 @@ namespace SecondBotEvents.Commands
}
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")]
@ -137,7 +134,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -152,7 +149,7 @@ namespace SecondBotEvents.Commands
{
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" +
@ -168,7 +165,7 @@ namespace SecondBotEvents.Commands
{
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" +
@ -183,7 +180,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -196,7 +193,7 @@ namespace SecondBotEvents.Commands
{
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")]
@ -209,7 +206,7 @@ namespace SecondBotEvents.Commands
{
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")]

View file

@ -6,11 +6,8 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("restarting")]
[ReturnHintsFailure("Not an estate manager here")]
@ -22,22 +19,21 @@ namespace SecondBotEvents.Commands
{
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);
if (modeflag == false)
{
GetClient().Estate.CancelRestart();
return BasicReply("canceled", new [] { delay, mode });
return BasicReply("canceled", [delay, mode]);
}
int delay_restart = 60;
int.TryParse(delay, out delay_restart);
if((delay_restart < 30) || (delay_restart > 240))
int.TryParse(delay, out int delay_restart);
if ((delay_restart < 30) || (delay_restart > 240))
{
delay_restart = 240;
}
GetClient().Estate.RestartRegion(delay_restart);
return BasicReply("restarting", new [] { delay, mode });
return BasicReply("restarting", [delay, mode]);
}
[About("Sends the message to the current sim")]
@ -49,14 +45,14 @@ namespace SecondBotEvents.Commands
{
if (SecondbotHelpers.notempty(message) == false)
{
return Failure("Message empty", new [] { message });
return Failure("Message empty", [message]);
}
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);
return BasicReply("ok", new [] { message });
return BasicReply("ok", [message]);
}
[About("Fetchs the regions map tile")]
@ -67,9 +63,9 @@ namespace SecondBotEvents.Commands
{
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")]
@ -94,12 +90,14 @@ namespace SecondBotEvents.Commands
{
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>();
reply.Add("region", regionname);
reply.Add("X", region.X.ToString());
reply.Add("Y", region.Y.ToString());
Dictionary<string, string> reply = new()
{
{ "region", regionname },
{ "X", region.X.ToString() },
{ "Y", region.Y.ToString() }
};
return BasicReply(JsonConvert.SerializeObject(reply));
}
@ -124,25 +122,24 @@ namespace SecondBotEvents.Commands
{
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;
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 globalban) == false)
if (bool.TryParse(global, out bool 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")
{
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);
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
{
[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")]
[ReturnHints("a json object of global region X,Y sim X,Y,Z and time it was updated")]
[ReturnHintsFailure("avatar lookup")]
@ -23,20 +19,20 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("avatar lookup", new[] { avatar });
return Failure("avatar lookup", [avatar]);
}
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
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);
FriendLocations loc = master.DataStoreService.GetFriendMap(avataruuid);
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")]
@ -44,14 +40,16 @@ namespace SecondBotEvents.Commands
public object Friendslist()
{
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
List< FriendListEntry > CleanedFriendsList = new List< FriendListEntry >();
List< FriendListEntry > CleanedFriendsList = [];
int index = 0;
foreach (FriendInfo A in FriendListCopy.Values)
{
FriendListEntry entry = new FriendListEntry();
entry.id = A.UUID.ToString();
entry.name = A.Name;
entry.online = A.IsOnline;
FriendListEntry entry = new()
{
id = A.UUID.ToString(),
name = A.Name,
online = A.IsOnline
};
CleanedFriendsList.Add(entry);
index++;
}
@ -71,24 +69,23 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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 status) == false)
if (bool.TryParse(state, out bool status) == false)
{
return Failure("state invaild", new [] { avatar, state });
return Failure("state invaild", [avatar, state]);
}
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)
{
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);
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")]
@ -105,27 +102,26 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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 status) == false)
if (bool.TryParse(state, out bool status) == false)
{
return Failure("state invaild", new [] { avatar, state });
return Failure("state invaild", [avatar, state]);
}
if (GetClient().Friends.FriendList.ContainsKey(avataruuid) == true)
{
if (status == false)
{
GetClient().Friends.TerminateFriendship(avataruuid);
return BasicReply("Removed", new [] { avatar, state });
return BasicReply("Removed", [avatar, state]);
}
}
if (status == false)
{
return Failure("Not in friendslist", new [] { avatar, state });
return Failure("Not in friendslist", [avatar, state]);
}
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
{
[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.")]
[ReturnHints("Current fund level")]
[ReturnHintsFailure("Funds commands are disabled")]
@ -35,24 +32,24 @@ namespace SecondBotEvents.Commands
{
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);
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)
{
return Failure("Invaild amount", new [] { avatar, amount });
return Failure("Invaild amount", [avatar, amount]);
}
if ((amountvalue < 0) || (amountvalue > GetClient().Self.Balance))
{
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);
return BasicReply("Accepted", new [] { avatar, amount });
return BasicReply("Accepted", [avatar, amount]);
}
[About("Makes the bot pay a object")]
@ -69,26 +66,26 @@ namespace SecondBotEvents.Commands
{
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)
{
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)
{
return Failure("Invaild amount", new [] { objectuuid, primname, amount });
return Failure("Invaild amount", [objectuuid, primname, amount]);
}
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)
{
return Failure("Primname is empty", new [] { objectuuid, primname, amount });
return Failure("Primname is empty", [objectuuid, primname, amount]);
}
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
{
[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")]
[ReturnHints("Membership reply with [membershipStatus,AvatarUUID,AvatarnameIfKnown,GroupUUID]")]
[ReturnHintsFailure("Updating")]
@ -24,7 +20,7 @@ namespace SecondBotEvents.Commands
{
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);
return BasicReply(master.DataStoreService.IsGroupMember(groupuuid, avataruuid).ToString());
@ -41,7 +37,7 @@ namespace SecondBotEvents.Commands
{
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)));
}
@ -60,27 +56,27 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new[] { group, avatar, state });
return Failure("Unknown group", [group, avatar, state]);
}
ProcessAvatar(avatar);
if(avataruuid == UUID.Zero)
{
return Failure("Unknown avatar", new[] { group, avatar, state });
return Failure("Unknown avatar", [group, avatar, state]);
}
GroupBanAction Action = GroupBanAction.Ban;
if (state == "false")
{
Action = GroupBanAction.Unban;
}
List<UUID> avatarstoaction = new()
{
List<UUID> avatarstoaction =
[
avataruuid
};
GetClient().Groups.RequestBanAction(groupuuid, Action, avatarstoaction.ToArray());
];
GetClient().Groups.RequestBanAction(groupuuid, Action, [.. avatarstoaction]);
return BasicReply("Accepted");
}
@ -100,16 +96,16 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new[] { group, avatar });
return Failure("Unknown group", [group, avatar]);
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Unknown avatar", new[] { group, avatar});
return Failure("Unknown avatar", [group, avatar]);
}
GetClient().Groups.EjectUser(groupuuid, avataruuid);
return BasicReply("Accepted");
@ -129,20 +125,20 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Invaild role UUID", new [] { group, avatar });
return Failure("Invaild role UUID", [group, avatar]);
}
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupuuid) == false)
{
return Failure("Unknown group", new[] { group, avatar, role });
return Failure("Unknown group", [group, avatar, role]);
}
ProcessAvatar(avatar);
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");
}
GetClient().Groups.AddToRole(groupuuid, roleuuid, avataruuid);
@ -164,31 +160,31 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new[] { group, avatar, role });
return Failure("Unknown group", [group, avatar, role]);
}
ProcessAvatar(avatar);
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
};
];
if (role != "everyone")
{
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);
}
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!)")]
@ -205,19 +201,19 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new [] { group, title, message });
return Failure("Unknown group", [group, title, message]);
}
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)
{
return Failure("Message empty", new [] { group, title, message });
return Failure("Message empty", [group, title, message]);
}
GroupNotice NewNotice = new()
{
@ -226,7 +222,7 @@ namespace SecondBotEvents.Commands
OwnerID = GetClient().Self.AgentID
};
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")]
@ -240,18 +236,18 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Invaild role UUID", new [] { group, role });
return Failure("Invaild role UUID", [group, role]);
}
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);
return BasicReply("Switching title", new [] { group, role });
return BasicReply("Switching title", [group, role]);
}
[About("Sets the selected group to the active group")]
@ -263,14 +259,14 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new[] { group });
return Failure("Unknown group", [group]);
}
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")]
@ -289,23 +285,23 @@ namespace SecondBotEvents.Commands
{
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)
{
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)
{
return Failure("Unknown group", new [] { group, title, message, attachment });
return Failure("Unknown group", [group, title, message, attachment]);
}
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)
{
return Failure("Message empty", new [] { group, title, message, attachment });
return Failure("Message empty", [group, title, message, attachment]);
}
GroupNotice NewNotice = new()
{
@ -315,7 +311,7 @@ namespace SecondBotEvents.Commands
AttachmentID = inventoryuuid
};
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)
{
return Failure("Invaild group UUID", new [] { group });
return Failure("Invaild group UUID", [group]);
}
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)));
}
@ -369,11 +365,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new [] { group });
return Failure("Unknown group", [group]);
}
return BasicReply(master.DataStoreService.GetGroupChatHasUnread(groupUUID).ToString());
}
@ -402,7 +398,7 @@ namespace SecondBotEvents.Commands
{
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)));
}
@ -417,15 +413,15 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Unknown group", new [] { group, message });
return Failure("Unknown group", [group, message]);
}
if (GetClient().Groups.GroupName2KeyCache.ContainsKey(groupUUID) == false)
{
return Failure("Unknown group", new[] { group });
return Failure("Unknown group", [group]);
}
GetClient().Self.InstantMessageGroup(groupUUID, message);
master.DataStoreService.BotRecordReplyIM(groupUUID, message);

View file

@ -7,20 +7,16 @@ using System.Collections.Generic;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("A json object")]
public object ListSculptys()
{
Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy();
Dictionary<uint, uint> mapLocalID = new Dictionary<uint, uint>();
Dictionary<uint, Primitive> sculpts = new Dictionary<uint, Primitive>();
Dictionary<uint, uint> mapLocalID = [];
Dictionary<uint, Primitive> sculpts = [];
foreach (KeyValuePair<uint, Primitive> Obj in objects_copy)
{
mapLocalID.Add(Obj.Value.LocalID, Obj.Key);
@ -29,7 +25,7 @@ namespace SecondBotEvents.Commands
sculpts.Add(Obj.Key, Obj.Value);
}
}
List<SculptysInfo> reply = new List<SculptysInfo>();
List<SculptysInfo> reply = [];
foreach (KeyValuePair<uint, Primitive> Obj in sculpts)
{
Vector3 pos = Obj.Value.Position;
@ -56,12 +52,14 @@ namespace SecondBotEvents.Commands
key = wip.ID;
}
}
SculptysInfo A = new SculptysInfo();
A.isLinked = asLink.ToString();
A.name = name.ToString();
A.owner = owner.ToString();
A.uuid = key.ToString();
A.pos = pos.ToString();
SculptysInfo A = new()
{
isLinked = asLink.ToString(),
name = name.ToString(),
owner = owner.ToString(),
uuid = key.ToString(),
pos = pos.ToString()
};
reply.Add(A);
}
if (reply.Count == 0)
@ -132,10 +130,12 @@ namespace SecondBotEvents.Commands
{
return Failure("Error not in a sim");
}
Dictionary<string, int> pos = new Dictionary<string, int>();
pos.Add("x", (int)Math.Round(GetClient().Self.SimPosition.X));
pos.Add("y", (int)Math.Round(GetClient().Self.SimPosition.Y));
pos.Add("z", (int)Math.Round(GetClient().Self.SimPosition.Z));
Dictionary<string, int> pos = new()
{
{ "x", (int)Math.Round(GetClient().Self.SimPosition.X) },
{ "y", (int)Math.Round(GetClient().Self.SimPosition.Y) },
{ "z", (int)Math.Round(GetClient().Self.SimPosition.Z) }
};
return BasicReply(JsonConvert.SerializeObject(pos));
}
}

View file

@ -12,12 +12,8 @@ using System.Linq;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("cleared")]
[ReturnHints("No action")]
@ -72,15 +68,15 @@ namespace SecondBotEvents.Commands
{
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));
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);
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)
{
return Failure("invaild item uuid", new [] { item, newname });
return Failure("invaild item uuid", [item, newname]);
}
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);
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;
GetClient().Inventory.RequestUpdateItem(realitem);
return BasicReply("Ok", new [] { item, newname });
return BasicReply("Ok", [item, newname]);
}
[About("Attempts to Remove the given inventory item")]
@ -119,10 +115,10 @@ namespace SecondBotEvents.Commands
{
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>());
return BasicReply("Ok", new [] { item });
GetClient().Inventory.Remove([target], []);
return BasicReply("Ok", [item]);
}
[About("Attempts to Remove the given inventory folder")]
@ -133,10 +129,10 @@ namespace SecondBotEvents.Commands
{
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 });
return BasicReply("Ok", new [] { folder });
GetClient().Inventory.Remove([], [target]);
return BasicReply("Ok", [folder]);
}
[About("Attempts to attach the given inventory item")]
@ -147,11 +143,11 @@ namespace SecondBotEvents.Commands
{
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);
GetClient().Appearance.AddAttachments(new List<InventoryItem>() { realitem }, false, false);
return BasicReply("Ok", new [] { item });
GetClient().Appearance.AddAttachments([realitem], false, false);
return BasicReply("Ok", [item]);
}
[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)
{
List<InventoryItem> toBeRemoved = new List<InventoryItem>();
List<InventoryItem> toBeRemoved = [];
foreach (KeyValuePair<UUID, AttachmentPoint> pair in GetClient().Appearance.GetAttachmentsByItemId())
{
if((pair.Value.ToString() != item) || (item == "*"))
@ -174,18 +170,18 @@ namespace SecondBotEvents.Commands
}
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)
{
GetClient().Appearance.RemoveFromOutfit(A);
}
return BasicReply("ok", new[] { item });
return BasicReply("ok", [item]);
}
InventoryItem realitem = HelperInventory.getItemByInventoryUUID(GetClient(), itemuuid);
GetClient().Appearance.RemoveFromOutfit(realitem);
return BasicReply("Ok", new [] { item });
return BasicReply("Ok", [item]);
}
@ -201,13 +197,13 @@ namespace SecondBotEvents.Commands
UUID folderUUID = UUID.Zero;
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<InventoryItem> wareables = new();
List<InventoryItem> wareables = [];
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)
{
@ -217,7 +213,7 @@ namespace SecondBotEvents.Commands
}
}
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!")]
@ -231,7 +227,7 @@ namespace SecondBotEvents.Commands
{
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
// must be a full outfit (shapes/eyes ect)
@ -248,7 +244,7 @@ namespace SecondBotEvents.Commands
}
if (AA == null)
{
return Failure("Cant find Clothing folder", new [] { name });
return Failure("Cant find Clothing folder", [name]);
}
T = GetClient().Inventory.Store.GetContents(AA);
AA = null;
@ -262,13 +258,13 @@ namespace SecondBotEvents.Commands
}
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<InventoryItem> wareables = new();
List<InventoryItem> wareables = [];
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)
{
@ -278,7 +274,7 @@ namespace SecondBotEvents.Commands
}
}
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");
}
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));
foreach (InventoryBase C in contents)
{
@ -318,7 +314,7 @@ namespace SecondBotEvents.Commands
}
if (purge_notecards.Count > 0)
{
GetClient().Inventory.Remove(purge_notecards, new List<UUID>());
GetClient().Inventory.Remove(purge_notecards, []);
}
return BasicReply("Ok");
}
@ -331,10 +327,10 @@ namespace SecondBotEvents.Commands
{
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);
return BasicReply(reply.ToString(), new [] { item });
return BasicReply(reply.ToString(), [item]);
}
[About("sends a item to an avatar via a path")]
@ -349,20 +345,20 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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));
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));
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);
return BasicReply("ok", new[] { path, avatar });
return BasicReply("ok", [path, avatar]);
}
[About("sends a item to an avatar")]
@ -378,19 +374,19 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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)
{
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));
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);
return BasicReply("ok", new [] { item, avatar });
return BasicReply("ok", [item, avatar]);
}
[About("Sends a folder to an avatar")]
[ReturnHints("ok")]
@ -403,15 +399,15 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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);
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);
return BasicReply("ok", new[] { path, avatar });
return BasicReply("ok", [path, avatar]);
}
@ -428,19 +424,19 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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)
{
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);
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);
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])")]
@ -458,21 +454,21 @@ namespace SecondBotEvents.Commands
{
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)
{
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)
{
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));
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();
KeyValuePair<uint, Primitive> RealObject = new(0, null);
@ -495,7 +491,7 @@ namespace SecondBotEvents.Commands
break;
}
}
return Failure("Unable to find object", new [] { item, objectuuid, running });
return Failure("Unable to find object", [item, objectuuid, running]);
}
bool scriptState = runscript;
if (itm.AssetType != AssetType.LSLText)
@ -505,10 +501,10 @@ namespace SecondBotEvents.Commands
if (itm.AssetType == AssetType.LSLText)
{
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);
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>")]
@ -540,9 +536,9 @@ namespace SecondBotEvents.Commands
{
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")]
@ -555,15 +551,15 @@ namespace SecondBotEvents.Commands
{
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)
{
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);
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)
{
return Failure("invaild item uuid", new[] { item, folder });
return Failure("invaild item uuid", [item, folder]);
}
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);
return BasicReply("Ok", new string[] { item });
return BasicReply("Ok", [item]);
}
[About("moves a folder to another folder")]
@ -597,14 +593,14 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("invaild dest folder uuid", new[] { sourceFolder, destFolder });
return Failure("invaild dest folder uuid", [sourceFolder, destFolder]);
}
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
{
[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")]
[ReturnHints("ok")]
[ReturnHintsFailure("Convert to float has failed")]
@ -23,14 +19,14 @@ namespace SecondBotEvents.Commands
{
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)
{
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);
return BasicReply("ok", new[] { height });
return BasicReply("ok", [height]);
}
[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)
{
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)
{
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)
{
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)
{
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.Movement.TurnToward(pos, true);
Thread.Sleep(500);
uint Globalx, Globaly;
Utils.LongToUInts(GetClient().Network.CurrentSim.Handle, out Globalx, out Globaly);
Utils.LongToUInts(GetClient().Network.CurrentSim.Handle, out uint Globalx, out uint Globaly);
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")]
@ -85,10 +80,10 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if(avataruuid == UUID.Zero)
{
return Failure("Invaild avatar UUID", new [] { avatar });
return Failure("Invaild avatar UUID", [avatar]);
}
GetClient().Self.SendTeleportLure(avataruuid);
return BasicReply("ok", new [] { avatar });
return BasicReply("ok", [avatar]);
}
[About("Sends a teleport request (Move the bot to the avatar)")]
@ -100,11 +95,11 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar UUID", new [] { avatar });
return Failure("Invaild avatar UUID", [avatar]);
}
// @todo action from event log with accept
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)")]
@ -115,11 +110,11 @@ namespace SecondBotEvents.Commands
{
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.SendUpdate();
return BasicReply("ok", new [] { mode });
return BasicReply("ok", [mode]);
}
[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)
{
return Failure("Invaild vector", new [] { vector });
return Failure("Invaild vector", [vector]);
}
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)
{
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)
{
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")]
@ -158,13 +153,13 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
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)
{
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")]
@ -175,7 +170,7 @@ namespace SecondBotEvents.Commands
{
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;
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;
GetClient().Self.Movement.BodyRotation = result;
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);
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)
{
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)
{
// Viserion/66/166/23
GetClient().Self.AutoPilotCancel();
SimSlURL A = new SimSlURL(url);
SimSlURL A = new(url);
if(A.name == null)
{
return false;

View file

@ -7,12 +7,8 @@ using SecondBotEvents.Services;
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")]
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")]
[ReturnHintsFailure("Not a vaild UUID")]
[ReturnHintsFailure("Unable to find inventory item")]
@ -27,28 +23,30 @@ namespace SecondBotEvents.Commands
{
return Failure("replytarget not set");
}
NotecardReadReply reply = new NotecardReadReply();
reply.uuid = notecardInventoryUUID;
reply.name = "?";
reply.status = false;
reply.content = "Not a vaild UUID";
NotecardReadReply reply = new()
{
uuid = notecardInventoryUUID,
name = "?",
status = false,
content = "Not a vaild UUID"
};
if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false)
{
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID });
return Failure(reply.content, [notecardInventoryUUID]);
}
reply.content = "Unable to find inventory item";
InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30));
if (item == null)
{
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID });
return Failure(reply.content, [notecardInventoryUUID]);
}
reply.content = "Inventory item is not a notecard";
if (item.InventoryType != InventoryType.Notecard)
{
master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
return Failure(reply.content, new[] { notecardInventoryUUID }); ;
return Failure(reply.content, [notecardInventoryUUID]); ;
}
InventoryNotecard notecard = (InventoryNotecard)item;
GetClient().Assets.RequestInventoryAsset(notecard, true, UUID.Random(), (AssetDownload transfer, Asset asset) =>
@ -95,14 +93,14 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Content value is empty", new [] { collection, content });
return Failure("Content value is empty", [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")]
@ -113,7 +111,7 @@ namespace SecondBotEvents.Commands
{
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);
return BasicReply("ok");
@ -132,26 +130,26 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Notecardname value is empty", new [] { avatar, collection, notecardname });
return Failure("Notecardname value is empty", [avatar, collection, notecardname]);
}
ProcessAvatar(avatar);
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);
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);
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);
return BasicReply("ok");
@ -169,21 +167,21 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("content value is empty", new[] { avatar, content, notecardname });
return Failure("content value is empty", [avatar, content, notecardname]);
}
ProcessAvatar(avatar);
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);
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");
}

View file

@ -13,12 +13,12 @@ using static OpenMetaverse.Stats.UtilizationStatistics;
namespace SecondBotEvents.Commands
{
public class parcelPacketReply
public class ParcelPacketReply
{
public List<string> groupuuids = new List<string>();
public List<parcelPacketData> parcels = new List<parcelPacketData>();
public List<string> groupuuids = [];
public List<ParcelPacketData> parcels = [];
}
public class parcelPacketData
public class ParcelPacketData
{
public int area;
public int groupindex;
@ -30,12 +30,8 @@ namespace SecondBotEvents.Commands
}
[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")]
[ReturnHints("ok")]
public object UpdateListOfParcels()
@ -47,8 +43,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("json encoded object")]
public object GetParcelListSnapshots()
{
Dictionary<string, string> reply = new Dictionary<string, string>();
List<Parcel> Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList();
Dictionary<string, string> reply = [];
List<Parcel> Parcels = [.. GetClient().Network.CurrentSim.Parcels.Copy().Values];
foreach (Parcel A in Parcels)
{
reply.Add(A.Name, A.SnapshotID.ToString());
@ -61,32 +57,32 @@ namespace SecondBotEvents.Commands
public object GetSimParcelLayers()
{
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 SimHeight = GetClient().Network.CurrentSim.SizeY;
Dictionary<int,string> maps = new Dictionary<int,string>();
Dictionary<int,string> maps = [];
int lastparcelid = 0;
uint lowX = 0;
uint lowY = 0;
Random rnd = new Random();
Random rnd = new();
uint startX = 4;
string svg = "<svg width=\"" + SimWidth + "\" height=\"" + SimHeight + "\" xmlns=\"http://www.w3.org/2000/svg\">";
uint boxheight = 0;
var color = "";
Parcel P = null;
string parcelname = "?";
int checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, 4, 20));
while (startX < SimWidth)
{
uint startY = 4;
string parcelname;
while (startY < SimHeight)
{
checkparcel = GetClient().Parcels.GetParcelLocalID(GetClient().Network.CurrentSim, new Vector3(startX, startY, 20));
if ((checkparcel != lastparcelid) || (startY >= SimHeight))
{
if(lastparcelid == 0)
if (lastparcelid == 0)
{
lastparcelid = checkparcel;
lowX = startX - 4;
@ -94,7 +90,7 @@ namespace SecondBotEvents.Commands
}
else
{
boxheight = (startY-4) - lowY;
boxheight = (startY - 4) - lowY;
color = "";
if (maps.ContainsKey(lastparcelid) == false)
{
@ -140,7 +136,7 @@ namespace SecondBotEvents.Commands
lastparcelid = 0;
startX += 4;
}
svg = svg + "</svg>";
svg += "</svg>";
return BasicReply(svg);
}
@ -149,8 +145,8 @@ namespace SecondBotEvents.Commands
[ReturnHints("json encoded object")]
public object GetListOfParcels()
{
parcelPacketReply reply = new parcelPacketReply();
List<Parcel> Parcels = GetClient().Network.CurrentSim.Parcels.Copy().Values.ToList();
ParcelPacketReply reply = new();
List<Parcel> Parcels = [.. GetClient().Network.CurrentSim.Parcels.Copy().Values];
foreach (Parcel A in Parcels)
{
int index = reply.groupuuids.IndexOf(A.GroupID.ToString());
@ -159,14 +155,16 @@ namespace SecondBotEvents.Commands
reply.groupuuids.Add(A.GroupID.ToString());
index = reply.groupuuids.IndexOf(A.GroupID.ToString());
}
parcelPacketData R = new parcelPacketData();
R.groupindex = index;
R.area = A.Area;
R.startbox = A.AABBMin.ToString();
R.endbox = A.AABBMax.ToString();
R.currentprims = A.TotalPrims;
R.maxprims = A.MaxPrims;
R.name = A.Name;
ParcelPacketData R = new()
{
groupindex = index,
area = A.Area,
startbox = A.AABBMin.ToString(),
endbox = A.AABBMax.ToString(),
currentprims = A.TotalPrims,
maxprims = A.MaxPrims,
name = A.Name
};
reply.parcels.Add(R);
}
return BasicReply(JsonConvert.SerializeObject(reply));
@ -201,11 +199,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
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)
{
return Failure("Invaild amount", new [] { amount, avatar });
return Failure("Invaild amount", [amount, avatar]);
}
int minAmount = 1;
@ -220,14 +218,14 @@ namespace SecondBotEvents.Commands
}
if ((amountvalue < minAmount) || (amountvalue > 9999999))
{
return Failure("Invaild amount", new [] { amount, avatar });
return Failure("Invaild amount", [amount, avatar]);
}
targetparcel.SalePrice = amountvalue;
targetparcel.AuthBuyerID = avataruuid;
ParcelStatic.ParcelSetFlag(ParcelFlags.ForSale, targetparcel, true);
ParcelStatic.ParcelSetFlag(ParcelFlags.ForSaleObjects, targetparcel, false);
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);
}
Dictionary<string, string> collection = new Dictionary<string, string>();
Dictionary<string, string> collection = [];
collection.Add("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString());
collection.Add("Cost", targetparcel.SalePrice.ToString());
collection.Add("SaleTarget", targetparcel.AuthBuyerID.ToString());
@ -320,8 +318,8 @@ namespace SecondBotEvents.Commands
{
return Failure("timeout must be >= 2000 and <= 7000");
}
AutoResetEvent landresultsTimeout = new AutoResetEvent(false);
List<string> collection = new List<string>();
AutoResetEvent landresultsTimeout = new(false);
List<string> collection = [];
void LandSearchResultsReply(object sender, DirLandReplyEventArgs e)
{
int counter = (100 * GetpageNum);
@ -344,7 +342,7 @@ namespace SecondBotEvents.Commands
GetClient().Directory.DirLandReply -= LandSearchResultsReply;
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();
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)
{
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)
{
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)
{
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.UserLocation = new Vector3(X, Y, Z);
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();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { name });
return Failure(tests.Value, [name]);
}
if (SecondbotHelpers.notempty(name) == false)
{
return Failure("Parcel name is empty", new [] { name });
return Failure("Parcel name is empty", [name]);
}
targetparcel.Name = name;
targetparcel.Update(GetClient());
return BasicReply("ok", new [] { name });
return BasicReply("ok", [name]);
}
[About("Updates the current parcels description")]
@ -414,11 +412,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { desc });
return Failure(tests.Value, [desc]);
}
targetparcel.Desc = desc;
targetparcel.Update(GetClient());
return BasicReply("ok", new [] { desc });
return BasicReply("ok", [desc]);
}
[About("Fetchs the current parcels desc")]
@ -447,7 +445,7 @@ namespace SecondBotEvents.Commands
return Failure(tests.Value);
}
Dictionary<string, ParcelFlags> flags = ParcelStatic.GetFlagsList();
Dictionary<string, string> collection = new();
Dictionary<string, string> collection = [];
foreach (ParcelFlags cfg in flags.Values)
{
collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString());
@ -464,10 +462,10 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if(avataruuid == UUID.Zero)
{
return Failure("Invaild avatar", new [] { avatar });
return Failure("Invaild avatar", [avatar]);
}
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")]
@ -496,12 +494,12 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { avatar });
return Failure(tests.Value, [avatar]);
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar", new [] { avatar });
return Failure("Invaild avatar", [avatar]);
}
bool alreadyBanned = false;
foreach (ParcelAccessEntry E in targetparcel.AccessBlackList)
@ -514,7 +512,7 @@ namespace SecondBotEvents.Commands
}
if (alreadyBanned == true)
{
return BasicReply("Avatar is in the blacklist", new [] { avatar });
return BasicReply("Avatar is in the blacklist", [avatar]);
}
ParcelAccessEntry entry = new()
{
@ -524,7 +522,7 @@ namespace SecondBotEvents.Commands
};
targetparcel.AccessBlackList.Add(entry);
targetparcel.Update(GetClient());
return BasicReply("ok", new [] { avatar });
return BasicReply("ok", [avatar]);
}
[About("Unbans an avatar from a parcel")]
@ -539,12 +537,12 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { avatar });
return Failure(tests.Value, [avatar]);
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar", new [] { avatar });
return Failure("Invaild avatar", [avatar]);
}
bool alreadyBanned = false;
ParcelAccessEntry removeentry = new();
@ -559,11 +557,11 @@ namespace SecondBotEvents.Commands
}
if (alreadyBanned == false)
{
return BasicReply("Avatar is already unbanned", new [] { avatar });
return BasicReply("Avatar is already unbanned", [avatar]);
}
targetparcel.AccessBlackList.Remove(removeentry);
targetparcel.Update(GetClient());
return BasicReply("ok", new [] { avatar });
return BasicReply("ok", [avatar]);
}
@ -577,10 +575,10 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { musicurl });
return Failure(tests.Value, [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")]
@ -598,13 +596,13 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
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();
acceptablewords.AddRange(new[] { "True", "False" });
acceptablewords.AddRange(["True", "False"]);
Dictionary<string, bool> setflags = new();
Dictionary<string, bool> setflags = [];
string[] args = escapedflagdata.Split(":::");
foreach (string a in args)
{
@ -627,11 +625,11 @@ namespace SecondBotEvents.Commands
}
if (setflags.Count == 0)
{
return Failure("No accepted flags", new [] { escapedflagdata });
return Failure("No accepted flags", [escapedflagdata]);
}
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)
{
@ -641,7 +639,7 @@ namespace SecondBotEvents.Commands
}
}
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")]
@ -655,15 +653,15 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { avatar });
return Failure(tests.Value, [avatar]);
}
ProcessAvatar(avatar);
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 });
return BasicReply("ok", new [] { avatar });
GetClient().Parcels.ReturnObjects(GetClient().Network.CurrentSim, targetparcel.LocalID, ObjectReturnType.None, [avataruuid]);
return BasicReply("ok", [avatar]);
}
@ -679,22 +677,22 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { group });
return Failure(tests.Value, [group]);
}
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)
{
return Failure("Not in group", new [] { group });
return Failure("Not in group", [group]);
}
ParcelStatic.ParcelSetFlag(ParcelFlags.AllowDeedToGroup, targetparcel, true);
targetparcel.GroupID = groupuuid;
targetparcel.Update(GetClient());
Thread.Sleep(500);
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!")]
@ -712,11 +710,11 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
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))
{
return Failure("Parcel sale locked to other avatars", new[] { amount });
return Failure("Parcel sale locked to other avatars", [amount]);
}
int minAmount = 1;
if (targetparcel.AuthBuyerID == GetClient().Self.AgentID)
@ -725,22 +723,22 @@ namespace SecondBotEvents.Commands
}
if (int.TryParse(amount, out int amountvalue) == false)
{
return Failure("Invaild amount", new [] { amount });
return Failure("Invaild amount", [amount]);
}
if (amountvalue < minAmount)
{
return Failure("Invaild amount", new [] { amount });
return Failure("Invaild amount", [amount]);
};
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)
{
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);
return BasicReply("ok", new [] { amount });
return BasicReply("ok", [amount]);
}
[About("Freezes an avatar")]
@ -753,15 +751,15 @@ namespace SecondBotEvents.Commands
{
if (bool.TryParse(state, out bool freezestate) == false)
{
return Failure("Invaild state", new [] { avatar, state });
return Failure("Invaild state", [avatar, state]);
}
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar UUID", new [] { avatar, state });
return Failure("Invaild avatar UUID", [avatar, state]);
}
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)
{
return Failure("Invaild object uuid", new [] { objectuuid });
return Failure("Invaild object uuid", [objectuuid]);
}
bool found = false;
Dictionary<uint, Primitive> objects_copy = GetClient().Network.CurrentSim.ObjectsPrimitives.Copy();
@ -830,9 +828,9 @@ namespace SecondBotEvents.Commands
}
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" +
@ -854,7 +852,7 @@ namespace SecondBotEvents.Commands
KeyValuePair<bool, string> tests = SetupCurrentParcel();
if (tests.Key == false)
{
return Failure(tests.Value, new [] { escapedflagdata });
return Failure(tests.Value, [escapedflagdata]);
}
string[] args = escapedflagdata.Split(":::");
foreach (string A in args)
@ -915,7 +913,7 @@ namespace SecondBotEvents.Commands
}
}
targetparcel.Update(GetClient());
return BasicReply("ok", new [] { escapedflagdata });
return BasicReply("ok", [escapedflagdata]);
}
protected static bool UpdateParcelMediaType(Parcel targetparcel, string value)
@ -952,7 +950,7 @@ namespace SecondBotEvents.Commands
public class GetParcelBanlistObject
{
public Dictionary<UUID, string> entrys = new();
public Dictionary<UUID, string> entrys = [];
public string parcelName = "";
public string regionName = "";
public int delay = 0;

View file

@ -7,12 +7,8 @@ using System.Linq;
namespace SecondBotEvents.Commands
{
[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)")]
[ReturnHints("sending")]
[ReturnHintsFailure("Send was rejected because: X")]
@ -57,7 +53,7 @@ namespace SecondBotEvents.Commands
{
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);
GetClient().Self.Stand();
@ -66,7 +62,7 @@ namespace SecondBotEvents.Commands
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.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)")]
@ -88,11 +84,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Value is empty", new[] { Key, Value });
return Failure("Value is empty", [Key, Value]);
}
master.DataStoreService.SetKeyValue(Key, Value);
return BasicReply("ok");
@ -106,7 +102,7 @@ namespace SecondBotEvents.Commands
{
if (SecondbotHelpers.isempty(Key) == false)
{
return Failure("Key is empty", new[] { Key });
return Failure("Key is empty", [Key]);
}
master.DataStoreService.ClearKeyValue(Key);
return BasicReply("ok");
@ -121,14 +117,14 @@ namespace SecondBotEvents.Commands
if ((target == "ground") || (target == UUID.Zero.ToString()))
{
GetClient().Self.SitOnGround();
return BasicReply("ok", new [] { target });
return BasicReply("ok", [target]);
}
if(UUID.TryParse(target,out UUID objectuuid) == false)
{
return Failure("Invaild object uuid and not ground");
}
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)")]
@ -150,7 +146,7 @@ namespace SecondBotEvents.Commands
{
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"));
@ -167,7 +163,7 @@ namespace SecondBotEvents.Commands
break;
}
}
return BasicReply(found_object.ToString(), new [] { target });
return BasicReply(found_object.ToString(), [target]);
}
[About("Makes the bot kill itself you monster")]
@ -183,7 +179,7 @@ namespace SecondBotEvents.Commands
[ReturnHints("list of commands")]
public object GetLastCommands()
{
List<string> reply = new List<string>();
List<string> reply = [];
foreach(CommandHistory A in master.DataStoreService.GetCommandHistory())
{
reply.Add(JsonConvert.SerializeObject(A));
@ -192,7 +188,7 @@ namespace SecondBotEvents.Commands
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 " +
@ -215,30 +211,28 @@ namespace SecondBotEvents.Commands
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("avatar lookup", new [] { avatar, flag, state, sticky });
return Failure("avatar lookup", [avatar, flag, state, sticky]);
}
bool stateflag = false;
bool stickyflag = false;
if(bool.TryParse(state,out stateflag) == false)
if (bool.TryParse(state, out bool 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)
{
return Failure("Invaild flag", new [] { avatar, flag, state, sticky });
return Failure("Invaild flag", [avatar, flag, state, sticky]);
}
if (stateflag == true)
{
// @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
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/>" +
"RelayService<br/>" +
"ChatGptService")]
public class Services : CommandsAPI
public class Services(EventsSecondBot setmaster) : CommandsAPI(setmaster)
{
public Services(EventsSecondBot setmaster) : base(setmaster)
{
}
protected List<string> controlable = new List<string> {
protected List<string> controlable = [
"BotClientService",
"RLVService",
"HttpService",
@ -37,7 +33,7 @@ namespace SecondBotEvents.Commands
"TriggerOnEventService",
"RelayService",
"ChatGptService"
};
];
[About("Marks a service as enabled and starts it")]
[ReturnHints("ok")]

View file

@ -7,13 +7,8 @@ using System;
namespace SecondBotEvents.Commands
{
[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")]
[ReturnHints("True|False")]
[ReturnHintsFailure("Bad reply: ...")]
@ -28,11 +23,11 @@ namespace SecondBotEvents.Commands
{
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)
{
return Failure("Endpointcode is empty", new [] { endpoint, endpointcode });
return Failure("Endpointcode is empty", [endpoint, endpointcode]);
}
string attempt_endpoint = endpoint + "sys.php";
@ -48,34 +43,34 @@ namespace SecondBotEvents.Commands
RestResponse endpoint_checks = client.ExecutePostAsync(request).Result;
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
{
NotecardEndpoint server_reply = JsonConvert.DeserializeObject<NotecardEndpoint>(endpoint_checks.Content);
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)
{
return Failure("Notecard title is to short", new [] { endpoint, endpointcode });
return Failure("Notecard title is to short", [endpoint, endpointcode]);
}
ProcessAvatar(server_reply.AvatarUUID);
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);
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");
}
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
{
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()
{
filename = "basic";

View file

@ -5,9 +5,8 @@ using System.Text;
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()
{
filename = "chatgpt";

View file

@ -5,9 +5,8 @@ using System.Linq;
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()
{
filename = "commands";
@ -22,8 +21,15 @@ namespace SecondBotEvents.Config
settings.Add("Enabled");
settings.Add("ObjectMasterOptout");
settings.Add("AllowServiceControl");
settings.Add("CommandHistoryLogResults");
settings.Add("HideStatusOutput");
}
public bool GetCommandHistoryLogResults()
{
return ReadSettingAsBool("CommandHistoryLogResults", false);
}
public bool GetAllowServiceControl()
{
return ReadSettingAsBool("AllowServiceControl", false);

View file

@ -4,10 +4,8 @@ using System.Text;
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()
{
filename = "customcommands";

View file

@ -4,9 +4,8 @@ using System.Text;
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()
{
filename = "datastore";
@ -24,6 +23,7 @@ namespace SecondBotEvents.Config
settings.Add("HideStatusOutput");
}
public int GetCommandHistoryLimit()
{
return ReadSettingAsInt("CommandHistoryLimit", 30);

View file

@ -5,9 +5,8 @@ using System.Text;
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()
{
filename = "dialogrelay";

View file

@ -4,9 +4,8 @@ using System.Text;
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()
{
filename = "discord";

View file

@ -5,9 +5,8 @@ using System.Text;
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()
{
filename = "events";

View file

@ -5,9 +5,8 @@ using System.Text;
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()
{
filename = "homebound";

View file

@ -4,9 +4,8 @@ using System.Text;
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()
{
filename = "http";

View file

@ -4,9 +4,8 @@ using System.Text;
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()
{
filename = "interaction";

View file

@ -6,9 +6,8 @@ using System.Text;
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()
{
filename = "onevent";

View file

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

View file

@ -4,9 +4,8 @@ using System.Text;
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()
{
filename = "smtp";

View file

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

View file

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

View file

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

View file

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

View file

@ -49,7 +49,7 @@ namespace SecondBotEvents.Services
{
try
{
ConfigurationOptions configRedis = new ConfigurationOptions()
ConfigurationOptions configRedis = new()
{
EndPoints = { myConfig.GetRedisSource() }
};
@ -120,7 +120,7 @@ namespace SecondBotEvents.Services
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)
{
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, long> ChatHistoryLastAccessed = new Dictionary<UUID, long>();
Dictionary<UUID, long> ChatRateLimiter = new Dictionary<UUID, long>();
Dictionary<UUID, List<KeyValuePair<string, string>>> chatHistoryAI = [];
Dictionary<UUID, long> ChatHistoryLastAccessed = [];
Dictionary<UUID, long> ChatRateLimiter = [];
protected long lastUpkeep = 0;
protected void upkeep()
@ -236,7 +236,7 @@ namespace SecondBotEvents.Services
// check for expired chat windows (longer than 2 mins from last message)
lock (ChatHistoryLastAccessed) lock (chatHistoryAI) lock (ChatRateLimiter)
{
List<UUID> needcleaning = new List<UUID>();
List<UUID> needcleaning = [];
long now = SecondbotHelpers.UnixTimeNow();
foreach (KeyValuePair<UUID, long> entry in ChatHistoryLastAccessed)
{
@ -292,7 +292,7 @@ namespace SecondBotEvents.Services
// are we using redis?
if (RedisLive() == false)
{
return new List<KeyValuePair<string, string>>();
return [];
}
// is redis enabled for this message type?
if ((myConfig.GetRedisImchat() == true) && (avatarchat == true))
@ -311,7 +311,7 @@ namespace SecondBotEvents.Services
return ReadChatFromRedis(store);
}
// 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
{
RedisKey readkey = new RedisKey(myConfig.GetRedisPrefix() + store.Guid.ToString());
RedisKey readkey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
if (redisDb.KeyExists(readkey) == false)
{
string rawstring = redisDb.StringGet(readkey);
@ -343,7 +343,7 @@ namespace SecondBotEvents.Services
{
if (chatHistoryAI.ContainsKey(store) == false)
{
return new List<KeyValuePair<string, string>>();
return [];
}
return chatHistoryAI[store];
}
@ -363,7 +363,7 @@ namespace SecondBotEvents.Services
if (chatHistoryAI.ContainsKey(store) == false)
{
// totaly new chat build it out
chatHistoryAI.Add(store, new List<KeyValuePair<string, string>>());
chatHistoryAI.Add(store, []);
string yourname = GetClient().Self.FirstName;
if (myConfig.GetCustomName() != "<!FIRSTNAME!>")
{
@ -437,7 +437,7 @@ namespace SecondBotEvents.Services
{
history.RemoveAt(1);
}
RedisKey writekey = new RedisKey(myConfig.GetRedisPrefix() + store.Guid.ToString());
RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
try
{
string savestring = JsonConvert.SerializeObject(history);
@ -446,7 +446,7 @@ namespace SecondBotEvents.Services
LogFormater.Warn("Redis failed to convert history into savable format");
return false;
}
RedisValue storeme = new RedisValue(savestring);
RedisValue storeme = new(savestring);
if(redisDb.StringSet(writekey, storeme) == true)
{
return redisDb.KeyExpire(writekey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins()));
@ -506,7 +506,7 @@ namespace SecondBotEvents.Services
{
ChatRateLimiter[user] = SecondbotHelpers.UnixTimeNow() + 1;
}
List<ChatMessage> messages = new List<ChatMessage>();
List<ChatMessage> messages = [];
lock (chatHistoryAI) lock (ChatHistoryLastAccessed)
{
// 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)
{

View file

@ -13,19 +13,13 @@ using System.ComponentModel.DataAnnotations;
namespace SecondBotEvents.Services
{
public class BotCommandNotice
public class BotCommandNotice(string Setcommand, string Setargs, string Setsource, bool Setaccepted, string Setresults)
{
public string command;
public string args;
public string source;
public bool accepted;
public BotCommandNotice(string Setcommand, string Setargs, string Setsource, bool Setaccepted)
{
command = Setcommand;
args = Setargs;
source = Setsource;
accepted = Setaccepted;
}
public string command = Setcommand;
public string args = Setargs;
public string source = Setsource;
public bool accepted = Setaccepted;
public string results = Setresults;
}
public class CommandsService : BotServices
{
@ -35,10 +29,10 @@ namespace SecondBotEvents.Services
add { 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 CommandsService(EventsSecondBot setMaster) : base(setMaster)
{
@ -66,7 +60,7 @@ namespace SecondBotEvents.Services
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);
foreach (MethodInfo M in endpointtype.GetMethods())
{
@ -221,7 +215,7 @@ namespace SecondBotEvents.Services
{
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)
{
return new KeyValuePair<bool, string>(false, "Not accepted via signing");
@ -276,8 +270,8 @@ namespace SecondBotEvents.Services
}
else if (mode == "HTTP")
{
Dictionary<string, string> values = new Dictionary<string, string>
{
Dictionary<string, string> values = new()
{
{ "reply", output },
{ "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)
{
@ -311,10 +305,10 @@ namespace SecondBotEvents.Services
MethodInfo theMethod = Endpoint.GetType().GetMethod(C.command);
if (theMethod != null)
{
List<string> argsList = C.args.ToList();
string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Count().ToString() + " but got: " + argsList.Count.ToString();
List<string> argsList = [.. C.args];
string reply = "Inconnect number of args expected: " + theMethod.GetParameters().Length.ToString() + " but got: " + argsList.Count.ToString();
bool status = false;
if (argsList.Count == theMethod.GetParameters().Count())
if (argsList.Count == theMethod.GetParameters().Length)
{
status = true;
try
@ -323,23 +317,23 @@ namespace SecondBotEvents.Services
{
return new KeyValuePair<bool, string>(false, "Endpoint is null");
}
object[] argsWorker = argsList.ToArray<object>();
object[] argsWorker = [.. argsList];
object processed = theMethod.Invoke(Endpoint, argsWorker);
reply = "Error";
if (processed != null)
{
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);
}
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);
}
}
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>(false, "theMethod is null");
@ -392,17 +386,17 @@ namespace SecondBotEvents.Services
public string[] GetFullListOfCommands()
{
List<string> output = new List<string>();
List<string> output = [];
foreach (string A in endpointcommandmap.Keys)
{
output.Add(A.ToLowerInvariant());
}
return output.ToArray();
return [.. output];
}
protected Dictionary<string, CommandsAPI> commandEndpoints = new Dictionary<string, CommandsAPI>();
protected Dictionary<string, string> endpointcommandmap = new Dictionary<string, string>(); // command = endpoint
protected Dictionary<string, string> commandnameLowerToReal = new Dictionary<string, string>();
protected Dictionary<string, CommandsAPI> commandEndpoints = [];
protected Dictionary<string, string> endpointcommandmap = []; // command = endpoint
protected Dictionary<string, string> commandnameLowerToReal = [];
protected void BotClientRestart(object o, BotClientNotice e)
{
@ -440,9 +434,13 @@ namespace SecondBotEvents.Services
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;
handler?.Invoke(this, e);
if(master.BotClient.basicCfg.GetLogCommands() == true)
@ -561,7 +559,7 @@ namespace SecondBotEvents.Services
command = bits[0];
// command
// args~#~args~#~args
args = new string[] { };
args = [];
if(bits.Length == 2)
{
args = bits[1].Split("~#~");

View file

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

View file

@ -13,7 +13,7 @@ namespace SecondBotEvents.Services
{
protected new CustomCommandsConfig myConfig;
protected bool botConnected = false;
protected Dictionary<string, CustomCommand> commands = new Dictionary<string, CustomCommand>();
protected Dictionary<string, CustomCommand> commands = [];
public bool HasCommand(string C)
{
return commands.ContainsKey(C);
@ -57,9 +57,11 @@ namespace SecondBotEvents.Services
int loop = 1;
while(loop <= myConfig.GetCount())
{
CustomCommand C = new CustomCommand();
C.trigger = myConfig.GetCommandTrigger(loop);
C.args = myConfig.GetCommandArgs(loop);
CustomCommand C = new()
{
trigger = myConfig.GetCommandTrigger(loop),
args = myConfig.GetCommandArgs(loop)
};
int loop2 = 1;
while(loop2 <= myConfig.GetCommandSteps(loop))
{
@ -127,6 +129,6 @@ namespace SecondBotEvents.Services
{
public string trigger = "";
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);
}
protected Dictionary<string, UUID> avatarsName2Key = new();
protected Dictionary<UUID, long> avatarLastUsed = new();
protected Dictionary<string, UUID> avatarsName2Key = [];
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, Dictionary<UUID, GroupRole>> groupRoles = new();
protected Dictionary<UUID, List<UUID>> groupMembers = [];
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, bool> chatWindowsUnread = new(); // sess, bool
protected Dictionary<UUID, bool> chatWindowsIsGroup = new(); // sess, bool
protected Dictionary<UUID, UUID> chatWindowsOwner = new(); // sess, owner id
protected Dictionary<UUID, List<string>> chatWindows = []; // sess, list chat
protected Dictionary<UUID, bool> chatWindowsUnread = []; // sess, bool
protected Dictionary<UUID, bool> chatWindowsIsGroup = []; // sess, bool
protected Dictionary<UUID, UUID> chatWindowsOwner = []; // sess, owner id
protected Dictionary<string, string> KeyValueStore = new();
protected Dictionary<string, long> KeyValueStoreLastUsed = new();
protected Dictionary<string, string> KeyValueStore = [];
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 lastCleanupAvatarStore = 0;
protected List<string> acceptedStores = new List<string>() { "FriendRequest", "InventoryOffer", "GroupInvite", "Teleport" };
protected Dictionary<string, List<UUID>> AcceptNextStore = new Dictionary<string, List<UUID>>();
protected List<string> acceptedStores = ["FriendRequest", "InventoryOffer", "GroupInvite", "Teleport"];
protected Dictionary<string, List<UUID>> AcceptNextStore = [];
public bool KnownStoreType(string storeType)
{
return acceptedStores.Contains(storeType);
@ -82,7 +82,7 @@ namespace SecondBotEvents.Services
}
if(AcceptNextStore.ContainsKey(store) == false)
{
AcceptNextStore.Add(store, new List<UUID>());
AcceptNextStore.Add(store, []);
}
if(AcceptNextStore[store].Contains(avatar) == true)
{
@ -155,7 +155,7 @@ namespace SecondBotEvents.Services
if (dif > 125)
{
lastCleanupKeyValueStore = unixtime;
List<string> clearentrys = new();
List<string> clearentrys = [];
foreach (KeyValuePair<string, long> entry in KeyValueStoreLastUsed)
{
dif = unixtime - entry.Value;
@ -185,7 +185,7 @@ namespace SecondBotEvents.Services
if (dif > 75)
{
lastCleanupAvatarStore = unixtime;
Dictionary<UUID, string> clearLinks = new();
Dictionary<UUID, string> clearLinks = [];
foreach (KeyValuePair<string, UUID> entry in avatarsName2Key)
{
dif = unixtime - avatarLastUsed[entry.Value];
@ -212,11 +212,11 @@ namespace SecondBotEvents.Services
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)
{
CommandHistory A = new(status, command, args, SecondbotHelpers.UnixTimeNow());
CommandHistory A = new(status, command, args, SecondbotHelpers.UnixTimeNow(), results);
commandHistories.Add(A);
int c = commandHistories.Count;
while (c > myConfig.GetCommandHistoryLimit())
@ -290,7 +290,7 @@ namespace SecondBotEvents.Services
public List<UUID> GetAllGroupsChatWithUnread()
{
List<UUID> reply = new();
List<UUID> reply = [];
foreach(KeyValuePair<UUID, bool> windowState in chatWindowsUnread)
{
if(windowState.Value == false)
@ -338,7 +338,7 @@ namespace SecondBotEvents.Services
{
if(chatWindows.ContainsKey(group) == false)
{
return new List<string>();
return [];
}
chatWindowsUnread[group] = false;
return chatWindows[group];
@ -364,7 +364,7 @@ namespace SecondBotEvents.Services
public Dictionary<UUID, string> GetGroupRoles(UUID group)
{
Dictionary<UUID, string> reply = new();
Dictionary<UUID, string> reply = [];
if (groupRoles.ContainsKey(group) == false)
{
@ -401,7 +401,7 @@ namespace SecondBotEvents.Services
{
if (groupMembers.ContainsKey(group) == false)
{
groupMembers.Add(group, new List<UUID>());
groupMembers.Add(group, []);
}
if (groupMembers[group].Contains(avatar) == false)
{
@ -439,7 +439,7 @@ namespace SecondBotEvents.Services
{
if (groupMembers.ContainsKey(Group) == false)
{
groupMembers.Add(Group, new List<UUID>());
groupMembers.Add(Group, []);
}
}
return groupMembers[Group];
@ -544,7 +544,7 @@ namespace SecondBotEvents.Services
}
return; // chat recovered
}
chatWindows.Add(sessionID, new List<string>());
chatWindows.Add(sessionID, []);
chatWindowsUnread.Add(sessionID, false);
chatWindowsIsGroup.Add(sessionID, group);
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()
{
@ -593,7 +593,7 @@ namespace SecondBotEvents.Services
if (currentHash != ObjectsAvatarsHash)
{
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)
{
AddAvatar(A.ID, A.Name);
@ -662,7 +662,7 @@ namespace SecondBotEvents.Services
public void GetAvatarNames(List<UUID> avatars)
{
List<UUID> lookup = new();
List<UUID> lookup = [];
foreach (UUID id in avatars)
{
if (avatarsName2Key.ContainsValue(id) == false)
@ -715,7 +715,7 @@ namespace SecondBotEvents.Services
public Dictionary<UUID,string> GetAvatarImWindows()
{
Dictionary<UUID, string> windows = new();
Dictionary<UUID, string> windows = [];
foreach (KeyValuePair<UUID,bool> links in chatWindowsIsGroup)
{
if(links.Value == true)
@ -735,7 +735,7 @@ namespace SecondBotEvents.Services
{
if (chatWindowsOwner.ContainsValue(avatarId) == false)
{
return new List<string>();
return [];
}
UUID sessionID = UUID.Zero;
foreach (KeyValuePair<UUID, UUID> links in chatWindowsOwner)
@ -748,7 +748,7 @@ namespace SecondBotEvents.Services
}
if(chatWindowsIsGroup[sessionID] == true)
{
return new List<string>();
return [];
}
chatWindowsUnread[sessionID] = false;
return chatWindows[sessionID];
@ -780,7 +780,7 @@ namespace SecondBotEvents.Services
public List<UUID> GetAvatarImWindowsUnread()
{
List<UUID> windows = new();
List<UUID> windows = [];
foreach (KeyValuePair<UUID, bool> links in chatWindowsIsGroup)
{
if (links.Value == true)
@ -819,23 +819,23 @@ namespace SecondBotEvents.Services
{
lastCleanupKeyValueStore = 0;
avatarsName2Key = new Dictionary<string, UUID>();
avatarsName2Key = [];
groupsKey2Name = new Dictionary<UUID, string>();
groupsKey2Name = [];
groupMembers = new Dictionary<UUID, List<UUID>>();
groupRoles = new Dictionary<UUID, Dictionary<UUID, GroupRole>>();
groupMembers = [];
groupRoles = [];
localChatHistory = new List<string>();
localChatHistory = [];
notecardDataStore = new Dictionary<string, KeyValuePair<string, long>>();
notecardDataStore = [];
chatWindows = new Dictionary<UUID, List<string>>(); // sess, list chat
chatWindowsUnread = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsIsGroup = new Dictionary<UUID, bool>(); // sess, bool
chatWindowsOwner = new Dictionary<UUID, UUID>(); // sess, owner id
chatWindows = []; // sess, list chat
chatWindowsUnread = []; // sess, bool
chatWindowsIsGroup = []; // sess, bool
chatWindowsOwner = []; // sess, owner id
estateBanlist = new List<UUID>();
estateBanlist = [];
}
@ -864,7 +864,7 @@ namespace SecondBotEvents.Services
{
if (groupRoles.ContainsKey(e.GroupID) == false)
{
groupRoles.Add(e.GroupID, new Dictionary<UUID, GroupRole>());
groupRoles.Add(e.GroupID, []);
}
groupRoles[e.GroupID] = e.Roles;
}
@ -878,7 +878,7 @@ namespace SecondBotEvents.Services
{
groupMembers.Remove(e.GroupID);
}
groupMembers.Add(e.GroupID, new List<UUID>());
groupMembers.Add(e.GroupID, []);
foreach (KeyValuePair<UUID, GroupMember> a in e.Members)
{
groupMembers[e.GroupID].Add(a.Value.ID);
@ -890,7 +890,7 @@ namespace SecondBotEvents.Services
{
if (estateBanlist == null)
{
List<UUID> reply = new();
List<UUID> reply = [];
AutoResetEvent fetchEvent = new(false);
void callback(object sender, EstateBansReplyEventArgs e)
{
@ -907,8 +907,8 @@ namespace SecondBotEvents.Services
return estateBanlist;
}
List<UUID> estateBanlist = null;
Dictionary<UUID, FriendLocations> FriendMapLocations = new Dictionary<UUID, FriendLocations>();
protected List<UUID> estateBanlist = null;
protected Dictionary<UUID, FriendLocations> FriendMapLocations = [];
public FriendLocations GetFriendMap(UUID id)
{
@ -921,8 +921,7 @@ namespace SecondBotEvents.Services
protected void FindFriendReply(object o, FriendFoundReplyEventArgs e)
{
uint x, y;
Utils.LongToUInts(e.RegionHandle, out x, out y);
Utils.LongToUInts(e.RegionHandle, out uint x, out uint y);
x /= 256;
y /= 256;
Dictionary<UUID, FriendInfo> FriendListCopy = GetClient().Friends.FriendList.Copy();
@ -930,7 +929,7 @@ namespace SecondBotEvents.Services
{
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)
{
FriendMapLocations.Add(e.AgentID, NewEntry);
@ -955,12 +954,12 @@ namespace SecondBotEvents.Services
Task.Factory.StartNew(() =>
{
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)
{
if (avprops.ContainsKey(agentID) == false)
@ -980,7 +979,7 @@ namespace SecondBotEvents.Services
avprops[e.AvatarID] = e.Properties;
}
protected void attachEventsAfterDelay()
protected void AttachEventsAfterDelay()
{
GetClient().Groups.CurrentGroups += GroupCurrent;
GetClient().Groups.GroupJoinedReply += GroupJoin;
@ -996,9 +995,9 @@ namespace SecondBotEvents.Services
GetClient().Friends.FriendFoundReply += FindFriendReply;
GetClient().Avatars.AvatarPropertiesReply += AvatarDetailsReply;
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)
{
switch(e.Type)
@ -1046,7 +1045,7 @@ namespace SecondBotEvents.Services
{
lock (groupsKey2Name)
{
List<UUID> missingGroups = groupsKey2Name.Keys.ToList();
List<UUID> missingGroups = [.. groupsKey2Name.Keys];
foreach (Group G in e.Groups.Values)
{
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[] Args = Array.Empty<string>();
public long Unixtime = 0;
public bool status = false;
public CommandHistory(bool setStatus, string setCommand, string[] setArgs, long setUnixtime)
{
status = setStatus;
Command = setCommand;
Args = setArgs;
Unixtime = setUnixtime;
}
public string Command = setCommand;
public string[] Args = setArgs;
public long Unixtime = setUnixtime;
public bool status = setStatus;
public string results = Setresults;
}
public class FriendLocations
public class FriendLocations(string SetName, Vector3 setPos, Vector3 setRegionPos)
{
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;
}
public string Name = SetName;
public Vector3 Pos = setPos;
public Vector3 RegionPos = setRegionPos;
public long time = SecondbotHelpers.UnixTimeNow();
}
}

View file

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

View file

@ -89,7 +89,7 @@ namespace SecondBotEvents.Services
return Task.CompletedTask;
}
private readonly object m_discordEventChatLock = new object();
private readonly object m_discordEventChatLock = new();
private EventHandler<SocketMessage> m_discordChatEvent;
/// <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)
{
// 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)
{
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)
{
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);
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);
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)
{
roleids.Add(role.Id.ToString());
@ -132,7 +132,7 @@ namespace SecondBotEvents.Services
return new KeyValuePair<bool, List<string>>(true, roleids);
}
protected HttpClient HTTPclient = new HttpClient();
protected HttpClient HTTPclient = new();
protected bool MessageInteractionEvent(SocketMessage message, SocketChannel socketChannel)
{
if (myConfig.GetInteractionEnabled() != true)
@ -155,8 +155,8 @@ namespace SecondBotEvents.Services
string getmessage = message.Content.Replace(myConfig.GetInteractionCommandName(), "");
long unixtime = SecondbotHelpers.UnixTimeNow();
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 },
{ "username", message.Author.Username },
{ "userid", message.Author.Id.ToString() },
@ -310,8 +310,7 @@ namespace SecondBotEvents.Services
{
// handle group notice
// !notice {Title}@@@{Message}[@@@{Inventory UUID}]
List<string> args = new List<string>();
args.Add(groupuuid.ToString());
List<string> args = [groupuuid.ToString()];
cleaned = cleaned.Replace("!notice ", "");
bits = cleaned.Split("@@@", StringSplitOptions.RemoveEmptyEntries);
args.AddRange(bits);
@ -321,10 +320,10 @@ namespace SecondBotEvents.Services
ReplyToMessage(message, "Notices require title and a message split with @@@!");
return;
}
SignedCommand C = new SignedCommand(
SignedCommand C = new(
master.CommandsService,
"discordapi",
"Groupnotice", null, args.ToArray(), 0, "none", false, 0, "", false);
"Groupnotice", null, [.. args], 0, "none", false, 0, "", false);
if (bits.Length == 3)
{
C.command = "GroupnoticeWithAttachment";
@ -336,35 +335,27 @@ namespace SecondBotEvents.Services
{
// handle group eject
cleaned = cleaned.Replace("!eject ", "");
List<string> args = new List<string>();
args.Add(groupuuid.ToString());
args.Add(cleaned);
List<string> args = [groupuuid.ToString(), cleaned];
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;
}
else if(cleaned.StartsWith("!invite") == true)
{
// hangle group invite
cleaned = cleaned.Replace("!invite ", "");
List<string> args = new List<string>();
args.Add(groupuuid.ToString());
args.Add(cleaned);
args.Add("everyone");
List<string> args = [groupuuid.ToString(), cleaned, "everyone"];
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;
}
else if(cleaned.StartsWith("!ban") == true)
{
// hangle group ban
cleaned = cleaned.Replace("!ban ", "");
List<string> args = new List<string>();
args.Add(groupuuid.ToString());
args.Add(cleaned);
args.Add("true");
List<string> args = [groupuuid.ToString(), cleaned, "true"];
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;
}
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}";
}
protected Dictionary<string, ulong> ChannelMap = new Dictionary<string, ulong>();
protected Dictionary<string, ulong> CategoryMap = new Dictionary<string, ulong>();
protected Dictionary<string, ulong> ChannelMap = [];
protected Dictionary<string, ulong> CategoryMap = [];
protected async void DoServerChannelSetup()
{
LogFormater.Info("Setting up channels");
LoginEvents();
Dictionary<string, string> WantedTextChannels = new Dictionary<string, string>
Dictionary<string, string> WantedTextChannels = new()
{
{ "status", StatusPrefill() },
{ "commands", "Send a command to the bot as if you are a master" },
{ "localchat", LocalChatPrefill() }
};
ChannelMap = new Dictionary<string, ulong>();
ChannelMap = [];
SocketGuild server = DiscordClient.GetGuild(myConfig.GetServerID());
foreach (ITextChannel channel in server.TextChannels)
@ -750,12 +741,12 @@ namespace SecondBotEvents.Services
}
List<string> WantedCategoryChannels = new List<string>
{
List<string> WantedCategoryChannels =
[
"bot",
"im",
"group"
};
];
foreach (ICategoryChannel category in server.CategoryChannels)
{
if (WantedCategoryChannels.Contains(category.Name) == false)
@ -834,7 +825,7 @@ namespace SecondBotEvents.Services
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)
{
switch (e.Type)
@ -1093,10 +1084,10 @@ namespace SecondBotEvents.Services
{
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);
Dictionary<string, string> textChannels = new Dictionary<string, string>();
Dictionary<string, string> textChannels = [];
foreach (SocketTextChannel channel in server.TextChannels)
{
textChannels.Add(channel.Id.ToString(), channel.Name);
@ -1124,10 +1115,10 @@ namespace SecondBotEvents.Services
{
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);
Dictionary<string, string> rolesList = new Dictionary<string, string>();
Dictionary<string, string> rolesList = [];
foreach (SocketRole role in server.Roles)
{
rolesList.Add(role.Id.ToString(), role.Name);
@ -1282,17 +1273,17 @@ namespace SecondBotEvents.Services
{
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)
{
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);
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 },
{ "Info|AssignedCount", role.Members.ToString() },
{ "Perm|AttachFiles", role.Permissions.AttachFiles.ToString() },
@ -1388,11 +1379,11 @@ namespace SecondBotEvents.Services
{
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);
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)
{
@ -1454,13 +1445,13 @@ namespace SecondBotEvents.Services
}
SocketGuild server = DiscordClient.GetGuild(serverid);
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;
justundertwosweeks = justundertwosweeks.Subtract(somedays);
long unixtimelimit = justundertwosweeks.ToUnixTimeSeconds();
foreach (SocketTextChannel channel in server.TextChannels)
{
List<IMessage> DeleteMessages = new List<IMessage>();
List<IMessage> DeleteMessages = [];
IEnumerable<IMessage> messages = await channel.GetMessagesAsync(100).FlattenAsync();
foreach (IMessage message in messages)
{

View file

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

View file

@ -77,7 +77,7 @@ namespace SecondBotEvents.Services
{
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)
{

View file

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

View file

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

View file

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

View file

@ -4,14 +4,10 @@ using System.Threading;
using Timer = System.Timers.Timer;
namespace SecondBotEvents.Services
{
public class RecoveryService : BotServices
public class RecoveryService(EventsSecondBot setMaster) : BotServices(setMaster)
{
protected Timer AutoRestartLoginTimer;
protected new BasicConfig myConfig;
public RecoveryService(EventsSecondBot setMaster) : base(setMaster)
{
myConfig = new BasicConfig(false);
}
protected new BasicConfig myConfig = new BasicConfig(false);
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);
}
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" };
readonly string[] hard_blocked_agents = ["secondlife", "second life"];
protected void LocalChat(object o, ChatEventArgs e)
{
@ -157,11 +157,13 @@ namespace SecondBotEvents.Services
return;
}
message = "{Relay} " + message;
relayEvent a = new relayEvent();
a.message = message;
a.name = name;
a.sourcetype = source;
a.sourceoption = filter;
relayEvent a = new()
{
message = message,
name = name,
sourcetype = source,
sourceoption = filter
};
string eventMessage = JsonConvert.SerializeObject(a);
while (loop <= myConfig.GetRelayCount())
{

View file

@ -6,15 +6,11 @@ using SecondBotEvents.Config;
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 bool running = false;
public BotServices(EventsSecondBot setMaster)
{
master = setMaster;
}
public void enableAndStart()
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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