########################################### # Log.pm - Logging Plugin for the IRC Bot # Mike Schilli, 2009 (m@perlmeister.com) ########################################### package Bot::BasicBot::Pluggable::Module::Log; use warnings; use strict; use base qw(Bot::BasicBot::Pluggable::Module); use Cache::Historical 0.03; use Log::Log4perl qw(:easy); our $SQLITE_FILE = "irclog.dat"; ########################################### sub init { ########################################### my($self) = @_; $self->{logbot_cache} = Cache::Historical->new( sqlite_file => $SQLITE_FILE, ); } ########################################### sub help { ########################################### return "Logs chats in SQLite"; } ########################################### sub told { ########################################### my ($self, $msg) = @_; my $val = "$msg->{who}: $msg->{body}"; my $key = $msg->{channel}; my $dt = DateTime->now( time_zone => "local"); DEBUG "$dt $val"; $self->{logbot_cache}->set( $dt, $key, $val ); return ""; } 1;