From f0c85eaafc4930b38c453026112b570ac00d4f32 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 7 Jul 2016 04:46:33 +0200 Subject: [PATCH] fixed customreactions always loading default reactions, even when they are deleted #370 --- NadekoBot/NadekoBot.cs | 2 +- NadekoBot/_Models/JSONModels/Configuration.cs | 46 +++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index df3c8f7d..86d22219 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -196,7 +196,7 @@ namespace NadekoBot return; } #if NADEKO_RELEASE - await Task.Delay(100000).ConfigureAwait(false); + await Task.Delay(120000).ConfigureAwait(false); #else await Task.Delay(1000).ConfigureAwait(false); #endif diff --git a/NadekoBot/_Models/JSONModels/Configuration.cs b/NadekoBot/_Models/JSONModels/Configuration.cs index ad75f35d..bafdb84e 100644 --- a/NadekoBot/_Models/JSONModels/Configuration.cs +++ b/NadekoBot/_Models/JSONModels/Configuration.cs @@ -3,25 +3,14 @@ using NadekoBot.Extensions; using Newtonsoft.Json; using System.Collections.Generic; using System.IO; +using System.Runtime.Serialization; namespace NadekoBot.Classes.JSONModels { public class Configuration { - public bool DontJoinServers { get; set; } = false; - public bool ForwardMessages { get; set; } = true; - public bool IsRotatingStatus { get; set; } = false; - public int BufferSize { get; set; } = 4.MiB(); - [JsonIgnore] - public List Quotes { get; set; } = new List(); - - [JsonIgnore] - public List PokemonTypes { get; set; } = new List(); - - public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗"; - - public Dictionary> CustomReactions { get; set; } = new Dictionary>() + public static readonly Dictionary> DefaultCustomReactions = new Dictionary> { {@"\o\", new List() { "/o/" } }, @@ -93,6 +82,21 @@ namespace NadekoBot.Classes.JSONModels } } }; + public bool DontJoinServers { get; set; } = false; + public bool ForwardMessages { get; set; } = true; + public bool IsRotatingStatus { get; set; } = false; + public int BufferSize { get; set; } = 4.MiB(); + + public List Quotes { get; set; } = new List(); + + [JsonIgnore] + public List PokemonTypes { get; set; } = new List(); + + public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗"; + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public Dictionary> CustomReactions { get; set; } + public List RotatingStatuses { get; set; } = new List(); public CommandPrefixesModel CommandPrefixes { get; set; } = new CommandPrefixesModel(); public HashSet ServerBlacklist { get; set; } = new HashSet(); @@ -104,6 +108,22 @@ namespace NadekoBot.Classes.JSONModels 143515953525817344 }; + [OnDeserialized] + internal void OnDeserialized(StreamingContext context) + { + if (CustomReactions == null) + { + CustomReactions = DefaultCustomReactions; + } + } + [OnSerializing] + internal void OnSerializing(StreamingContext context) + { + if (CustomReactions == null) + { + CustomReactions = DefaultCustomReactions; + } + } public string[] _8BallResponses { get; set; } = {