From fbde5e292211baf3b5b288d5077918cbaa6e5d6b Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Thu, 24 Mar 2016 16:36:17 +0200 Subject: [PATCH] Improve command regexps --- lib/App/Statsbot.pm | 4 ++-- statsbot | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) 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 -- 2.39.2