diff options
| author | 2007-07-26 00:46:31 +0000 | |
|---|---|---|
| committer | 2007-07-26 00:46:31 +0000 | |
| commit | 3790452619828dc2c5d27c13eeec7b67b3fe6eff (patch) | |
| tree | ad2940dfb841c15843e015cd2f80e8bedb5223e6 /modules/inspect.pl | |
| parent | 2e39d5b2b95c2e705fd962c9752070f816c1dfec (diff) | |
new commands like ;help, code optimizations, bugfixes, colors in the messages, and more\!
Diffstat (limited to 'modules/inspect.pl')
| -rw-r--r-- | modules/inspect.pl | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/modules/inspect.pl b/modules/inspect.pl index bed8a46..a995202 100644 --- a/modules/inspect.pl +++ b/modules/inspect.pl @@ -2,8 +2,8 @@ package ASM::Inspect; use warnings; use strict; -use Data::Dumper; -use List::Util qw(first); +#use Data::Dumper; +#use List::Util qw(first); %::ignored = (); sub new @@ -27,27 +27,29 @@ sub inspect { return if (defined($::eline{$nick}) || defined($::eline{lc $event->{user}}) || defined($::eline{lc $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}} : (); +# %monx = defined($::channels->{channel}->{master}->{event}) ? %{$::channels->{channel}->{master}->{event}} : (); ## NB: isn't there a better way to do this with grep, somehow? + %aonx = %{$::channels->{channel}->{master}->{event}}; foreach $chan ( @{$event->{to}} ) { next unless $chan =~ /^#/; - %conx = defined($::channels->{channel}->{lc $chan}->{event}) ? %{$::channels->{channel}->{lc $chan}->{event}} : (); - %aonx = (%monx, %conx); +# %conx = defined($::channels->{channel}->{lc $chan}->{event}) ? %{$::channels->{channel}->{lc $chan}->{event}} : (); +# %aonx = (%monx, %conx); foreach $id (keys %aonx) { - next unless ( defined(first { lc $_ eq $event->{type} } split(/[,:; ]+/, $aonx{$id}{type}) ) ) - || ( lc $event->{type} eq lc $aonx{$id}{type} ); + next unless ( grep { $event->{type} eq $_ } split(/[,:; ]+/, $aonx{$id}{type}) ); $dct{$id} = $aonx{$id} if $::classes->check($aonx{$id}{class}, $aonx{$id}, $id, $event, $chan, $rev); } } foreach ( keys %dct ) { - push( @override, split( /[ ,;]+/, $dct{$_}{override} ) ) if ( defined $dct{$_}{override} ); + if ( defined $dct{$_}{override} ) { + push( @override, split( /[ ,;]+/, $dct{$_}{override} ) ); + } } delete $dct{$_} foreach @override; foreach $chan (@{$event->{to}}) { foreach $id ( keys %dct ) { $::db->record($chan, $event->{nick}, $event->{user}, $event->{host}, $::sn{lc $event->{nick}}->{gecos}, $dct{$id}{risk}, $id, $dct{$id}{reason}); - $txtz = "\x02$dct{$id}{risk}\x02 risk threat: ". - "Detected \x02$event->{nick}\x02 $dct{$id}{reason} in $chan "; + $txtz = "\x03" . $::RCOLOR{$::RISKS{$dct{$id}{risk}}} . "\u$dct{$id}{risk}\x03 risk threat [\x02$chan\x02]: ". + "\x02$event->{nick}\x02 - $dct{$id}{reason}; ping "; $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 @@ -55,23 +57,23 @@ sub inspect { $::oq->o_send( $conn, "topic $chan :$oldtopic"); $::oq->o_send( $conn, "mode $chan +t"); } - eval '$unmode = Actions::' . $dct{$id}{action} . '($conn, $event, $chan);'; - warn $@ if $@; +# eval '$unmode = Actions::' . $dct{$id}{action} . '($conn, $event, $chan);'; + $unmode = $::actions->do($dct{$id}{action}, $conn, $event, $chan); my $lconn=$conn; my $lunmode = $unmode; if ((int($dct{$id}{time}) ne 0) && ($unmode ne '')) { - $conn->schedule(int($dct{$id}{time}), sub { print "Timer called!\n"; $::oq->o_send($lconn,$lunmode); }); + $conn->schedule(int($dct{$id}{time}), sub { $::oq->o_send($lconn,$lunmode); }); } } - unless (defined($::ignored{lc $event->{nick}}) && ($::ignored{lc $event->{nick}} >= $::RISKS{$dct{$id}{risk}})) { + unless (defined($::ignored{$event->{host}}) && ($::ignored{$event->{host}} >= $::RISKS{$dct{$id}{risk}})) { my @tgts = ASM::Util->getAlert($chan, $dct{$id}{risk}, 'msgs'); foreach my $tgt (@tgts) { $conn->privmsg($tgt, $txtz); } - $::ignored{lc $nick} = $::RISKS{$dct{$id}{risk}}; - $conn->schedule(15, sub { delete($::ignored{lc $nick})}); + $::ignored{$event->{host}} = $::RISKS{$dct{$id}{risk}}; + $conn->schedule(60, sub { delete($::ignored{$event->{host}})}); } } } } -return 1; +1; |
