From: Marius Gavrilescu Date: Thu, 24 Mar 2016 14:36:17 +0000 (+0200) Subject: Improve command regexps X-Git-Tag: 1.000~2 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=fbde5e292211baf3b5b288d5077918cbaa6e5d6b;p=app-statsbot.git Improve command regexps --- diff --git a/lib/App/Statsbot.pm b/lib/App/Statsbot.pm index fcc7959..8e03642 100644 --- a/lib/App/Statsbot.pm +++ b/lib/App/Statsbot.pm @@ -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; diff --git a/statsbot b/statsbot index 4c06d1a..de88ae2 100755 --- 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