diff options
| author | 2015-09-24 01:32:11 +0000 | |
|---|---|---|
| committer | 2015-09-24 01:32:11 +0000 | |
| commit | 9b472795d26cd93d1bb58488ef60a062f5237295 (patch) | |
| tree | 8572778595d145176e720a1b7168c73adbd64ed4 /modules/log.pl | |
| parent | b93c3a24f14e0f64bc46b4945a65ae1bba62dc12 (diff) | |
Rework module paths
Diffstat (limited to 'modules/log.pl')
| -rw-r--r-- | modules/log.pl | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/modules/log.pl b/modules/log.pl deleted file mode 100644 index c2a2b72..0000000 --- a/modules/log.pl +++ /dev/null @@ -1,112 +0,0 @@ -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; - $self->{backlog} = {}; - bless($self); - return $self; -} - -sub incident -{ - my $self = shift; - my ($chan, $header) = @_; - $chan = lc $chan; - open(FH, '>>', 'dctlog.txt'); - print FH $header; - if (defined($self->{backlog}->{$chan})) { - print FH join('', @{$self->{backlog}->{$chan}}); - } - print FH "\n\n"; - close(FH); -} - -#writes out the backlog to a file which correlates to ASM's SQL actionlog table -sub sqlIncident -{ - my $self = shift; - my ($channel, $index) = @_; - $channel = lc $channel; - my @chans = split(/,/, $channel); - open(FH, '>', $self->{CONFIG}->{actiondir} . $index . '.txt'); - foreach my $chan (@chans) { - if (defined($self->{backlog}->{$chan})) { - say FH "$chan"; - say FH join('', @{$self->{backlog}->{$chan}}); - } - } - close(FH); -} - -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; - next if ($chan eq '$$*'); - $chan =~ s/^[@+]//; - if ($chan eq '*') { - ASM::Util->dprint("$event->{nick}: $event->{args}->[0]", 'snotice'); - next; - } - 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 ($event->{args}->[0])" 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 ($event->{args}->[0])" 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'; - my $nostamp = $_; - $_ = strftime($cfg->{timefmt}, @time) . $_ . "\n"; - my $line = $_; - my @backlog = (); - if (defined($self->{backlog}->{$chan})) { - @backlog = @{$self->{backlog}->{$chan}}; - if (scalar @backlog >= 30) { - shift @backlog; - } - } - push @backlog, $line; - $self->{backlog}->{$chan} = \@backlog; - if (open(FH, $path)) { # or die "Can't open $path: $!"; - print FH $line; - ASM::Util->dprint($line, 'logger'); - close(FH); - } else { - print "COULDN'T PRINT TO $path - $line"; - } - my $spy; - if (defined($::spy{$chan})) { - $spy = $::spy{$chan}; - } elsif (defined($::spy{lc $event->{nick}})) { - $spy = $::spy{lc $event->{nick}}; - } - if (defined($spy)) { - say $spy "$chan: $nostamp"; - } -# $_ >> io($path); - } -} - -1; |
