blob: 6f25c481bba1f0ed1c51c03f249fec21b56ecd62 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package ASM::Log;
use warnings;
use strict;
#use IO::All;
use POSIX qw(strftime);
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}};
@chans = ( $event->{args}->[0] ) if ($event->{type} eq 'kick');
my @time = ($cfg->{zone} eq 'local') ? localtime : gmtime;
foreach my $chan ( @chans )
{
$chan = lc $chan;
if (substr($chan, 0, 1) eq '@') {
$chan = substr($chan, 1);
}
my $path = ">>$cfg->{dir}${chan}/${chan}" . strftime($cfg->{filefmt}, @time);
$_ = '';
$_ = "<$event->{nick}> $event->{args}->[0]" if $event->{type} eq 'public';
$_ = "*** $event->{nick} has joined $chan" if $event->{type} eq 'join';
$_ = "*** $event->{nick} has left $chan" if $event->{type} eq 'part';
$_ = "* $event->{nick} $event->{args}->[0]" if $event->{type} eq 'caction';
$_ = "*** $event->{nick} is now known as $event->{args}->[0]" if $event->{type} eq 'nick';
$_ = "*** $event->{nick} has quit IRC" if $event->{type} eq 'quit';
$_ = "*** $event->{to}->[0] was kicked by $event->{nick}" if $event->{type} eq 'kick';
$_ = "-$event->{nick}- $event->{args}->[0]" if $event->{type} eq 'notice';
$_ = "*** $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';
$_ = strftime($cfg->{timefmt}, @time) . $_ . "\n";
my $line = $_;
open(FH, $path) or die "Can't open $path: $!";
print FH $line;
close(FH);
# $_ >> io($path);
}
}
1;
|