diff options
| author | 2007-06-29 02:21:38 +0000 | |
|---|---|---|
| committer | 2007-06-29 02:21:38 +0000 | |
| commit | f52c9bd6e6e018ff0c45f1dea4ded2aeb4ae1427 (patch) | |
| tree | 395c0133072d89da4a936e0a180e836997c1cb56 /modules/inspect.pl | |
| parent | 6907da0a5da3d45a91c3ac4893e5b890200b27eb (diff) | |
lots of modularization done, needs testing and is unstable
Diffstat (limited to 'modules/inspect.pl')
| -rw-r--r-- | modules/inspect.pl | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/modules/inspect.pl b/modules/inspect.pl index fc66215..9b03ca1 100644 --- a/modules/inspect.pl +++ b/modules/inspect.pl @@ -1,14 +1,23 @@ +package ASM::Inspect; use warnings; use strict; use List::Util qw(first); +use Data::Dumper; %::ignored = (); +sub new +{ + my $module = shift; + my $self = {}; + bless($self); + return $self; +} sub inspect { - our ($conn, $event) = @_; + our ($self, $conn, $event) = @_; my (%conx, %monx); - our (%aonx, %dct, $rev, $chan, $id); + my (%aonx, %dct, $rev, $chan, $id); %aonx=(); %dct=(); $chan=""; $id=""; my (@dnsbl, @unpakt, @uniq, @cut); my ($match, $txtz, $iaddr); @@ -18,7 +27,7 @@ sub inspect { return if (defined(first { ( lc $event->{nick} eq lc $_ ) } @::eline)); return if (defined(first { ( lc $event->{user} eq lc $_ ) } @::eline)); return if (defined(first { ( lc $event->{host} eq lc $_ ) } @::eline)); - $iaddr = hostip($event->{host}); + $iaddr = gethostbyname($event->{host}); $rev = join('.', reverse(unpack('C4', $iaddr))).'.' if (defined $iaddr); %monx = defined($::channels->{channel}->{master}->{event}) ? %{$::channels->{channel}->{master}->{event}} : (); ## NB: isn't there a better way to do this with grep, somehow? @@ -33,8 +42,10 @@ sub inspect { next unless ( defined(first { lc $_ eq $event->{type} } split(/[,:; ]+/, $aonx{$id}{type}) ) ) || ( lc $event->{type} eq lc $aonx{$id}{type} ); # next unless ( defined($::classes->{class}->{$aonx{$id}{class}})); - eval "Classes::" . $aonx{$id}{class} . "();"; - warn $@ if $@; + $dct{$id} = $aonx{$id} if $::classes->check($aonx{$id}{class}, $aonx{$id}, $id, $event, $chan, $rev); +# my ($chk, $id, $event, $chan) = @_; +# eval "Classes::" . $aonx{$id}{class} . "();"; +# warn $@ if $@; } } foreach ( keys %dct ) { @@ -46,14 +57,14 @@ sub inspect { $::db->record($chan, $event->{nick}, $event->{user}, $event->{host}, $::sn{lc $event->{nick}}->{gecos}, $dct{$id}{risk}, $id, $dct{$id}{reason}); $txtz = "$dct{$id}{risk} risk threat: ". "Detected $event->{nick} $dct{$id}{reason} in $chan "; - $txtz = $txtz . commaAndify(getAlert(lc $chan, $dct{$id}{risk}, 'hilights')) if (getAlert(lc $chan, $dct{$id}{risk}, 'hilights')); - if (cs(lc $chan)->{op} ne 'no') { + $txtz = $txtz . ASM::Util->commaAndify(ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights')) if (ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights')); + if (ASM::Util->cs(lc $chan)->{op} ne 'no') { if ($event->{type} eq 'topic') { #restore old topic my $oldtopic = $::sc{lc $event->{to}->[0]}{topic}{text}; o_send( $conn, "topic $chan :$oldtopic"); o_send( $conn, "mode $chan +t"); } - eval "Actions::" . $dct{$id}{action} . "();"; + eval '$unmode = Actions::' . $dct{$id}{action} . '($conn, $event, $chan);'; warn $@ if $@; my $lconn=$conn; my $lunmode = $unmode; if ((int($dct{$id}{time}) ne 0) && ($unmode ne '')) { @@ -61,7 +72,12 @@ sub inspect { } } unless (defined($::ignored{lc $event->{nick}}) && ($::ignored{lc $event->{nick}} >= $::RISKS{$dct{$id}{risk}})) { - $conn->privmsg($_, $txtz) foreach getAlert($chan, $dct{$id}{risk}, 'msgs'); + print "alerting!\n"; + my @tgts = ASM::Util->getAlert($chan, $dct{$id}{risk}, 'msgs'); + print Dumper(\@tgts); + foreach my $tgt (@tgts) { + $conn->privmsg($tgt, $txtz); + } $::ignored{lc $nick} = $::RISKS{$dct{$id}{risk}}; $conn->schedule(15, sub { delete($::ignored{lc $nick})}); } @@ -69,8 +85,4 @@ sub inspect { } } -sub Inspect::killsub { - undef &inspect; -} - return 1; |
