summaryrefslogtreecommitdiffstats
path: root/modules/log.pl
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-06-28 23:48:48 +0000
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2007-06-28 23:48:48 +0000
commit6907da0a5da3d45a91c3ac4893e5b890200b27eb (patch)
tree5a61df15a30b6d0aefa6c6e72e7eab2d8f03de1f /modules/log.pl
parent638d9eae9e63755e26f9843985597e6f1c7c5f8e (diff)
modularized stuff, fixed alert logic, simplified stuff, updated TODO
Diffstat (limited to 'modules/log.pl')
-rw-r--r--modules/log.pl32
1 files changed, 22 insertions, 10 deletions
diff --git a/modules/log.pl b/modules/log.pl
index 6381110..19b44b3 100644
--- a/modules/log.pl
+++ b/modules/log.pl
@@ -1,19 +1,35 @@
use warnings;
use strict;
+package ASM::Log;
+
use String::Interpolate qw(interpolate);
+use IO::All;
+use POSIX qw(strftime);
+use Data::Dumper;
+
+sub new
+{
+ my $module = shift;
+ my $config = shift;
+ my $self = {};
+ $self->{CONFIG} = $config;
+ bless($self);
+ return $self;
+}
sub logg
{
+ my $self = shift;
my ($event) = @_;
+ my $cfg = $self->{CONFIG};
my @chans = @{$event->{to}};
- my $fh;
@chans = ( $event->{args}->[0] ) if ($event->{type} eq 'kick');
- my @time = ($::settings->{log}->{zone} eq 'local') ? localtime : gmtime;
- foreach my $chan ( @chans)
+ my @time = ($cfg->{zone} eq 'local') ? localtime : gmtime;
+ foreach my $chan ( @chans )
{
$chan = lc $chan;
- io(interpolate($::settings->{log}->{dir}))->mkpath;
+ io(interpolate($cfg->{dir}))->mkpath;
$_='';
$_ = "<$event->{nick}> $event->{args}->[0]" if $event->{type} eq 'public';
$_ = "*** $event->{nick} has joined $chan" if $event->{type} eq 'join';
@@ -26,13 +42,9 @@ sub logg
$_ = "*** $event->{nick} sets mode: ".join(" ",@{$event->{args}}) if $event->{type} eq 'mode';
$_ = "*** $event->{nick} changes topic to \"$event->{args}->[0]\"" if $event->{type} eq 'topic';
print Dumper($event) if ($_ eq '');
- $_ = interpolate(strftime($::settings->{log}->{timefmt}, @time)) . $_ . "\n" unless $_ eq '';
- $_ >> io(interpolate($::settings->{log}->{dir}).'/'.interpolate(strftime($::settings->{log}->{filefmt}, @time))) unless ($_ eq '');
+ $_ = interpolate(strftime($cfg->{timefmt}, @time)) . $_ . "\n" unless $_ eq '';
+ $_ >> io(interpolate($cfg->{dir}).'/'.interpolate(strftime($cfg->{filefmt}, @time))) unless ($_ eq '');
}
}
-sub Log::killsub {
- undef &logg;
-}
-
return 1;