/// <param name="CommandPrefix">The prefix that all commands in Imgur Comments must begin with, such as "@Tagaroo", not including trailing whitespace</param>
        /// <param name="Imgur">To reduce Imgur API bandwidth consumption, Replies to Comments are lazily loaded, only if needed, using this instance</param>
        public ImgurCommandParser(string CommandPrefix, ImgurInterfacer Imgur)
        {
            string CommandPrefixEscaped = Regex.Escape(CommandPrefix);

            this.Imgur = Imgur;

            this.Pattern_Command = new Regex(

                /*
                 * The expression for matching the command specifier should be the same as for matching a Taglist name in Pattern_Tag,
                 * as a Taglist name may appear instead of a command specifier
                 * as shorthand for the "tag" command.
                 * Any unrecognized commands are treated as "tag" commands.
                 */
                CommandPrefixEscaped + @" (?>[\p{Zs}\t]+) (?>([a-z0-9_-]+))",
                RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
                | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled
                );

            /*
             * Take care when permitting additional characters in Category names;
             * the expression will attempt to match as many Category names as possible,
             * which may stray beyond what the tagger thinks would be the end of the command.
             */
            this.Pattern_Tag = new Regex(@"
#Prefix, 'tag' command optional
\G " + CommandPrefixEscaped + @" (?: (?>[\p{Zs}\t]+) tag )?
#Capture Taglist name
#If adding permissible characters to Taglist names, be sure to update the Pattern_Command expression as well
(?>[\p{Zs}\t]+) (?>([a-z0-9_-]+))
#Capture Rating, optional
#If adding permissible characters to Category names, be sure to update the lookahead here as well
(?: (?>[\p{Zs}\t]+) ([SQE])(?![a-z0-9_-]) )?
#Capture Categories until unrecognized character
(?>(?:
(?>[\p{Zs}\t]+) (?>([a-z0-9_-]+))
)*)
",
                                         RegexOptions.IgnoreCase | RegexOptions.CultureInvariant |
                                         RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled
                                         );

            /*
             * Test Inputs:
             * @Tagaroo tag taglist-name
             * @Tagaroo taglist-name
             * @Tagaroo tag taglist-name S
             * @Tagaroo taglist-name S
             * @Tagaroo taglist-name S S-Category
             * @Tagaroo taglist-name S-Category
             * @Tagaroo taglist-name S-
             * @Tagaroo taglist-name S; #Should match excluding semicolon
             * @Tagaroo taglist-name S-Category S
             * @Tagaroo S S S S
             * @Tagaroo tag tag tag tag
             * @Tagaroo tag tag S tag tag
             * @Tagaroo tag
             */
        }
Esempio n. 2
0
 public ProcessLatestCommentsActivity(
     ImgurInterfacer Imgur,
     SettingsRepository RepositorySettings,
     CacheingTaglistRepository RepositoryTaglists,
     ProcessCommentActivity SubActivity
     )
 {
     this.Imgur = Imgur;
     this.RepositorySettings = RepositorySettings;
     this.SubActivity        = SubActivity;
     this.RepositoryTaglists = RepositoryTaglists;
 }
Esempio n. 3
0
 /// <param name="ApplicationShutdownLock">
 /// This should be the same instance as passed to other objects;
 /// this class will acquire a write lock on the lock
 /// before allowing the process to shutdown cleanly
 /// </param>
 public Program(
     ProcessLatestCommentsActivity ActivityProcessComments,
     ImgurInterfacer Imgur,
     DiscordInterfacer Discord,
     TaglistRepository RepositoryTaglists,
     SettingsRepository RepositorySettings,
     SingleThreadReadWriteLock ApplicationShutdownLock
     )
 {
     this.Imgur                   = Imgur;
     this.Discord                 = Discord;
     this.RepositoryTaglists      = RepositoryTaglists;
     this.RepositorySettings      = RepositorySettings;
     this.ActivityProcessComments = ActivityProcessComments;
     this.ApplicationShutdownLock = ApplicationShutdownLock;
 }
Esempio n. 4
0
 public RegisterUserCommand(TaglistRepository Repository, ImgurInterfacer Imgur, Discord.MessageSender MessageSender) : base(MessageSender)
 {
     this.Repository = Repository;
     this.Imgur      = Imgur;
 }
Esempio n. 5
0
 public RefreshImgurOAuthTokenCommand(ImgurInterfacer Imgur, Discord.MessageSender MessageSender) : base(MessageSender)
 {
     this.Imgur = Imgur;
 }
 public QueryImgurRemainingBandwidthCommand(ImgurInterfacer Imgur, Discord.MessageSender MessageSender) : base(MessageSender)
 {
     this.Imgur = Imgur;
 }
Esempio n. 7
0
 public ProcessTagCommandActivity(ImgurInterfacer Imgur, DiscordInterfacer Discord, TaglistRepository RepositoryTaglists)
 {
     this.Imgur              = Imgur;
     this.Discord            = Discord;
     this.RepositoryTaglists = RepositoryTaglists;
 }
 public ImgurUserIDCommand(ImgurInterfacer Imgur, Discord.MessageSender MessageSender) : base(MessageSender)
 {
     this.Imgur = Imgur;
 }