mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05: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
 | 
					#nullable disable
 | 
				
			||||||
using System.Text.Json;
 | 
					using Newtonsoft.Json;
 | 
				
			||||||
 | 
					using Newtonsoft.Json.Linq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace NadekoBot;
 | 
					namespace NadekoBot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -14,12 +15,6 @@ public abstract record SmartText
 | 
				
			|||||||
    public bool IsEmbedArray
 | 
					    public bool IsEmbedArray
 | 
				
			||||||
        => this is SmartEmbedTextArray;
 | 
					        => this is SmartEmbedTextArray;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private static readonly JsonSerializerOptions _opts = new JsonSerializerOptions()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        PropertyNameCaseInsensitive = true,
 | 
					 | 
				
			||||||
        PropertyNamingPolicy = JsonNamingPolicy.CamelCase
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    public static SmartText operator +(SmartText text, string input)
 | 
					    public static SmartText operator +(SmartText text, string input)
 | 
				
			||||||
        => text switch
 | 
					        => text switch
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -58,13 +53,13 @@ public abstract record SmartText
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        try
 | 
					        try
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var doc = JsonDocument.Parse(input);
 | 
					            var doc = JObject.Parse(input);
 | 
				
			||||||
            var root = doc.RootElement;
 | 
					            var root = doc.Root;
 | 
				
			||||||
            if (root.ValueKind == JsonValueKind.Object)
 | 
					            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)
 | 
					                    if (arr is null)
 | 
				
			||||||
                        return new SmartPlainText(input);
 | 
					                        return new SmartPlainText(input);
 | 
				
			||||||
@@ -73,7 +68,7 @@ public abstract record SmartText
 | 
				
			|||||||
                    return arr;
 | 
					                    return arr;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var obj = root.Deserialize<SmartEmbedText>(_opts);
 | 
					                var obj = root.ToObject<SmartEmbedText>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (obj is null)
 | 
					                if (obj is null)
 | 
				
			||||||
                    return new SmartPlainText(input);
 | 
					                    return new SmartPlainText(input);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
 | 
					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
 | 
					    public string Author
 | 
				
			||||||
        => "Kwoth#2452";
 | 
					        => "Kwoth#2452";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user