diff --git a/CompatBot/Commands/BotStatus.cs b/CompatBot/Commands/BotStatus.cs index 949c9529..ebfb01d2 100644 --- a/CompatBot/Commands/BotStatus.cs +++ b/CompatBot/Commands/BotStatus.cs @@ -22,8 +22,10 @@ internal static class BotStatus } .AddField("Current Uptime", Config.Uptime.Elapsed.AsShortTimespan(), true) .AddField("Discord Latency", $"{latency.TotalMilliseconds:0.0} ms", true); - if (!string.IsNullOrEmpty(Config.AzureComputerVisionKey)) + if (Config.AzureComputerVisionKey is {Length: >0}) embed.AddField("Max OCR Queue", MediaScreenshotMonitor.MaxQueueLength.ToString(), true); + else + embed.AddField("Max OCR Queue", "-", true); var osInfo = RuntimeInformation.OSDescription; if (Environment.OSVersion.Platform is PlatformID.Unix or PlatformID.MacOSX) osInfo = RuntimeInformation.RuntimeIdentifier; diff --git a/CompatBot/Commands/Explain.cs b/CompatBot/Commands/Explain.cs index 0bcc7a77..a656af2a 100644 --- a/CompatBot/Commands/Explain.cs +++ b/CompatBot/Commands/Explain.cs @@ -66,6 +66,7 @@ internal static class Explain memStream.Seek(0, SeekOrigin.Begin); explainMsg.AddFile(result.explanation.AttachmentFilename!, memStream); await ctx.RespondAsync(explainMsg).ConfigureAwait(false); + StatsStorage.IncExplainStat(term); } [Command("add"), RequiresBotModRole] diff --git a/CompatBot/Utils/Extensions/MemoryCacheExtensions.cs b/CompatBot/Utils/Extensions/MemoryCacheExtensions.cs index b67db816..4c9340b8 100644 --- a/CompatBot/Utils/Extensions/MemoryCacheExtensions.cs +++ b/CompatBot/Utils/Extensions/MemoryCacheExtensions.cs @@ -21,7 +21,7 @@ internal static class MemoryCacheExtensions var coherentState = stateField?.GetValue(memoryCache); if (coherentState is null) { - Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed"); + Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(coherentState)}"); return []; } @@ -34,7 +34,7 @@ internal static class MemoryCacheExtensions .FirstOrDefault(fi => fi.Name == "_nonStringEntries"); if (stringField is null || nonStringField is null) { - Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed"); + Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(stringField)}"); return []; } @@ -54,7 +54,7 @@ internal static class MemoryCacheExtensions var coherentState = stateField?.GetValue(memoryCache); if (coherentState is null) { - Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed"); + Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {nameof(coherentState)}"); return new(); } @@ -64,7 +64,7 @@ internal static class MemoryCacheExtensions var cacheEntries = (IDictionary?)field?.GetValue(coherentState); if (cacheEntries is null) { - Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed"); + Config.Log.Error($"Looks like {nameof(MemoryCache)} internals have changed in {cacheEntries}"); return new(0); } diff --git a/Tests/MemoryCacheExtensionTests.cs b/Tests/MemoryCacheExtensionTests.cs index 124ed48d..ce323706 100644 --- a/Tests/MemoryCacheExtensionTests.cs +++ b/Tests/MemoryCacheExtensionTests.cs @@ -16,10 +16,13 @@ public class MemoryCacheExtensionTests const string testVal = "vale13"; cache.Set(13, testVal); + cache.Set("bob", 69); Assert.Multiple(() => { Assert.That(cache.TryGetValue(13, out string? expectedVal), Is.True); Assert.That(expectedVal, Is.EqualTo(testVal)); + Assert.That(cache.TryGetValue("bob", out int? expectedValInt), Is.True); + Assert.That(expectedValInt, Is.EqualTo(69)); } ); Assert.That(cache.GetCacheKeys(), Has.Count.EqualTo(1)); @@ -32,6 +35,8 @@ public class MemoryCacheExtensionTests Assert.That(cache.GetCacheKeys(), Is.Empty); cache.Set(13, "val13"); + cache.Set("bob", 69); Assert.That(cache.GetCacheKeys(), Has.Count.EqualTo(1)); + Assert.That(cache.GetCacheKeys(), Has.Count.EqualTo(1)); } } \ No newline at end of file