]> iEval git - app-statsbot.git/commitdiff
Improve command regexps
authorMarius Gavrilescu <marius@ieval.ro>
Thu, 24 Mar 2016 14:36:17 +0000 (16:36 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Thu, 24 Mar 2016 14:42:29 +0000 (16:42 +0200)
lib/App/Statsbot.pm
statsbot

index fcc79594eefc2656742758b52de94af9b3957aa3..8e03642918d06901de6d112590b651a6ea766b8a 100644 (file)
@@ -138,14 +138,14 @@ sub on_public{
        my ($targets,$message)=@_[ARG1,ARG2];
        my $botnick = _nick_name;
 
-       if ($message =~ /(?:$botnick[:,])?\s*!?help\s*(.*)/sx) {
+       if ($message =~ /^(?:$botnick[:,]\s*!?|\s*!)help/sx) {
                _yield(privmsg => $targets, 'Try !presence username interval [truncate]');
                _yield(privmsg => $targets, q/For example, !presence mgv '2 days'/);
                _yield(privmsg => $targets, q/or !presence mgv '1 year' 4/);
                return;
        }
 
-       return unless $message =~ /(?:$botnick[:,])?\s*!?presence\s*(.*)/sx;
+       return unless $message =~ /^(?:$botnick[:,])?\s*!?presence\s*(.*)/sx;
        my ($nick, $time, $truncate) = shellwords $1;
 
        $truncate//=-1;
index 4c06d1a407f972a2fc08c366af8d4d908ec74f4b..de88ae232a4a93c6ad8a027a787c9d8249edcf3d 100755 (executable)
--- a/statsbot
+++ b/statsbot
@@ -33,7 +33,10 @@ statsbot - simple IRC bot that tracks time spent in a channel
   # < mgv> !presence mgv
   # < mgv>   presence mgv '1 day'
   # < mgv> BOTNICK: !presence mgv '1 year' 2
-  # < mgv> BOTNICK:    presence   mgv
+  # < mgv> BOTNICK,    presence   mgv
+  # < mgv>   !help
+  # < mgv> BOTNICK:    help
+  # < mgv> BOTNICK,  help
 
 =head1 DESCRIPTION
 
This page took 0.03045 seconds and 4 git commands to generate.