mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Reverted smarttext to newtonsoft to relax the allowed json rules. Upped version to 4.1.3
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
using System.Text.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
@@ -14,12 +15,6 @@ public abstract record SmartText
|
||||
public bool IsEmbedArray
|
||||
=> this is SmartEmbedTextArray;
|
||||
|
||||
private static readonly JsonSerializerOptions _opts = new JsonSerializerOptions()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
};
|
||||
|
||||
public static SmartText operator +(SmartText text, string input)
|
||||
=> text switch
|
||||
{
|
||||
@@ -58,13 +53,13 @@ public abstract record SmartText
|
||||
|
||||
try
|
||||
{
|
||||
var doc = JsonDocument.Parse(input);
|
||||
var root = doc.RootElement;
|
||||
if (root.ValueKind == JsonValueKind.Object)
|
||||
var doc = JObject.Parse(input);
|
||||
var root = doc.Root;
|
||||
if (root.Type == JTokenType.Object)
|
||||
{
|
||||
if (root.TryGetProperty("embeds", out _))
|
||||
if (((JObject)root).TryGetValue("embeds", out _))
|
||||
{
|
||||
var arr = root.Deserialize<SmartEmbedTextArray>(_opts);
|
||||
var arr = root.ToObject<SmartEmbedTextArray>();
|
||||
|
||||
if (arr is null)
|
||||
return new SmartPlainText(input);
|
||||
@@ -73,7 +68,7 @@ public abstract record SmartText
|
||||
return arr;
|
||||
}
|
||||
|
||||
var obj = root.Deserialize<SmartEmbedText>(_opts);
|
||||
var obj = root.ToObject<SmartEmbedText>();
|
||||
|
||||
if (obj is null)
|
||||
return new SmartPlainText(input);
|
||||
|
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
|
||||
|
||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||
{
|
||||
public const string BOT_VERSION = "4.1.2";
|
||||
public const string BOT_VERSION = "4.1.3";
|
||||
|
||||
public string Author
|
||||
=> "Kwoth#2452";
|
||||
|
Reference in New Issue
Block a user