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;
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
=back
+=head1 ENVIRONMENT
+
+All options can be passed via the environment. If an option is passed both as an environment variable and as an argument, the argument takes priority.
+
+=over
+
+=item B<STATSBOT_DEBUG>=I<1>
+
+Equivalent to B<--debug>.
+
+=item B<STATSBOT_TICK>=I<60>
+
+Equivalent to B<--tick>=I<60>.
+
+=item B<STATSBOT_NICKNAME>=I<"timebot">
+
+Equivalent to B<--nickname>=I<"timebot">.
+
+=item B<STATSBOT_SERVER>=I<"irc.oftc.net">
+
+Equivalent to B<--server>=I<"irc.oftc.net">.
+
+=item B<STATSBOT_PORT>=I<6697>
+
+Equivalent to B<--port>=I<6697>.
+
+=item B<STATSBOT_SSL>=I<1>
+
+Equivalent to B<--ssl>.
+
+=item B<STATSBOT_CHANNELS>=I<"#mychan #otherchan">
+
+Equivalent to B<--channel>=I<#mychan> B<--channel>=I<#otherchan>.
+
+=item B<STATSBOT_DB>=I<"/path/to/some/file.sqlite">
+
+Equivalent to B<--db>=I<"/path/to/some/file.sqlite">.
+
+=back
+
=head1 SEE ALSO
L<App::Statsbot>