forked from discord-net/Discord.Net
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for parsing multiple types of quotation marks in commands, …
…Fix discord-net#942 (discord-net#943) * Add ability to support different types of quotation marks * Added normal quotation mark to list of aliases, removed single quote mark * clean up leftover changes from testing * change quotation mark parsing to use a map of matching pairs * remove commented out code * Fix conventions of the command parser utility functions * change storage type of alias dictionary to be IReadOnlyDictionary * revert type of CommandServiceConfig QuotationMarkAliasMap to Dictionary * minor formatting changes to CommandParser * remove unnecessary whitespace * Move aliases outside of CommandInfo class * copy IReadOnlyDictionary to ImmutableDictionary * minor syntax changes in CommandServiceConfig * add newline before namespace for consistency * newline formatting tweak * simplification of GetMatch method for CommandParser * add more quote unicode punctuation pairs * add check for null value when building ImmutableDictionary * Move default alias map into a separate source file * Ensure that the collection passed into command service is not null
- Loading branch information
1 parent
b52af7a
commit cee71ef
Showing
5 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Globalization; | ||
|
||
namespace Discord.Commands | ||
{ | ||
/// <summary> | ||
/// Utility methods for generating matching pairs of unicode quotation marks for CommandServiceConfig | ||
/// </summary> | ||
internal static class QuotationAliasUtils | ||
{ | ||
/// <summary> | ||
/// Generates an IEnumerable of characters representing open-close pairs of | ||
/// quotation punctuation. | ||
/// </summary> | ||
internal static Dictionary<char, char> 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<char, char> { | ||
{'\"', '\"' }, | ||
{'«', '»' }, | ||
{'‘', '’' }, | ||
{'“', '”' }, | ||
{'„', '‟' }, | ||
{'‹', '›' }, | ||
{'‚', '‛' }, | ||
{'《', '》' }, | ||
{'〈', '〉' }, | ||
{'「', '」' }, | ||
{'『', '』' }, | ||
{'〝', '〞' }, | ||
{'﹁', '﹂' }, | ||
{'﹃', '﹄' }, | ||
{'"', '"' }, | ||
{''', ''' }, | ||
{'「', '」' }, | ||
{'(', ')' }, | ||
{'༺', '༻' }, | ||
{'༼', '༽' }, | ||
{'᚛', '᚜' }, | ||
{'⁅', '⁆' }, | ||
{'⌈', '⌉' }, | ||
{'⌊', '⌋' }, | ||
{'❨', '❩' }, | ||
{'❪', '❫' }, | ||
{'❬', '❭' }, | ||
{'❮', '❯' }, | ||
{'❰', '❱' }, | ||
{'❲', '❳' }, | ||
{'❴', '❵' }, | ||
{'⟅', '⟆' }, | ||
{'⟦', '⟧' }, | ||
{'⟨', '⟩' }, | ||
{'⟪', '⟫' }, | ||
{'⟬', '⟭' }, | ||
{'⟮', '⟯' }, | ||
{'⦃', '⦄' }, | ||
{'⦅', '⦆' }, | ||
{'⦇', '⦈' }, | ||
{'⦉', '⦊' }, | ||
{'⦋', '⦌' }, | ||
{'⦍', '⦎' }, | ||
{'⦏', '⦐' }, | ||
{'⦑', '⦒' }, | ||
{'⦓', '⦔' }, | ||
{'⦕', '⦖' }, | ||
{'⦗', '⦘' }, | ||
{'⧘', '⧙' }, | ||
{'⧚', '⧛' }, | ||
{'⧼', '⧽' }, | ||
{'⸂', '⸃' }, | ||
{'⸄', '⸅' }, | ||
{'⸉', '⸊' }, | ||
{'⸌', '⸍' }, | ||
{'⸜', '⸝' }, | ||
{'⸠', '⸡' }, | ||
{'⸢', '⸣' }, | ||
{'⸤', '⸥' }, | ||
{'⸦', '⸧' }, | ||
{'⸨', '⸩' }, | ||
{'【', '】'}, | ||
{'〔', '〕' }, | ||
{'〖', '〗' }, | ||
{'〘', '〙' }, | ||
{'〚', '〛' } | ||
}; | ||
} | ||
} | ||
} | ||
} |