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;
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;
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