From fd3533f7bb02aeed8d7ff7ad92febecf88b24c92 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Sun, 4 Feb 2018 17:23:59 -0800 Subject: [PATCH] Move default alias map into a separate source file --- .../CommandServiceConfig.cs | 72 +------------- .../Utilities/QuotationAliasUtils.cs | 95 +++++++++++++++++++ 2 files changed, 97 insertions(+), 70 deletions(-) create mode 100644 src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs diff --git a/src/Discord.Net.Commands/CommandServiceConfig.cs b/src/Discord.Net.Commands/CommandServiceConfig.cs index 91656cf72..9ab89c1bb 100644 --- a/src/Discord.Net.Commands/CommandServiceConfig.cs +++ b/src/Discord.Net.Commands/CommandServiceConfig.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Discord.Commands { @@ -20,75 +20,7 @@ namespace Discord.Commands /// Collection of aliases that can wrap strings for command parsing. /// represents the opening quotation mark and the value is the corresponding closing mark. - public Dictionary QuotationMarkAliasMap { get; set; } - = new Dictionary { - {'\"', '\"' }, - {'«', '»' }, - {'‘', '’' }, - {'“', '”' }, - {'„', '‟' }, - {'‹', '›' }, - {'‚', '‛' }, - {'《', '》' }, - {'〈', '〉' }, - {'「', '」' }, - {'『', '』' }, - {'〝', '〞' }, - {'﹁', '﹂' }, - {'﹃', '﹄' }, - {'"', '"' }, - {''', ''' }, - {'「', '」' }, - {'(', ')' }, - {'༺', '༻' }, - {'༼', '༽' }, - {'᚛', '᚜' }, - {'⁅', '⁆' }, - {'⌈', '⌉' }, - {'⌊', '⌋' }, - {'❨', '❩' }, - {'❪', '❫' }, - {'❬', '❭' }, - {'❮', '❯' }, - {'❰', '❱' }, - {'❲', '❳' }, - {'❴', '❵' }, - {'⟅', '⟆' }, - {'⟦', '⟧' }, - {'⟨', '⟩' }, - {'⟪', '⟫' }, - {'⟬', '⟭' }, - {'⟮', '⟯' }, - {'⦃', '⦄' }, - {'⦅', '⦆' }, - {'⦇', '⦈' }, - {'⦉', '⦊' }, - {'⦋', '⦌' }, - {'⦍', '⦎' }, - {'⦏', '⦐' }, - {'⦑', '⦒' }, - {'⦓', '⦔' }, - {'⦕', '⦖' }, - {'⦗', '⦘' }, - {'⧘', '⧙' }, - {'⧚', '⧛' }, - {'⧼', '⧽' }, - {'⸂', '⸃' }, - {'⸄', '⸅' }, - {'⸉', '⸊' }, - {'⸌', '⸍' }, - {'⸜', '⸝' }, - {'⸠', '⸡' }, - {'⸢', '⸣' }, - {'⸤', '⸥' }, - {'⸦', '⸧' }, - {'⸨', '⸩' }, - {'【', '】'}, - {'〔', '〕' }, - {'〖', '〗' }, - {'〘', '〙' }, - {'〚', '〛' } - }; + public Dictionary QuotationMarkAliasMap { get; set; } = QuotationAliasUtils.GetDefaultAliasMap; /// Determines whether extra parameters should be ignored. public bool IgnoreExtraArgs { get; set; } = false; diff --git a/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs b/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs new file mode 100644 index 000000000..15a08b9b3 --- /dev/null +++ b/src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Globalization; + +namespace Discord.Commands +{ + /// + /// Utility methods for generating matching pairs of unicode quotation marks for CommandServiceConfig + /// + internal static class QuotationAliasUtils + { + /// + /// Generates an IEnumerable of characters representing open-close pairs of + /// quotation punctuation. + /// + internal static Dictionary GetDefaultAliasMap + { + get + { + // Output of a gist provided by https://gist.github.com/ufcpp + // https://gist.github.com/ufcpp/5b2cf9a9bf7d0b8743714a0b88f7edc5 + // This was not used for the implementation because of incompatibility with netstandard1.1 + return new Dictionary { + {'\"', '\"' }, + {'«', '»' }, + {'‘', '’' }, + {'“', '”' }, + {'„', '‟' }, + {'‹', '›' }, + {'‚', '‛' }, + {'《', '》' }, + {'〈', '〉' }, + {'「', '」' }, + {'『', '』' }, + {'〝', '〞' }, + {'﹁', '﹂' }, + {'﹃', '﹄' }, + {'"', '"' }, + {''', ''' }, + {'「', '」' }, + {'(', ')' }, + {'༺', '༻' }, + {'༼', '༽' }, + {'᚛', '᚜' }, + {'⁅', '⁆' }, + {'⌈', '⌉' }, + {'⌊', '⌋' }, + {'❨', '❩' }, + {'❪', '❫' }, + {'❬', '❭' }, + {'❮', '❯' }, + {'❰', '❱' }, + {'❲', '❳' }, + {'❴', '❵' }, + {'⟅', '⟆' }, + {'⟦', '⟧' }, + {'⟨', '⟩' }, + {'⟪', '⟫' }, + {'⟬', '⟭' }, + {'⟮', '⟯' }, + {'⦃', '⦄' }, + {'⦅', '⦆' }, + {'⦇', '⦈' }, + {'⦉', '⦊' }, + {'⦋', '⦌' }, + {'⦍', '⦎' }, + {'⦏', '⦐' }, + {'⦑', '⦒' }, + {'⦓', '⦔' }, + {'⦕', '⦖' }, + {'⦗', '⦘' }, + {'⧘', '⧙' }, + {'⧚', '⧛' }, + {'⧼', '⧽' }, + {'⸂', '⸃' }, + {'⸄', '⸅' }, + {'⸉', '⸊' }, + {'⸌', '⸍' }, + {'⸜', '⸝' }, + {'⸠', '⸡' }, + {'⸢', '⸣' }, + {'⸤', '⸥' }, + {'⸦', '⸧' }, + {'⸨', '⸩' }, + {'【', '】'}, + {'〔', '〕' }, + {'〖', '〗' }, + {'〘', '〙' }, + {'〚', '〛' } + }; + } + } + } +}