X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FApp%2FStatsbot.pm;h=701c6c56e6bbf0beab018c2f309927440c323135;hb=a5a815022b423e52039da8bc69f4ca97d9cf7d66;hp=902f9d336668bd930d7ad6bc87d8e4ef57ae9033;hpb=d6102de2038794abd9388080c23d278632ef52e1;p=app-statsbot.git diff --git a/lib/App/Statsbot.pm b/lib/App/Statsbot.pm index 902f9d3..701c6c5 100644 --- a/lib/App/Statsbot.pm +++ b/lib/App/Statsbot.pm @@ -4,7 +4,7 @@ use 5.014000; use strict; use warnings; -our $VERSION = '0.001002'; +our $VERSION = '1.000'; use POE; use POE::Component::IRC::State; @@ -31,6 +31,15 @@ our $SSL = ''; our @CHANNELS; our $DB = '/var/lib/statsbot/db'; +{ + my %cfg = (debug => \$DEBUG, tick => \$TICK, nickname => \$NICKNAME, server => \$SERVER, port => \$PORT, ssl => \$SSL, channels => \@CHANNELS, db => \$DB); + for my $var (keys %cfg) { + my $key = "STATSBOT_\U$var"; + ${$cfg{$var}} = $ENV{$key} if exists $ENV{$key} && ref $cfg{$var} eq 'SCALAR'; + @{$cfg{$var}} = split ' ', $ENV{$key} if exists $ENV{$key} && ref $cfg{$var} eq 'ARRAY'; + } +} + my $dbh; my $insert; my $update; @@ -129,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; @@ -198,6 +207,11 @@ a channel. It is able to answer queries of the form "In the last