From 2702c45b4f1531c8c23d148e4baf6874db04d3e0 Mon Sep 17 00:00:00 2001 From: Ske Date: Sat, 13 Jun 2020 22:20:24 +0200 Subject: [PATCH] General bits of cleanup --- PluralKit.Bot/Lists/SortFilterOptions.cs | 3 ++- PluralKit.Bot/Proxy/ProxyMatcher.cs | 6 +++--- PluralKit.Bot/Proxy/ProxyService.cs | 2 +- PluralKit.Bot/Proxy/ProxyTagParser.cs | 15 --------------- .../Utils/HandlerQueue.cs | 2 +- 5 files changed, 7 insertions(+), 21 deletions(-) rename {PluralKit.Bot => PluralKit.Core}/Utils/HandlerQueue.cs (98%) diff --git a/PluralKit.Bot/Lists/SortFilterOptions.cs b/PluralKit.Bot/Lists/SortFilterOptions.cs index de5eed6c..2b5f164f 100644 --- a/PluralKit.Bot/Lists/SortFilterOptions.cs +++ b/PluralKit.Bot/Lists/SortFilterOptions.cs @@ -64,7 +64,8 @@ namespace PluralKit.Bot { PrivacyFilter.PrivateOnly => PrivacyLevel.Private, PrivacyFilter.PublicOnly => PrivacyLevel.Public, - PrivacyFilter.All => null + PrivacyFilter.All => null, + _ => throw new ArgumentOutOfRangeException($"Unknown privacy filter {PrivacyFilter}") }, Filter, SearchInDescription); private IEnumerable Sort(IEnumerable input) diff --git a/PluralKit.Bot/Proxy/ProxyMatcher.cs b/PluralKit.Bot/Proxy/ProxyMatcher.cs index 339e7e8c..d4f81081 100644 --- a/PluralKit.Bot/Proxy/ProxyMatcher.cs +++ b/PluralKit.Bot/Proxy/ProxyMatcher.cs @@ -9,10 +9,10 @@ namespace PluralKit.Bot { public class ProxyMatcher { - public static readonly Duration LatchExpiryTime = Duration.FromHours(6); + private static readonly Duration LatchExpiryTime = Duration.FromHours(6); - private IClock _clock; - private ProxyTagParser _parser; + private readonly IClock _clock; + private readonly ProxyTagParser _parser; public ProxyMatcher(ProxyTagParser parser, IClock clock) { diff --git a/PluralKit.Bot/Proxy/ProxyService.cs b/PluralKit.Bot/Proxy/ProxyService.cs index 6e38c8ab..f96297cb 100644 --- a/PluralKit.Bot/Proxy/ProxyService.cs +++ b/PluralKit.Bot/Proxy/ProxyService.cs @@ -18,7 +18,7 @@ namespace PluralKit.Bot { public class ProxyService { - public static readonly TimeSpan MessageDeletionDelay = TimeSpan.FromMilliseconds(1000); + private static readonly TimeSpan MessageDeletionDelay = TimeSpan.FromMilliseconds(1000); private readonly LogChannelService _logChannel; private readonly IDatabase _db; diff --git a/PluralKit.Bot/Proxy/ProxyTagParser.cs b/PluralKit.Bot/Proxy/ProxyTagParser.cs index c4f84423..bdef419c 100644 --- a/PluralKit.Bot/Proxy/ProxyTagParser.cs +++ b/PluralKit.Bot/Proxy/ProxyTagParser.cs @@ -1,5 +1,4 @@ #nullable enable -using System; using System.Collections.Generic; using System.Linq; @@ -49,20 +48,6 @@ namespace PluralKit.Bot return false; } - public bool TryMatchTags(string input, ProxyTag tag, out string inner) - { - // This just wraps TryMatchTagsInner w/ support for leading mentions - var leadingMention = ExtractLeadingMention(ref input); - - inner = ""; - if (!TryMatchTagsInner(input, tag, out var innerRaw)) return false; - - // Add leading mentions back - inner = leadingMention == null ? innerRaw : $"{leadingMention} {innerRaw}"; - return true; - - } - private bool TryMatchTagsInner(string input, ProxyTag tag, out string inner) { inner = ""; diff --git a/PluralKit.Bot/Utils/HandlerQueue.cs b/PluralKit.Core/Utils/HandlerQueue.cs similarity index 98% rename from PluralKit.Bot/Utils/HandlerQueue.cs rename to PluralKit.Core/Utils/HandlerQueue.cs index 732194c5..abeee1ae 100644 --- a/PluralKit.Bot/Utils/HandlerQueue.cs +++ b/PluralKit.Core/Utils/HandlerQueue.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using NodaTime; -namespace PluralKit.Bot +namespace PluralKit.Core { public class HandlerQueue {