diff --git a/LibreMetaverse/LibreMetaverse.csproj b/LibreMetaverse/LibreMetaverse.csproj
index 8c07b66..d983dec 100644
--- a/LibreMetaverse/LibreMetaverse.csproj
+++ b/LibreMetaverse/LibreMetaverse.csproj
@@ -29,12 +29,12 @@
-
+
-
+
diff --git a/SecondBotEvents/Commands/Avatars.cs b/SecondBotEvents/Commands/Avatars.cs
index ca49980..d3da313 100644
--- a/SecondBotEvents/Commands/Avatars.cs
+++ b/SecondBotEvents/Commands/Avatars.cs
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using OpenMetaverse;
-using Newtonsoft.Json;
+using System.Text.Json;
using SecondBotEvents.Services;
-using System.Threading.Tasks;
-using System.Linq;
namespace SecondBotEvents.Commands
{
@@ -16,7 +14,7 @@ namespace SecondBotEvents.Commands
[ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHintsFailure("Unknown store type")]
[ReturnHintsFailure("Unable to process request store")]
- [ArgHints("store", "What type of request to accept", "Text", "GroupInvite", new string[] { "FriendRequest", "InventoryOffer", "GroupInvite", "Teleport" })]
+ [ArgHints("store", "What type of request to accept", "Text", "GroupInvite", ["FriendRequest", "InventoryOffer", "GroupInvite", "Teleport"])]
[ArgHints("avatar", "Who to accept the request from", "AVATAR")]
[ArgHints("remove", "Should this remove the entry", "BOOL")]
[CmdTypeDo()]
@@ -47,7 +45,7 @@ namespace SecondBotEvents.Commands
[ReturnHints("false")]
[ReturnHintsFailure("Invaild avatar uuid")]
[ReturnHintsFailure("Unknown store type")]
- [ArgHints("store", "What type of request to accept", "Text", "GroupInvite", new string[] { "FriendRequest", "InventoryOffer", "GroupInvite", "Teleport" })]
+ [ArgHints("store", "What type of request to accept", "Text", "GroupInvite", ["FriendRequest", "InventoryOffer", "GroupInvite", "Teleport"])]
[ArgHints("avatar", "Who to accept the request from", "AVATAR")]
[CmdTypeDo()]
public Object IsOnAcceptNext(string store, string avatar)
@@ -97,7 +95,7 @@ namespace SecondBotEvents.Commands
BetterNearMe.Add(details);
}
}
- return BasicReply(JsonConvert.SerializeObject(BetterNearMe));
+ return BasicReply(JsonSerializer.Serialize(BetterNearMe));
}
[About("Requests the given avatars profile image")]
@@ -230,7 +228,7 @@ namespace SecondBotEvents.Commands
NearMe.Add(av.ID, av.Name);
}
}
- return BasicReply(JsonConvert.SerializeObject(NearMe));
+ return BasicReply(JsonSerializer.Serialize(NearMe));
}
[About("searchs the AV database if not found triggers a lookup")]
@@ -241,12 +239,11 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object Key2Name(string uuid)
{
- UUID avUUID = UUID.Zero;
- if (UUID.TryParse(uuid, out avUUID) == false)
+ if (UUID.TryParse(uuid, out _) == false)
{
return Failure("Not a vaild UUID");
}
- return BasicReply(master.DataStoreService.GetAvatarName(avUUID));
+ return BasicReply(master.DataStoreService.GetAvatarName(UUID.Zero));
}
[About("searchs the AV database if not found triggers a lookup")]
diff --git a/SecondBotEvents/Commands/Chat.cs b/SecondBotEvents/Commands/Chat.cs
index 495b8b8..0269b6a 100644
--- a/SecondBotEvents/Commands/Chat.cs
+++ b/SecondBotEvents/Commands/Chat.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
@@ -12,7 +12,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object LocalChatHistory()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetLocalChat()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetLocalChat()));
}
[About("sends a message to localchat (Normal chat)")]
@@ -23,7 +23,7 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object Say(string channel, string message)
{
- if (SecondbotHelpers.isempty(message) == true)
+ if (SecondbotHelpers.IsEmpty(message) == true)
{
return Failure("Message empty", [channel, message]);
}
@@ -44,7 +44,7 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object Shout(string channel, string message)
{
- if (SecondbotHelpers.isempty(message) == true)
+ if (SecondbotHelpers.IsEmpty(message) == true)
{
return Failure("Message empty", [channel, message]);
}
@@ -65,7 +65,7 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object Whisper(string channel, string message)
{
- if (SecondbotHelpers.isempty(message) == true)
+ if (SecondbotHelpers.IsEmpty(message) == true)
{
return Failure("Message empty", [channel, message]);
}
@@ -94,7 +94,7 @@ namespace SecondBotEvents.Commands
{
return Failure("avatar lookup", [avatar, message]);
}
- if (SecondbotHelpers.isempty(message) == true)
+ if (SecondbotHelpers.IsEmpty(message) == true)
{
return Failure("Message empty", [avatar, message]);
}
@@ -108,7 +108,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object chatwindows()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAvatarImWindows()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindows()));
}
[About("gets a list of chat windows from avatars with unread messages")]
@@ -116,7 +116,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object listwithunread()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAvatarImWindowsUnread()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindowsUnread()));
}
[About("gets if there are any unread im messages from avatars at all")]
@@ -139,7 +139,7 @@ namespace SecondBotEvents.Commands
{
return Failure("avatar UUID invaild");
}
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAvatarImWindow(avatarUUID)));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindow(avatarUUID)));
}
}
diff --git a/SecondBotEvents/Commands/Discord.cs b/SecondBotEvents/Commands/Discord.cs
index 829a113..4260dc8 100644
--- a/SecondBotEvents/Commands/Discord.cs
+++ b/SecondBotEvents/Commands/Discord.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using SecondBotEvents.Services;
using System.Collections.Generic;
using System.Linq;
@@ -38,7 +38,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Discord client not ready");
}
- if (SecondbotHelpers.notempty(why) == false)
+ if (SecondbotHelpers.NotEmpty(why) == false)
{
return Failure("Why empty", [serverid, memberid, why]);
}
@@ -63,7 +63,7 @@ namespace SecondBotEvents.Commands
{
return Failure(reply.Value.First());
}
- return BasicReply(JsonConvert.SerializeObject(reply.Value));
+ return BasicReply(JsonSerializer.Serialize(reply.Value));
}
[About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")]
@@ -128,7 +128,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Discord client not ready");
}
- if (SecondbotHelpers.notempty(message) == false)
+ if (SecondbotHelpers.NotEmpty(message) == false)
{
return Failure("message empty", [serverid, channelid, tts, message]);
}
diff --git a/SecondBotEvents/Commands/Estate.cs b/SecondBotEvents/Commands/Estate.cs
index 6bdeb27..0b1c3a5 100644
--- a/SecondBotEvents/Commands/Estate.cs
+++ b/SecondBotEvents/Commands/Estate.cs
@@ -1,5 +1,5 @@
using EmbedIO;
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData;
@@ -372,7 +372,7 @@ namespace SecondBotEvents.Commands
}
string covenantText = covenantAssetRead.Value;
// Return the result as a JSON object, including the text
- return BasicReply(JsonConvert.SerializeObject(new
+ return BasicReply(JsonSerializer.Serialize(new
{
Fetched = covenantAssetRead.Key,
CovenantID = result.CovenantID.ToString(),
@@ -580,7 +580,7 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object SimMessage(string message)
{
- if (SecondbotHelpers.notempty(message) == false)
+ if (SecondbotHelpers.NotEmpty(message) == false)
{
return Failure("Message empty", [message]);
}
@@ -638,7 +638,7 @@ namespace SecondBotEvents.Commands
{ "X", region.X.ToString() },
{ "Y", region.Y.ToString() }
};
- return BasicReply(JsonConvert.SerializeObject(reply));
+ return BasicReply(JsonSerializer.Serialize(reply));
}
[About("Requests the estate banlist")]
@@ -646,7 +646,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object GetEstateBanList()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetEstateBans()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetEstateBans()));
}
[About("Attempts to add/remove the avatar to/from the Estate banlist")]
diff --git a/SecondBotEvents/Commands/Friends.cs b/SecondBotEvents/Commands/Friends.cs
index fda6aa6..6e20fc5 100644
--- a/SecondBotEvents/Commands/Friends.cs
+++ b/SecondBotEvents/Commands/Friends.cs
@@ -1,6 +1,6 @@
using OpenMetaverse;
using SecondBotEvents.Services;
-using Newtonsoft.Json;
+using System.Text.Json;
using System.Collections.Generic;
using System.Linq;
@@ -34,7 +34,7 @@ namespace SecondBotEvents.Commands
{
return Failure("no map access or updating", [avatar]);
}
- return BasicReply(JsonConvert.SerializeObject(loc), [avatar]);
+ return BasicReply(JsonSerializer.Serialize(loc), [avatar]);
}
[About("Gets the friendslist")]
@@ -56,7 +56,7 @@ namespace SecondBotEvents.Commands
CleanedFriendsList.Add(entry);
index++;
}
- return BasicReply(JsonConvert.SerializeObject(CleanedFriendsList));
+ return BasicReply(JsonSerializer.Serialize(CleanedFriendsList));
}
[About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]
diff --git a/SecondBotEvents/Commands/Funds.cs b/SecondBotEvents/Commands/Funds.cs
index b97c5a0..8260610 100644
--- a/SecondBotEvents/Commands/Funds.cs
+++ b/SecondBotEvents/Commands/Funds.cs
@@ -83,7 +83,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Amount out of range", [objectuuid, primname, amount]);
}
- if(SecondbotHelpers.notempty(primname) == false)
+ if(SecondbotHelpers.NotEmpty(primname) == false)
{
return Failure("Primname is empty", [objectuuid, primname, amount]);
}
diff --git a/SecondBotEvents/Commands/Group.cs b/SecondBotEvents/Commands/Group.cs
index 0fec74b..18fce65 100644
--- a/SecondBotEvents/Commands/Group.cs
+++ b/SecondBotEvents/Commands/Group.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Collections.Generic;
@@ -41,7 +41,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Invaild group UUID", [group]);
}
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupMembers(groupuuid)));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupMembers(groupuuid)));
}
[About("Attempts to ban/unban a given avatar from a group")]
@@ -212,11 +212,11 @@ namespace SecondBotEvents.Commands
{
return Failure("Unknown group", [group, title, message]);
}
- if (SecondbotHelpers.notempty(title) == false)
+ if (SecondbotHelpers.NotEmpty(title) == false)
{
return Failure("Title empty", [group, title, message]);
}
- if (SecondbotHelpers.notempty(message) == false)
+ if (SecondbotHelpers.NotEmpty(message) == false)
{
return Failure("Message empty", [group, title, message]);
}
@@ -303,11 +303,11 @@ namespace SecondBotEvents.Commands
{
return Failure("Unknown group", [group, title, message, attachment]);
}
- if (SecondbotHelpers.notempty(title) == false)
+ if (SecondbotHelpers.NotEmpty(title) == false)
{
return Failure("Title empty", [group, title, message, attachment]);
}
- if (SecondbotHelpers.notempty(message) == false)
+ if (SecondbotHelpers.NotEmpty(message) == false)
{
return Failure("Message empty", [group, title, message, attachment]);
}
@@ -328,7 +328,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object GetGroupList()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroups()));
}
[About("Forces the bot to reload the groups list")]
@@ -357,7 +357,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Unknown group", [group]);
}
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupRoles(groupuuid)));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupRoles(groupuuid)));
}
[About("fetchs a list of all groups with unread messages")]
@@ -365,7 +365,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object GroupchatListAllUnreadGroups()
{
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetAllGroupsChatWithUnread()));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAllGroupsChatWithUnread()));
}
[About("checks if a given group has any unread messages")]
@@ -416,7 +416,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Group UUID invaild", [group]);
}
- return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroupChatHistory(groupUUID)));
+ return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupChatHistory(groupUUID)));
}
[About("sends a message to the groupchat")]
diff --git a/SecondBotEvents/Commands/Info.cs b/SecondBotEvents/Commands/Info.cs
index 86299ac..2705d8c 100644
--- a/SecondBotEvents/Commands/Info.cs
+++ b/SecondBotEvents/Commands/Info.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System;
@@ -82,7 +82,7 @@ namespace SecondBotEvents.Commands
{
return Failure("No objects found");
}
- return BasicReply(JsonConvert.SerializeObject(reply));
+ return BasicReply(JsonSerializer.Serialize(reply));
}
[About("Fetchs the current bot")]
@@ -158,7 +158,7 @@ namespace SecondBotEvents.Commands
{ "y", (int)Math.Round(GetClient().Self.SimPosition.Y) },
{ "z", (int)Math.Round(GetClient().Self.SimPosition.Z) }
};
- return BasicReply(JsonConvert.SerializeObject(pos));
+ return BasicReply(JsonSerializer.Serialize(pos));
}
}
diff --git a/SecondBotEvents/Commands/Inventory.cs b/SecondBotEvents/Commands/Inventory.cs
index 1c7c213..20e1471 100644
--- a/SecondBotEvents/Commands/Inventory.cs
+++ b/SecondBotEvents/Commands/Inventory.cs
@@ -1,5 +1,5 @@
using BetterSecondBot.Static;
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.Assets;
using Org.BouncyCastle.Tls;
@@ -804,11 +804,11 @@ namespace SecondBotEvents.Commands
{
return Failure("Invaild item uuid", [itemuuid, itemname, itemtype, avatar]);
}
- if(SecondbotHelpers.isempty(itemname) == true)
+ if(SecondbotHelpers.IsEmpty(itemname) == true)
{
return Failure("Invaild item name", [itemuuid, itemname, itemtype, avatar]);
}
- if (SecondbotHelpers.isempty(itemtype) == true)
+ if (SecondbotHelpers.IsEmpty(itemtype) == true)
{
return Failure("Invaild item name", [itemuuid, itemname, itemtype, avatar]);
}
@@ -1112,7 +1112,7 @@ namespace SecondBotEvents.Commands
public object InventoryContentsCatched()
{
InventoryNodeEntry root = LoadInventoryNode(GetClient().Inventory.Store.RootFolder.UUID,"My Inventory");
- return BasicReply(JsonConvert.SerializeObject(root));
+ return BasicReply(JsonSerializer.Serialize(root));
}
protected InventoryNodeEntry LoadInventoryNode(UUID folder, string name="")
@@ -1284,7 +1284,7 @@ namespace SecondBotEvents.Commands
}
public string ToJson()
{
- return JsonConvert.SerializeObject(this);
+ return JsonSerializer.Serialize(this);
}
}
}
diff --git a/SecondBotEvents/Commands/Movement.cs b/SecondBotEvents/Commands/Movement.cs
index 18a615e..1b69969 100644
--- a/SecondBotEvents/Commands/Movement.cs
+++ b/SecondBotEvents/Commands/Movement.cs
@@ -22,7 +22,7 @@ namespace SecondBotEvents.Commands
{
return Failure("Convert to float has failed", [height]);
}
- if (SecondbotHelpers.inrange(level, -2.0, 2.0) == false)
+ if (SecondbotHelpers.InRange(level, -2.0, 2.0) == false)
{
return Failure("height value out of range(-2.0 to 2.0)", [height]);
}
@@ -45,15 +45,15 @@ namespace SecondBotEvents.Commands
{
return Failure("Convert to vector has failed", [x, y, z]);
}
- if (SecondbotHelpers.inrange(pos.X, 0, 255) == false)
+ if (SecondbotHelpers.InRange(pos.X, 0, 255) == false)
{
return Failure("x value out of range 0-255", [x, y, z]);
}
- if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false)
+ if (SecondbotHelpers.InRange(pos.Y, 0, 255) == false)
{
return Failure("y value out of range 0-255", [x, y, z]);
}
- if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false)
+ if (SecondbotHelpers.InRange(pos.Z, 0, 5000) == false)
{
return Failure("z value out of range 0-5000", [x, y, z]);
}
@@ -135,15 +135,15 @@ namespace SecondBotEvents.Commands
{
return Failure("Invaild vector", [vector]);
}
- if (SecondbotHelpers.inrange(pos.X, 0, 255) == false)
+ if (SecondbotHelpers.InRange(pos.X, 0, 255) == false)
{
return Failure("Vector x value is out of range 0-255", [vector]);
}
- if (SecondbotHelpers.inrange(pos.Y, 0, 255) == false)
+ if (SecondbotHelpers.InRange(pos.Y, 0, 255) == false)
{
return Failure("Vector y value is out of range 0-255", [vector]);
}
- if (SecondbotHelpers.inrange(pos.Z, 0, 5000) == false)
+ if (SecondbotHelpers.InRange(pos.Z, 0, 5000) == false)
{
return Failure("Vector z value is out of range 0-5000", [vector]);
}
@@ -233,7 +233,7 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object TeleportSLURL(string slurl)
{
- if (SecondbotHelpers.notempty(slurl) == false)
+ if (SecondbotHelpers.NotEmpty(slurl) == false)
{
return Failure("slurl is empty", [slurl]);
}
diff --git a/SecondBotEvents/Commands/Notecard.cs b/SecondBotEvents/Commands/Notecard.cs
index ad87980..92525eb 100644
--- a/SecondBotEvents/Commands/Notecard.cs
+++ b/SecondBotEvents/Commands/Notecard.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.Assets;
using SecondBotEvents.Services;
@@ -20,7 +20,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object NotecardRead(string notecardInventoryUUID, string replytarget)
{
- if(SecondbotHelpers.isempty(replytarget) == true)
+ if(SecondbotHelpers.IsEmpty(replytarget) == true)
{
return Failure("replytarget not set");
}
@@ -33,20 +33,20 @@ namespace SecondBotEvents.Commands
};
if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false)
{
- master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
+ master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead");
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");
+ master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead");
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");
+ master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead");
return Failure(reply.content, [notecardInventoryUUID]); ;
}
InventoryNotecard notecard = (InventoryNotecard)item;
@@ -55,7 +55,7 @@ namespace SecondBotEvents.Commands
if (transfer.Success == false)
{
reply.content = "!ERROR! - unable to read notecard";
- master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
+ master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead");
}
else
{
@@ -77,7 +77,7 @@ namespace SecondBotEvents.Commands
reply.content = contents;
reply.name = notecard.Name;
reply.status = true;
- master.CommandsService.SmartCommandReply(replytarget, JsonConvert.SerializeObject(reply), "NotecardRead");
+ master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead");
}
}
);
@@ -93,11 +93,11 @@ namespace SecondBotEvents.Commands
[CmdTypeSet()]
public object NotecardAdd(string collection, string content)
{
- if (SecondbotHelpers.notempty(collection) == false)
+ if (SecondbotHelpers.NotEmpty(collection) == false)
{
return Failure("Collection value is empty", [collection, content]);
}
- if (SecondbotHelpers.notempty(content) == false)
+ if (SecondbotHelpers.NotEmpty(content) == false)
{
return Failure("Content value is empty", [collection, content]);
}
@@ -112,7 +112,7 @@ namespace SecondBotEvents.Commands
[CmdTypeSet()]
public object NotecardClear(string collection)
{
- if (SecondbotHelpers.notempty(collection) == false)
+ if (SecondbotHelpers.NotEmpty(collection) == false)
{
return Failure("Collection value is empty", [collection]);
}
@@ -132,11 +132,11 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object NotecardSend(string avatar, string collection, string notecardname)
{
- if (SecondbotHelpers.notempty(collection) == false)
+ if (SecondbotHelpers.NotEmpty(collection) == false)
{
return Failure("Collection value is empty", [avatar, collection, notecardname]);
}
- if (SecondbotHelpers.notempty(notecardname) == false)
+ if (SecondbotHelpers.NotEmpty(notecardname) == false)
{
return Failure("Notecardname value is empty", [avatar, collection, notecardname]);
}
@@ -170,11 +170,11 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object NotecardDirectSend(string avatar, string content, string notecardname)
{
- if (SecondbotHelpers.notempty(notecardname) == false)
+ if (SecondbotHelpers.NotEmpty(notecardname) == false)
{
return Failure("notecardname value is empty", [avatar, content, notecardname]);
}
- if (SecondbotHelpers.notempty(content) == false)
+ if (SecondbotHelpers.NotEmpty(content) == false)
{
return Failure("content value is empty", [avatar, content, notecardname]);
}
diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs
index 6336035..ad62c15 100644
--- a/SecondBotEvents/Commands/ParcelCommands.cs
+++ b/SecondBotEvents/Commands/ParcelCommands.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.ImportExport.Collada14;
using SecondBotEvents.Services;
@@ -106,7 +106,7 @@ namespace SecondBotEvents.Commands
{
reply.Add(A.Name, A.SnapshotID.ToString());
}
- return BasicReply(JsonConvert.SerializeObject(reply));
+ return BasicReply(JsonSerializer.Serialize(reply));
}
[About("Requests the current parcel size")]
@@ -245,7 +245,7 @@ namespace SecondBotEvents.Commands
};
reply.parcels.Add(R);
}
- return BasicReply(JsonConvert.SerializeObject(reply));
+ return BasicReply(JsonSerializer.Serialize(reply));
}
[About("Cancels the current parcel the bot is in sale")]
@@ -341,7 +341,7 @@ namespace SecondBotEvents.Commands
collection.Add("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString());
collection.Add("Cost", targetparcel.SalePrice.ToString());
collection.Add("SaleTarget", targetparcel.AuthBuyerID.ToString());
- return BasicReply(JsonConvert.SerializeObject(collection));
+ return BasicReply(JsonSerializer.Serialize(collection));
}
[About("Make a request to the landsale directory")]
@@ -407,7 +407,7 @@ namespace SecondBotEvents.Commands
int counter = (100 * GetpageNum);
foreach(DirectoryParcel parcel in e.DirParcels)
{
- collection.Add(JsonConvert.SerializeObject(parcel));
+ collection.Add(JsonSerializer.Serialize(parcel));
counter++;
}
landresultsTimeout.Set();
@@ -422,7 +422,7 @@ namespace SecondBotEvents.Commands
return Failure("Timed out while doing land search");
}
GetClient().Directory.DirLandReply -= LandSearchResultsReply;
- string reply = JsonConvert.SerializeObject(collection);
+ string reply = JsonSerializer.Serialize(collection);
return BasicReply(reply, [filterRegion, filterPrice, filterArea, pageNum, timeout]);
}
@@ -477,7 +477,7 @@ namespace SecondBotEvents.Commands
{
return Failure(tests.Value, [name]);
}
- if (SecondbotHelpers.notempty(name) == false)
+ if (SecondbotHelpers.NotEmpty(name) == false)
{
return Failure("Parcel name is empty", [name]);
}
@@ -537,7 +537,7 @@ namespace SecondBotEvents.Commands
{
collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString());
}
- return BasicReply(JsonConvert.SerializeObject(collection));
+ return BasicReply(JsonSerializer.Serialize(collection));
}
[About("Ejects an avatar")]
@@ -785,7 +785,7 @@ namespace SecondBotEvents.Commands
collection.Add("OtherPrims", targetparcel.OtherPrims.ToString());
collection.Add("MaxPrims", targetparcel.MaxPrims.ToString());
collection.Add("ParcelPrimBonus", targetparcel.ParcelPrimBonus.ToString());
- return BasicReply(JsonConvert.SerializeObject(collection));
+ return BasicReply(JsonSerializer.Serialize(collection));
}
[About("Controls who can trigger audio on this parcel\n if everyone is set to true then grouponly will switch to false")]
[ReturnHints("ok")]
@@ -1064,7 +1064,7 @@ namespace SecondBotEvents.Commands
reply.delay = delays * 1000;
reply.parcelName = targetparcel.Name;
reply.regionName = GetClient().Network.CurrentSim.Name;
- return BasicReply(JsonConvert.SerializeObject(reply));
+ return BasicReply(JsonSerializer.Serialize(reply));
}
[About("Returns a rezzed object")]
@@ -1131,7 +1131,7 @@ namespace SecondBotEvents.Commands
{
return Failure("No objects found in the parcel");
}
- return BasicReply(JsonConvert.SerializeObject(objects));
+ return BasicReply(JsonSerializer.Serialize(objects));
}
[About("Updates the current parcels media settings \n" +
diff --git a/SecondBotEvents/Commands/RabbitMQ.cs b/SecondBotEvents/Commands/RabbitMQ.cs
index 4abd616..7f581c2 100644
--- a/SecondBotEvents/Commands/RabbitMQ.cs
+++ b/SecondBotEvents/Commands/RabbitMQ.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System;
diff --git a/SecondBotEvents/Commands/Self.cs b/SecondBotEvents/Commands/Self.cs
index fd3bc57..3bc7de4 100644
--- a/SecondBotEvents/Commands/Self.cs
+++ b/SecondBotEvents/Commands/Self.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.ImportExport.Collada14;
using SecondBotEvents.Services;
@@ -22,14 +22,14 @@ namespace SecondBotEvents.Commands
[CmdTypeDo()]
public object SendEmail(string to, string subject, string body)
{
- if (SecondbotHelpers.isempty(to) == true) {
+ if (SecondbotHelpers.IsEmpty(to) == true) {
return Failure("to is empty");
}
- else if (SecondbotHelpers.isempty(subject) == true)
+ else if (SecondbotHelpers.IsEmpty(subject) == true)
{
return Failure("subject is empty", [to]);
}
- else if (SecondbotHelpers.isempty(body) == true)
+ else if (SecondbotHelpers.IsEmpty(body) == true)
{
return Failure("body is empty", [to, subject]);
}
@@ -90,11 +90,11 @@ namespace SecondBotEvents.Commands
[CmdTypeSet()]
public object SetKeyValue(string Key, string Value)
{
- if (SecondbotHelpers.isempty(Key) == false)
+ if (SecondbotHelpers.IsEmpty(Key) == false)
{
return Failure("Key is empty", [Key, Value]);
}
- if (SecondbotHelpers.isempty(Value) == false)
+ if (SecondbotHelpers.IsEmpty(Value) == false)
{
return Failure("Value is empty", [Key, Value]);
}
@@ -109,7 +109,7 @@ namespace SecondBotEvents.Commands
[CmdTypeSet()]
public object ClearKeyValue(string Key)
{
- if (SecondbotHelpers.isempty(Key) == false)
+ if (SecondbotHelpers.IsEmpty(Key) == false)
{
return Failure("Key is empty", [Key]);
}
@@ -218,7 +218,7 @@ namespace SecondBotEvents.Commands
List reply = [];
foreach (CommandHistory A in master.DataStoreService.GetCommandHistory())
{
- reply.Add(JsonConvert.SerializeObject(A));
+ reply.Add(JsonSerializer.Serialize(A));
if (reply.Count >= 5)
{
break;
diff --git a/SecondBotEvents/Commands/Services.cs b/SecondBotEvents/Commands/Services.cs
index 131d1e7..befa13c 100644
--- a/SecondBotEvents/Commands/Services.cs
+++ b/SecondBotEvents/Commands/Services.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Services;
using System.Collections.Generic;
diff --git a/SecondBotEvents/Commands/StreamAdmin.cs b/SecondBotEvents/Commands/StreamAdmin.cs
index 974368e..a1cf6e1 100644
--- a/SecondBotEvents/Commands/StreamAdmin.cs
+++ b/SecondBotEvents/Commands/StreamAdmin.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using RestSharp;
using SecondBotEvents.Services;
@@ -22,11 +22,11 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()]
public object FetchNextNotecard(string endpoint, string endpointcode)
{
- if (SecondbotHelpers.notempty(endpoint) == false)
+ if (SecondbotHelpers.NotEmpty(endpoint) == false)
{
return Failure("Endpoint is empty", [endpoint, endpointcode]);
}
- if (SecondbotHelpers.notempty(endpointcode) == false)
+ if (SecondbotHelpers.NotEmpty(endpointcode) == false)
{
return Failure("Endpointcode is empty", [endpoint, endpointcode]);
}
@@ -48,7 +48,7 @@ namespace SecondBotEvents.Commands
}
try
{
- NotecardEndpoint server_reply = JsonConvert.DeserializeObject(endpoint_checks.Content);
+ NotecardEndpoint server_reply = JsonSerializer.Deserialize(endpoint_checks.Content);
if (server_reply.status == false)
{
return Failure("Bad reply: " + server_reply.message, [endpoint, endpointcode]);
diff --git a/SecondBotEvents/Config/config.cs b/SecondBotEvents/Config/config.cs
index e8ae4bc..f77ed55 100644
--- a/SecondBotEvents/Config/config.cs
+++ b/SecondBotEvents/Config/config.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -76,7 +76,7 @@ namespace SecondBotEvents.Config
SimpleIO IO = new();
IO.ChangeRoot(fromFolder);
string writeFile = filename + ".json";
- IO.WriteFile(writeFile, JsonConvert.SerializeObject(saveMe));
+ IO.WriteFile(writeFile, JsonSerializer.Serialize(saveMe));
}
protected void LoadSettingsFromFile(string fromFolder)
@@ -96,7 +96,7 @@ namespace SecondBotEvents.Config
{
settings.Add(x.Key);
string value = x.Value.ToString();
- if (SecondbotHelpers.notempty(value) == false)
+ if (SecondbotHelpers.NotEmpty(value) == false)
{
mysettings.Add(x.Key, "");
continue;
diff --git a/SecondBotEvents/EventsSecondBot.cs b/SecondBotEvents/EventsSecondBot.cs
index 9983e5d..b88920b 100644
--- a/SecondBotEvents/EventsSecondBot.cs
+++ b/SecondBotEvents/EventsSecondBot.cs
@@ -97,7 +97,7 @@ namespace SecondBotEvents
protected bool exitNow = false;
public EventsSecondBot(string[] args)
{
- if (SecondbotHelpers.notempty(Environment.GetEnvironmentVariable("basic_Username")) == true)
+ if (SecondbotHelpers.NotEmpty(Environment.GetEnvironmentVariable("basic_Username")) == true)
{
fromEnv = true;
}
diff --git a/SecondBotEvents/SecondBotEvents.csproj b/SecondBotEvents/SecondBotEvents.csproj
index 36f2375..65c763d 100644
--- a/SecondBotEvents/SecondBotEvents.csproj
+++ b/SecondBotEvents/SecondBotEvents.csproj
@@ -13,17 +13,16 @@
-
-
-
+
+
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
diff --git a/SecondBotEvents/Services/ChatGptService.cs b/SecondBotEvents/Services/ChatGptService.cs
index 5c1101e..4534fb3 100644
--- a/SecondBotEvents/Services/ChatGptService.cs
+++ b/SecondBotEvents/Services/ChatGptService.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Config;
using System;
@@ -62,15 +62,15 @@ namespace SecondBotEvents.Services
}
}
- chatHistorySize = inrange(3,10,myConfig.GetChatHistoryMessages());
- localchatRateLimit = inrange(1, 10, myConfig.GetLocalchatRateLimiter());
- groupchatRateLimit = inrange(1, 10, myConfig.GetGroupReplyRateLimiter());
- imchatRateLimit = inrange(1, 10, myConfig.GetImReplyRateLimiter());
+ chatHistorySize = InRange(3,10,myConfig.GetChatHistoryMessages());
+ localchatRateLimit = InRange(1, 10, myConfig.GetLocalchatRateLimiter());
+ groupchatRateLimit = InRange(1, 10, myConfig.GetGroupReplyRateLimiter());
+ imchatRateLimit = InRange(1, 10, myConfig.GetImReplyRateLimiter());
running = true;
master.BotClientNoticeEvent += BotClientRestart;
}
- protected int inrange(int value, int min, int max)
+ protected static int InRange(int value, int min, int max)
{
if (value < min) return min;
else if(value > max) return max;
@@ -113,9 +113,9 @@ namespace SecondBotEvents.Services
return "Disabled";
}
upkeep();
- if (chatHistoryAI.Count() > 0)
+ if (chatHistoryAI.Count > 0)
{
- return "Enabled running: " + chatHistoryAI.Count().ToString() + " chat windows";
+ return "Enabled running: " + chatHistoryAI.Count.ToString() + " chat windows";
}
return "Enabled No chat history";
}
@@ -220,9 +220,9 @@ namespace SecondBotEvents.Services
}
}
- Dictionary>> chatHistoryAI = [];
- Dictionary ChatHistoryLastAccessed = [];
- Dictionary ChatRateLimiter = [];
+ protected Dictionary>> chatHistoryAI = [];
+ protected Dictionary ChatHistoryLastAccessed = [];
+ protected Dictionary ChatRateLimiter = [];
protected long lastUpkeep = 0;
protected void upkeep()
@@ -248,18 +248,9 @@ namespace SecondBotEvents.Services
}
foreach(UUID a in needcleaning)
{
- if(chatHistoryAI.ContainsKey(a))
- {
- chatHistoryAI.Remove(a);
- }
- if(ChatHistoryLastAccessed.ContainsKey(a))
- {
- ChatHistoryLastAccessed.Remove(a);
- }
- if (ChatRateLimiter.ContainsKey(a))
- {
- ChatRateLimiter.Remove(a);
- }
+ chatHistoryAI.Remove(a);
+ ChatHistoryLastAccessed.Remove(a);
+ ChatRateLimiter.Remove(a);
}
}
}
@@ -328,7 +319,7 @@ namespace SecondBotEvents.Services
return chatHistoryAI[store]; // nothing in memory use the default store
}
redisDb.KeyExpire(readkey, TimeSpan.FromMinutes(myConfig.GetRedisMaxageMins())); // update the expire value
- return JsonConvert.DeserializeObject>>(rawstring);
+ return JsonSerializer.Deserialize>>(rawstring);
}
return NoRedisStoreFound(store);
}
@@ -423,24 +414,24 @@ namespace SecondBotEvents.Services
{
return false;
}
- int maxsize = inrange(1, 9999, myConfig.GetRedisCountLocal());
+ int maxsize = InRange(1, 9999, myConfig.GetRedisCountLocal());
if(avatarchat == true)
{
- maxsize = inrange(1, 9999, myConfig.GetRedisCountIm());
+ maxsize = InRange(1, 9999, myConfig.GetRedisCountIm());
}
else if(groupchat == true)
{
- maxsize = inrange(1, 9999, myConfig.GetRedisCountGroup());
+ maxsize = InRange(1, 9999, myConfig.GetRedisCountGroup());
}
// trim the history using targeted max values
- while (history.Count() > maxsize + 1)
+ while (history.Count > maxsize + 1)
{
history.RemoveAt(1);
}
RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
try
{
- string savestring = JsonConvert.SerializeObject(history);
+ string savestring = JsonSerializer.Serialize(history);
if (savestring == null)
{
LogFormater.Warn("Redis failed to convert history into savable format");
@@ -475,7 +466,7 @@ namespace SecondBotEvents.Services
protected List> BasicSaveHistory(UUID store, List> history)
{
// trim the history using basic config
- while (history.Count() > chatHistorySize + 1)
+ while (history.Count > chatHistorySize + 1)
{
history.RemoveAt(1);
}
@@ -519,11 +510,7 @@ namespace SecondBotEvents.Services
{
throw new ArgumentException("Invalid role provided in history. Role must be 'system', 'user', or 'assistant'.");
}
- string thismessage = entry.Value;
- if(thismessage == null)
- {
- throw new ArgumentException("Message can not be empty");
- }
+ string thismessage = entry.Value ?? throw new ArgumentException("Message can not be empty");
if (role == "system") messages.Add(ChatMessage.FromSystem(thismessage));
else if (role == "user") messages.Add(ChatMessage.FromUser(thismessage));
else if (role == "assistant") messages.Add(ChatMessage.FromAssistant(thismessage));
@@ -538,7 +525,7 @@ namespace SecondBotEvents.Services
return;
}
}
- if(messages.Count() == 0)
+ if(messages.Count == 0)
{
LogFormater.Warn("No messages given");
return;
@@ -581,7 +568,7 @@ namespace SecondBotEvents.Services
completionResult = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest
{
Messages = messages,
- Model = openAI_Models.GetModel(myConfig.GetUseModel())
+ Model = OpenAIModels.GetModel(myConfig.GetUseModel())
});
}
@@ -705,7 +692,7 @@ namespace SecondBotEvents.Services
}
}
- public class openAI_Models
+ public class OpenAIModels
{
public static string GetModel(string input)
{
diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs
index 132916c..cff79c2 100644
--- a/SecondBotEvents/Services/CommandsService.cs
+++ b/SecondBotEvents/Services/CommandsService.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using Newtonsoft.Json.Linq;
using OpenMetaverse;
using SecondBotEvents.Config;
@@ -245,7 +245,10 @@ namespace SecondBotEvents.Services
return;
}
mode = "IM";
- UUID.TryParse(UUIDfetch, out target_avatar);
+ if(UUID.TryParse(UUIDfetch, out target_avatar) == false)
+ {
+ return;
+ }
}
else if (new EmailAddressAttribute().IsValid(target) == true)
{
@@ -322,7 +325,7 @@ namespace SecondBotEvents.Services
reply = "Error";
if (processed != null)
{
- reply = JsonConvert.SerializeObject(processed);
+ reply = JsonSerializer.Serialize(processed);
}
CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply);
return new KeyValuePair(status, reply);
@@ -450,7 +453,7 @@ namespace SecondBotEvents.Services
{
e.results = e.results.Substring(0, 100) + "...";
}
- LogFormater.Info("Command log:" + JsonConvert.SerializeObject(e));
+ LogFormater.Info("Command log:" + JsonSerializer.Serialize(e));
}
}
}
@@ -606,7 +609,7 @@ namespace SecondBotEvents.Services
{
dynamic ret = jToken[key];
if (ret == null) return defaultValue;
- if (ret is JObject) return JsonConvert.DeserializeObject(ret.ToString());
+ if (ret is JObject) return JsonSerializer.Deserialize(ret.ToString());
return (T)ret;
}
}
diff --git a/SecondBotEvents/Services/DataStoreService.cs b/SecondBotEvents/Services/DataStoreService.cs
index 06d2b36..99a46c4 100644
--- a/SecondBotEvents/Services/DataStoreService.cs
+++ b/SecondBotEvents/Services/DataStoreService.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Config;
using System;
diff --git a/SecondBotEvents/Services/DialogService.cs b/SecondBotEvents/Services/DialogService.cs
index 878b14b..a9e1557 100644
--- a/SecondBotEvents/Services/DialogService.cs
+++ b/SecondBotEvents/Services/DialogService.cs
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
-using Newtonsoft.Json;
+using System.Text.Json;
using System.Linq;
using Swan;
using SecondBotEvents.Commands;
@@ -190,7 +190,7 @@ namespace SecondBotEvents.Services
objectname = e.ObjectName,
expires = expiresAt
};
- string eventMessage = JsonConvert.SerializeObject(window);
+ string eventMessage = JsonSerializer.Serialize(window);
foreach(int a in DialogRelayChannels)
{
if(a >= 0)
diff --git a/SecondBotEvents/Services/EventsService.cs b/SecondBotEvents/Services/EventsService.cs
index d5b1ef4..43bcd65 100644
--- a/SecondBotEvents/Services/EventsService.cs
+++ b/SecondBotEvents/Services/EventsService.cs
@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
-using Newtonsoft.Json;
+using System.Text.Json;
using System.Linq;
using Swan;
using RestSharp;
@@ -33,7 +33,7 @@ namespace SecondBotEvents.Services
{
foreach(string A in InventoryEvents[detail["itemtype"]])
{
- string output = JsonConvert.SerializeObject(detail);
+ string output = JsonSerializer.Serialize(detail);
if(UUID.TryParse(A, out UUID OutputAvatar) == true)
{
if (OutputAvatar != UUID.Zero)
@@ -259,7 +259,7 @@ namespace SecondBotEvents.Services
args,
myConfig.GetOutputSecret()
);
- string output = JsonConvert.SerializeObject(e);
+ string output = JsonSerializer.Serialize(e);
if(myConfig.GetOutputChannel() >= 0)
{
GetClient().Self.Chat(output, myConfig.GetOutputChannel(), ChatType.Normal);
@@ -268,7 +268,7 @@ namespace SecondBotEvents.Services
{
GetClient().Self.InstantMessage(OutputAvatar, output);
}
- if(SecondbotHelpers.isempty(myConfig.GetOutputHttpURL()) == false)
+ if(SecondbotHelpers.IsEmpty(myConfig.GetOutputHttpURL()) == false)
{
if(myConfig.GetOutputHttpURL().StartsWith("http") == false)
{
diff --git a/SecondBotEvents/Services/HttpService.cs b/SecondBotEvents/Services/HttpService.cs
index 2d8ddab..2c4317a 100644
--- a/SecondBotEvents/Services/HttpService.cs
+++ b/SecondBotEvents/Services/HttpService.cs
@@ -13,7 +13,6 @@ using System.Text.Json;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Newtonsoft.Json;
using Org.BouncyCastle.Utilities;
using Swan;
@@ -160,7 +159,7 @@ namespace SecondBotEvents.Services
{
return "Command request rejected";
}
- return JsonConvert.SerializeObject(master.CommandsService.RunCommand("HTTP", C));
+ return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP", C));
}
public static async Task SerializationCallback(IHttpContext context, object? data)
{
@@ -223,7 +222,7 @@ namespace SecondBotEvents.Services
protected object BasicReply(string input)
{
- return BasicReply(input, Array.Empty(), GetCallingCommand());
+ return BasicReply(input, [], GetCallingCommand());
}
protected object BasicReply(string input, string[] args)
@@ -250,12 +249,12 @@ namespace SecondBotEvents.Services
protected object Failure(string input)
{
- return Failure(input, GetCallingCommand(), Array.Empty(), null);
+ return Failure(input, GetCallingCommand(), [], null);
}
protected static string GetCallingCommand()
{
- string commandName = "Unable to get";
+ string commandName;
try
{
int index = 2;
@@ -343,7 +342,7 @@ namespace SecondBotEvents.Services
public string about = about;
public string defaultValueType = defaultValueType ?? string.Empty; // Default to empty string if not provided
public string exampleValue = exampleValue ?? string.Empty; // Default to empty string if not provided
- public string[] acceptedValues = acceptedValues ?? Array.Empty(); // Default to empty array if not provided
+ public string[] acceptedValues = acceptedValues ?? []; // Default to empty array if not provided
}
public class SecondbotWebApi(EventsSecondBot setmaster) : WebApiController
@@ -364,7 +363,7 @@ namespace SecondBotEvents.Services
public string Run([FormField] string commandName, [FormField] string args, [FormField] string signing, [FormField] string unixtime)
{
- string[] myArgs = Array.Empty();
+ string[] myArgs = [];
if(args != null)
{
myArgs = args.Split("~#~", StringSplitOptions.RemoveEmptyEntries);
@@ -385,7 +384,7 @@ namespace SecondBotEvents.Services
{
return "Command request rejected";
}
- return JsonConvert.SerializeObject(master.CommandsService.RunCommand("HTTP",C));
+ return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP",C));
}
}
diff --git a/SecondBotEvents/Services/InteractionService.cs b/SecondBotEvents/Services/InteractionService.cs
index ebda904..63a5355 100644
--- a/SecondBotEvents/Services/InteractionService.cs
+++ b/SecondBotEvents/Services/InteractionService.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Config;
using System;
@@ -145,7 +145,7 @@ namespace SecondBotEvents.Services
{
if(myConfig.GetEnableDebug() == true)
{
- LogFormater.Warn("Interaction debug:" + JsonConvert.SerializeObject(new InteractionEvent(from, eventype, status, why, setMisc)));
+ LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc)));
}
if (myConfig.GetEnableJsonOutputEvents() == false)
{
@@ -153,7 +153,7 @@ namespace SecondBotEvents.Services
}
master.CommandsService.SmartCommandReply(
myConfig.GetJsonOutputEventsTarget(),
- JsonConvert.SerializeObject(new InteractionEvent(from, eventype, status, why, setMisc)),
+ JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc)),
"interactions"
);
}
@@ -171,7 +171,7 @@ namespace SecondBotEvents.Services
{
if (myConfig.GetEnableDebug() == true)
{
- LogFormater.Warn("Interaction debug:" + JsonConvert.SerializeObject(misc));
+ LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(misc));
}
if (myConfig.GetEnableJsonOutputEvents() == false)
{
@@ -180,7 +180,7 @@ namespace SecondBotEvents.Services
misc.Add("eventsource", source);
master.CommandsService.SmartCommandReply(
myConfig.GetJsonOutputEventsTarget(),
- JsonConvert.SerializeObject(misc),
+ JsonSerializer.Serialize(misc),
"interactions"
);
}
diff --git a/SecondBotEvents/Services/RLVService.cs b/SecondBotEvents/Services/RLVService.cs
index b3a3308..7afb091 100644
--- a/SecondBotEvents/Services/RLVService.cs
+++ b/SecondBotEvents/Services/RLVService.cs
@@ -1,7 +1,7 @@
using OpenMetaverse;
using SecondBotEvents.Config;
using System.Collections.Generic;
-using Newtonsoft.Json;
+using System.Text.Json;
using RestSharp;
using OpenMetaverse.StructuredData;
using System.Linq;
diff --git a/SecondBotEvents/Services/RabbitService.cs b/SecondBotEvents/Services/RabbitService.cs
index 9bc21ec..df63a53 100644
--- a/SecondBotEvents/Services/RabbitService.cs
+++ b/SecondBotEvents/Services/RabbitService.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
using RabbitMQ.Client.Events;
-using Newtonsoft.Json;
+using System.Text.Json;
using Swan;
using OpenMetaverse;
using Microsoft.Extensions.Logging.Abstractions;
@@ -19,7 +19,7 @@ namespace SecondBotEvents.Services
{
try
{
- JsonCommandFormat result = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(e.Body.ToArray()));
+ JsonCommandFormat result = JsonSerializer.Deserialize(Encoding.UTF8.GetString(e.Body.ToArray()));
if (result == null || string.IsNullOrEmpty(result.CommandName))
{
if (myConfig.GetLogDebug() == true)
@@ -45,7 +45,7 @@ namespace SecondBotEvents.Services
{
try
{
- JsonNotecardFormat result = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(e.Body.ToArray()));
+ JsonNotecardFormat result = JsonSerializer.Deserialize(Encoding.UTF8.GetString(e.Body.ToArray()));
if (
result == null ||
string.IsNullOrEmpty(result.Name) ||
@@ -82,7 +82,7 @@ namespace SecondBotEvents.Services
Console.WriteLine("Message received: " + Encoding.UTF8.GetString(e.Body.ToArray()));
try
{
- JsonMessageFormat result = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(e.Body.ToArray()));
+ JsonMessageFormat result = JsonSerializer.Deserialize(Encoding.UTF8.GetString(e.Body.ToArray()));
if (result == null || string.IsNullOrEmpty(result.UUID) || string.IsNullOrEmpty(result.Message))
{
if (myConfig.GetLogDebug() == true)
@@ -113,7 +113,7 @@ namespace SecondBotEvents.Services
Console.WriteLine("Message received: " + Encoding.UTF8.GetString(e.Body.ToArray()));
try
{
- JsonMessageFormat result = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(e.Body.ToArray()));
+ JsonMessageFormat result = JsonSerializer.Deserialize(Encoding.UTF8.GetString(e.Body.ToArray()));
if (result == null || string.IsNullOrEmpty(result.UUID) || string.IsNullOrEmpty(result.Message))
{
if (myConfig.GetLogDebug() == true)
@@ -151,9 +151,8 @@ namespace SecondBotEvents.Services
return;
}
}
- ConnectionFactory factory;
- IConnection connection;
- Dictionary channels = new Dictionary();
+ protected IConnection connection;
+ protected Dictionary channels = [];
public override void Start(bool updateEnabled = false, bool setEnabledTo = false)
{
if (updateEnabled == true)
@@ -209,7 +208,7 @@ namespace SecondBotEvents.Services
return new KeyValuePair(true, "Message sent to queue " + Qname);
}
- protected void connectService()
+ protected void ConnectService()
{
if (connection != null && connection.IsOpen == true)
{
@@ -219,9 +218,11 @@ namespace SecondBotEvents.Services
var endpoints = new System.Collections.Generic.List {
new AmqpTcpEndpoint(myConfig.GetHostIP(),myConfig.GetHostPort()),
};
- ConnectionFactory factory = new ConnectionFactory();
- factory.UserName = myConfig.GetHostUsername();
- factory.Password = myConfig.GetHostPassword();
+ ConnectionFactory factory = new ConnectionFactory
+ {
+ UserName = myConfig.GetHostUsername(),
+ Password = myConfig.GetHostPassword()
+ };
try
{
connection = factory.CreateConnectionAsync(endpoints).Await();
@@ -232,10 +233,10 @@ namespace SecondBotEvents.Services
return;
}
- createChannelWorker(myConfig.GetNotecardQueue(), "NotecardMessageEvent");
- createChannelWorker(myConfig.GetCommandQueue(), "CommandMessageEvent");
- createChannelWorker(myConfig.GetImQueue(), "ImMessageEvent");
- createChannelWorker(myConfig.GetGroupImQueue(), "GroupMessageEvent");
+ CreateChannelWorker(myConfig.GetNotecardQueue(), "NotecardMessageEvent");
+ CreateChannelWorker(myConfig.GetCommandQueue(), "CommandMessageEvent");
+ CreateChannelWorker(myConfig.GetImQueue(), "ImMessageEvent");
+ CreateChannelWorker(myConfig.GetGroupImQueue(), "GroupMessageEvent");
}
catch (Exception ex)
{
@@ -250,7 +251,7 @@ namespace SecondBotEvents.Services
}
- protected async void createChannelWorker(string queueName, string functionpointer)
+ protected async void CreateChannelWorker(string queueName, string functionpointer)
{
IChannel channel = connection.CreateChannelAsync().Await();
channels.Add(queueName, channel);
@@ -299,7 +300,7 @@ namespace SecondBotEvents.Services
}
LogFormater.Info("Rabbit service [Attached to new client]");
hasSecondbot = true;
- connectService();
+ ConnectService();
}
public override void Stop()
diff --git a/SecondBotEvents/Services/RelayService.cs b/SecondBotEvents/Services/RelayService.cs
index 01ad465..38bf6c1 100644
--- a/SecondBotEvents/Services/RelayService.cs
+++ b/SecondBotEvents/Services/RelayService.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using SecondBotEvents.Config;
using System;
@@ -218,7 +218,7 @@ namespace SecondBotEvents.Services
sourcetype = source,
sourceoption = filter
};
- string eventMessage = JsonConvert.SerializeObject(a);
+ string eventMessage = JsonSerializer.Serialize(a);
relayEventExtended relayEventExtended = new()
{
source = source,
@@ -230,7 +230,7 @@ namespace SecondBotEvents.Services
message = message,
unixtime = SecondbotHelpers.UnixTimeNow().ToString()
};
- string eventMessageExtended = JsonConvert.SerializeObject(relayEventExtended);
+ string eventMessageExtended = JsonSerializer.Serialize(relayEventExtended);
while (loop <= myConfig.GetRelayCount())
{
diff --git a/SecondBotEvents/Static/Helpers.cs b/SecondBotEvents/Static/Helpers.cs
index 5fad6e3..5162591 100644
--- a/SecondBotEvents/Static/Helpers.cs
+++ b/SecondBotEvents/Static/Helpers.cs
@@ -70,7 +70,7 @@ namespace SecondBotEvents
return e.Message;
}
}
- public static bool inrange(float current,float min,float max)
+ public static bool InRange(float current,float min,float max)
{
if(current <= max)
{
@@ -81,7 +81,7 @@ namespace SecondBotEvents
}
return false;
}
- public static bool inrange(double current, double min, double max)
+ public static bool InRange(double current, double min, double max)
{
if (current <= max)
{
@@ -92,11 +92,11 @@ namespace SecondBotEvents
}
return false;
}
- public static bool inbox(float expected, float current, float drift)
+ public static bool Inbox(float expected, float current, float drift)
{
- return distance_check(expected, current, drift, true);
+ return DistanceCheck(expected, current, drift, true);
}
- public static bool distance_check(float expected, float current, float drift, bool current_value)
+ public static bool DistanceCheck(float expected, float current, float drift, bool current_value)
{
if (current > (expected + drift))
{
@@ -148,7 +148,7 @@ namespace SecondBotEvents
var timeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
return (long)timeSpan.TotalSeconds;
}
- public static bool notempty(string V)
+ public static bool NotEmpty(string V)
{
if (V != null)
{
@@ -160,7 +160,7 @@ namespace SecondBotEvents
return false;
}
- public static bool isempty(string V)
+ public static bool IsEmpty(string V)
{
if (V != null)
{
@@ -172,7 +172,7 @@ namespace SecondBotEvents
return true;
}
- public static bool notempty(string[] V)
+ public static bool NotEmpty(string[] V)
{
if (V != null)
{
diff --git a/SecondBotEvents/Static/Inventory.cs b/SecondBotEvents/Static/Inventory.cs
index 7fda437..e9017c0 100644
--- a/SecondBotEvents/Static/Inventory.cs
+++ b/SecondBotEvents/Static/Inventory.cs
@@ -1,4 +1,4 @@
-using Newtonsoft.Json;
+using System.Text.Json;
using OpenMetaverse;
using OpenMetaverse.ImportExport.Collada14;
using System;
@@ -146,7 +146,7 @@ namespace BetterSecondBot.Static
}
public static string MapFolderInventoryJson(GridClient bot,UUID folder)
{
- return JsonConvert.SerializeObject(getfolderinventory(bot, folder));
+ return JsonSerializer.Serialize(getfolderinventory(bot, folder));
}
public static KeyValuePair MapFolderInventoryHumanReadable(GridClient bot, UUID folder)
@@ -192,7 +192,7 @@ namespace BetterSecondBot.Static
}
if (topLevel != null)
{
- return JsonConvert.SerializeObject(DoMapFolderJson(bot, topLevel, subfolders));
+ return JsonSerializer.Serialize(DoMapFolderJson(bot, topLevel, subfolders));
}
}
}