use strict;
use warnings;
-our $VERSION = '0.001';
+our $VERSION = '0.001002';
use POE;
use POE::Component::IRC::State;
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;
$_[KERNEL]->delay(tick => $TICK);
$irc->plugin_add(CTCP => POE::Component::IRC::Plugin::CTCP->new(
+ version => "Statsbot/$VERSION",
+ source => 'https://metacpan.org/pod/App::Statsbot',
userinfo => 'A bot which keeps logs and computes channel statistics',
clientinfo => 'PING VERSION CLIENTINFO USERINFO SOURCE',
));
my ($targets,$message)=@_[ARG1,ARG2];
my $botnick = _nick_name;
- if ($message =~ /(?:$botnick[:,])?\s*!?help\s*(.*)/) {
- _yield(privmsg => $targets, "Try !presence username interval [truncate]");
- _yield(privmsg => $targets, "For example, !presence mgv '2 days'");
- _yield(privmsg => $targets, "or !presence mgv '1 year' 4");
+ 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;
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