]> iEval git - app-statsbot.git/blobdiff - lib/App/Statsbot.pm
Bump version and update Changes
[app-statsbot.git] / lib / App / Statsbot.pm
index 902f9d336668bd930d7ad6bc87d8e4ef57ae9033..701c6c56e6bbf0beab018c2f309927440c323135 100644 (file)
@@ -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 <time
 interval>, how much time did <nick> spend in this channel?".
 
 It is configured via global variables in the App::Statsbot package.
+These variables are initialized from environment variables with names
+of the form STATSBOT_DEBUG, STATSBOT_TICK, etc. In the case of array
+variables, the environment variable is treated as a space separated
+list. Each configuration variable has a default value used when it is
+not set explicitly or via the environment.
 
 =over
 
@@ -251,7 +265,7 @@ Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2013-2015 by Marius Gavrilescu
+Copyright (C) 2013-2016 by Marius Gavrilescu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.20.2 or,
This page took 0.02759 seconds and 4 git commands to generate.