diff options
| author | 2007-07-26 00:46:31 +0000 | |
|---|---|---|
| committer | 2007-07-26 00:46:31 +0000 | |
| commit | 3790452619828dc2c5d27c13eeec7b67b3fe6eff (patch) | |
| tree | ad2940dfb841c15843e015cd2f80e8bedb5223e6 | |
| parent | 2e39d5b2b95c2e705fd962c9752070f816c1dfec (diff) | |
new commands like ;help, code optimizations, bugfixes, colors in the messages, and more\!
| -rw-r--r-- | config-default/channels.xml | 55 | ||||
| -rw-r--r-- | config-default/commands.xml | 14 | ||||
| -rw-r--r-- | config-default/users.xml | 3 | ||||
| -rwxr-xr-x | meta.pl | 1 | ||||
| -rw-r--r-- | modules/actions.pl | 36 | ||||
| -rw-r--r-- | modules/classes.pl | 93 | ||||
| -rw-r--r-- | modules/event.pl | 15 | ||||
| -rw-r--r-- | modules/inspect.pl | 36 | ||||
| -rw-r--r-- | modules/util.pl | 30 |
9 files changed, 186 insertions, 97 deletions
diff --git a/config-default/channels.xml b/config-default/channels.xml index de9800b..7633dbb 100644 --- a/config-default/channels.xml +++ b/config-default/channels.xml @@ -1,6 +1,9 @@ <channels> <channel id="##asb-meta" op="no" /> - <channel id="##asb-nexus" op="when" /> + <channel id="##asb-nexus" op="when"> + <hilights></hilights> + <msgs></msgs> + </channel> <channel id="##asb-testing" op="when"> <hilights> <low>a</low> @@ -16,7 +19,6 @@ <hilights> <low>WildPikachu</low> <low>nalioth</low> - <low>seanw</low> <low>quux</low> <low>denny</low> <low>Fieldy</low> @@ -31,16 +33,13 @@ <channel id="##linux-ops" op="no"> <hilights> <opalert>WildPikachu</opalert> - <opalert>seanw</opalert> <opalert>quux</opalert> <opalert>denny</opalert> <opalert>Fieldy</opalert> <opalert>numist</opalert> <opalert>PhilKC</opalert> </hilights> - <msgs> - <opalert>##linux-ops</opalert> - </msgs> + <msgs opalert="##linux-ops" /> </channel> <channel id="##windows" op="no"> <hilights> @@ -48,10 +47,10 @@ <low>quux</low> <low>HentaiXP</low> <low>TechSalvager</low> - <low>seanw</low> <low>njan</low> <low>JonathanD</low> <low>Cpudan80</low> + <low>AndrewB</low> </hilights> <msgs></msgs> </channel> @@ -64,8 +63,12 @@ <debug>Shadow_mil</debug> <debug>newmanbe</debug> </hilights> + <msgs></msgs> </channel> <channel id="#wikimedia" op="no"> + <hilights> + <debug>Mbimmler</debug> + </hilights> <msgs> <low>#wikimedia-ops</low> </msgs> @@ -91,28 +94,28 @@ <msgs></msgs> </channel> <channel id="#wikipedia" op="no"> - <event id="autorem_2" action="fmod_wiki" class="re" override="autoremove" reason="on chanserv autoremove" risk="info" time="0" type="raw">^mode \S+ \+b (.*)$</event> - <event id="part_fags" action="ban" class="re" reason="parted with 'Fags!'" risk="low" time="0" type="part">.*Fags! Fags! Fags!.*</event> <hilights> - <low>seanw</low> + <debug>Cbrown1023</debug> + <debug>Sean_William</debug> + <debug>ST47</debug> + <info>Karlprof</info> <low>Pilotguy</low> <low>Eagle-101</low> <low>Mbimmler</low> <low>skenmy</low> <low>Ral315</low> - <low>Karlprof</low> <low>tomaw</low> <low>Fabexplosive</low> <low>Krimpet</low> - <low>ST47</low> <low>AndrewB</low> <low>stylus</low> <low>Martinp23</low> - <low>Soms</low> <low>Daniel-Bryant</low> <low>amidaniel</low> <low>Gracenotes</low> <low>SWATJester</low> + <low>njan</low> + <low>mike42</low> </hilights> <msgs> <debug>#wikimedia-ops</debug> @@ -121,12 +124,12 @@ <channel id="#wikipedia-en" op="yes"> <hilights> <debug>White_Cat</debug> + <debug>Cometstyles</debug> <low>AppleBoy</low> <low>Soms</low> - <low>Pilotguy</low> <low>ST47</low> - <low>seanw</low> <low>Martinp23</low> + <low>Cbrown1023</low> </hilights> <msgs> <debug>#wikimedia-ops</debug> @@ -142,7 +145,6 @@ </channel> <channel id="#wikipedia-overflow" op="no"> <hilights> - <low>seanw</low> <low>Eagle-101</low> <low>Mbimmler</low> <low>Pilotguy</low> @@ -154,25 +156,31 @@ </msgs> </channel> <channel id="#wikipedia-social" op="no"> + <hilights> + <debug>ST47</debug> + </hilights> <msgs> <low>#wikimedia-ops</low> </msgs> </channel> + <channel id="Mbimmler"> + <hilights></hilights> + </channel> <channel id="default" op="no"> <event id="flood-15to45" action="none" class="floodqueue" reason="flooding 15 to 45" risk="low" time="0" type="public">15:45</event> </channel> <channel id="master"> <event id="autoremove" action="none" class="re" reason="on chanserv autoremove" risk="info" time="0" type="part">requested by ChanServ</event> <event id="badurl1" action="ban" class="re" reason="sending spam url" risk="medium" time="0" type="public">tinyurl\.com/ypvk4n</event> + <event id="blacklist" action="none" class="strbl" reason="sending pm matching string blacklist" risk="low" time="0" type="public">blah</event> <event id="ctcp-dcc" action="ban" class="re" reason="ctcp-dcc" risk="high" time="0" type="cdcc">.*</event> <event id="dcc" action="ban" class="re" override="dcc-medium" reason="using the DC.C SE.ND exploit" risk="high" time="0" type="public">^DCC SEND |\bDCC SEND "?[A-Za-z0-9]+"? \d+ \d+ \d+</event> <event id="dcc-medium" action="ban" class="re" reason="using the DC.C SE.ND exploit" risk="medium" time="0" type="public">DCC SEND </event> + <event id="dcc-part" action="ban" class="re" reason="using the DC.C SE.ND exploit in a part message" risk="high" time="0" type="part">DCC SEND </event> <event id="dcc-topic" action="ban" class="re" reason="setting a bad topic" risk="medium" time="0" type="topic">\bDCC SEND </event> <event id="ddos_countdown" action="none" class="re" reason="doing the ddos countdown thing" risk="medium" time="0" type="public">^... DDOS COUNTDOWN.*</event> - <event id="dosrequest" action="none" class="re" reason="requesting a DoS" risk="medium" time="0" type="public">via paypal if you DoS somone for</event> <event id="dronebl" action="ban" class="dnsbl" override="ahbl" reason="in dnsbl.dronebl.org" risk="info" time="0" type="join">dnsbl.dronebl.org</event> <event id="efnet_rbl" action="none" class="dnsbl" reason="in rbl.efnet.org" risk="info" time="0" type="join">rbl.efnet.org</event> - <event id="exoticforum" action="ban" class="re" reason="link spam" risk="low" time="0" type="public">http://exotics\.ezbbforum\.com</event> <event id="flood-10to30" action="none" class="floodqueue" reason="flooding (10 messages per 30 seconds)" risk="low" time="0" type="public">10:30</event> <event id="flood-5to3" action="quiet" class="floodqueue" reason="flooding (5 messages per 3 seconds)" risk="low" time="10" type="public">5:3</event> <event id="genspam1" action="none" class="re" reason="generic spamming" risk="debug" time="0" type="public">([^ ]{4,} +)\1{5,}</event> @@ -181,21 +189,18 @@ <event id="keylogger" action="ban" class="re" override="keylogger-medium" reason="using the norton start-key-logger exploit" risk="high" time="0" type="public">^startkeylogger$|^stopkeylogger$</event> <event id="keylogger-medium" action="ban" class="re" reason="using the norton start-key-logger exploit" risk="medium" time="0" type="public">\bstartkeylogger\b|\bstopkeylogger\b</event> <event id="last_measure_regex" action="kban" class="re" reason="posting what appears to be a last measure link" risk="medium" time="0" type="public">http://\S+\.on\.nimp\.org</event> - <event id="lesbian" action="ban" class="re" reason="bad nick match (lesbian..)" risk="medium" time="0" type="join">^lesbian..$</event> + <event id="levenflood" action="none" class="levenflood" override="flood-5to3" reason="levenshtein flood match" risk="debug" time="0" type="public">contentisuseless</event> <event id="magical" action="none" class="ident" reason="typical w00t ident" risk="info" time="0" type="join">i=magical</event> <event id="massflood" action="ban" class="splitflood" reason="distributed flooding" risk="high" time="0" type="public,part,caction">5:3</event> - <event id="massflood2" action="ban" class="splitflood" reason="distributed flooding" risk="medium" time="0" type="caction">5:3</event> <event id="nickspam" action="ban" class="nickspam" reason="nickspamming" risk="high" time="0" type="public">150:20</event> <event id="notice" action="ban" class="re" reason="sending a notice to the channel" risk="high" time="0" type="notice">.*</event> <event id="redarmyoflol" action="ban" class="re" reason="parting with 'red army of lol'" risk="low" time="0" type="part">RED ARMY OF LOL</event> <event id="sms_spam" action="none" class="re" reason="spam link / virus" risk="low" time="0" type="public">\.com/sms.exe</event> - <event id="weirdspam_1" action="none" class="re" reason="wwe mass murderer nonsense" risk="medium" time="0" type="public">hello sir, my name is Chris Benoit and I am a WWE MASS MURDERER.</event> - <event id="wikifags2" action="none" class="re" nocase="nocase" reason="saying 'sure are a lot of wikifag'..." risk="low" time="0" type="public">sure are a ?lot of wikifag</event> - <event id="dcc-part" action="ban" class="re" reason="using the DC.C SE.ND exploit in a part message" risk="high" time="0" type="part">DCC SEND </event> - <event id="levenflood" action="none" class="levenflood" reason="levenshtein flood match" risk="debug" time="0" type="public" override="flood-5to3">contentisuseless</event> - <event id="blacklist" action="none" class="strbl" reason="sending pm matching string blacklist" risk="low" time="0" type="public">blah</event> + <event id="wikifags2" action="none" class="re" reason="saying 'sure are a lot of wikifag'..." risk="low" time="0" type="public">(?i)^sure are a ?lot of .*fags? in here</event> <hilights> <debug>AfterDeath</debug> + <low>alindeman</low> + <low>seanw</low> </hilights> <msgs> <debug>##asb-nexus</debug> diff --git a/config-default/commands.xml b/config-default/commands.xml index 8353b0f..eedf584 100644 --- a/config-default/commands.xml +++ b/config-default/commands.xml @@ -1,4 +1,9 @@ <commands> + <command cmd="^;help$"> + <![CDATA[ + $conn->privmsg($event->{to}->[0], "help is at http://meta.wikimedia.org/wiki/User:WHeimbigner/AntiSpamMeta"); + ]]> + </command> <command cmd="^;query (\S+) (\S+)$"> <![CDATA[ my $channel = $1; @@ -178,15 +183,16 @@ </command> <command cmd="^;exempt (.*)" flag="o"> <![CDATA[ - $::eline{lc $1} = 1; - lc $1 . "\n" >> io 'exempt.txt'; - $conn->privmsg($event->{to}->[0], lc $1 . " exempted"); + my $x = lc $1; + $::eline{$x} = 1; + $x . "\n" >> io 'exempt.txt'; + $conn->privmsg($event->{to}->[0], $x . " exempted"); ]]> </command> <command cmd="^\!ops *(.*)"> <![CDATA[ my $hilite=ASM::Util->commaAndify(ASM::Util->getAlert($event->{to}->[0], 'opalert', 'hilights')); - $conn->privmsg($_, "$hilite: $event->{nick} wants your attention ($1) ") foreach ASM::Util->getAlert($event->{to}->[0], 'opalert', 'msgs'); + $conn->privmsg($_, "[$event->{to}->[0]] - $event->{nick} wants op attention ($1) $hilite") foreach ASM::Util->getAlert($event->{to}->[0], 'opalert', 'msgs'); ]]> </command> <command cmd="^;re(load|hash) exempts" flag="a"> diff --git a/config-default/users.xml b/config-default/users.xml index dc2046a..0c59b57 100644 --- a/config-default/users.xml +++ b/config-default/users.xml @@ -4,7 +4,8 @@ <person id="dmcdevit" flags="oat" host="IDENTIFY" /> <person id="filiated" flags="odat" host="IDENTIFY" /> <person id="mark_ryan" flags="ot" host="wikimedia/mark" /> - <person id="seanw" flags="oat" host="freenode/staff/wikimedia.sean-whitton" /> + <person id="sean_william" flags="a" host="IDENTIFY" /> + <person id="seanw" flags="odat" host="freenode/staff/wikimedia.sean-whitton" /> <person id="slowking_man" flags="ot" host="IDENTIFY" /> <person id="st47" flags="oat" host="IDENTIFY" /> <person id="wildpikachu" flags="odat" host="about/linux/staff/wildpikachu" /> @@ -54,6 +54,7 @@ sub init { $::commander = ASM::Commander->new(); $::event = ASM::Event->new($conn, $::inspector); $::classes = ASM::Classes->new(); + $::actions = ASM::Actions->new(); my @eline=io('exempt.txt')->getlines; chomp @eline; foreach my $item (@eline) { diff --git a/modules/actions.pl b/modules/actions.pl index 386e51a..08bf1be 100644 --- a/modules/actions.pl +++ b/modules/actions.pl @@ -1,35 +1,57 @@ +package ASM::Actions; use strict; use warnings; -#package Actions; +sub new +{ + my $module = shift; + my $self = {}; + my $tbl = { + "ban" => \&ban, + "kban" => \&kban, + "kick" => \&kick, + "none" => \&none, + "quiet" => \&quiet, + }; + $self->{ftbl} = $tbl; + bless($self); + return $self; +} + +sub do +{ + my $self = shift; + my $item = shift; + return $self->{ftbl}->{$item}->(@_); +} -sub Actions::ban { +sub ban { my ($conn, $event, $chan) = @_; $::oq->o_send( $conn, "mode $chan +b *!*\@$event->{host}" ); return "mode $chan -b *!*\@$event->{host}"; } -sub Actions::kban { +sub kban { my ($conn, $event, $chan) = @_; $::oq->o_send($conn, "mode $chan +b *!*\@$event->{host}"); $::oq->o_send($conn, "kick $chan $event->{nick} :Spamming"); return "mode $chan -b *!*\@$event->{host}"; } -sub Actions::kick { +sub kick { my ($conn, $event, $chan) = @_; $::oq->o_send($conn, "kick $chan $event->{nick} :Spamming"); return ""; } -sub Actions::none { +sub none { return ""; } -sub Actions::quiet { +sub quiet { my ($conn, $event, $chan) = @_; $::oq->o_send( $conn, "mode $chan +b %*!*\@$event->{host}" ); return "mode $chan -b %*!*\@$event->{host}"; } -return 1; +1; diff --git a/modules/classes.pl b/modules/classes.pl index b540a9a..4233d88 100644 --- a/modules/classes.pl +++ b/modules/classes.pl @@ -29,21 +29,22 @@ sub new return $self; } -sub check { +sub check +{ my $self = shift; my $item = shift; return $self->{ftbl}->{$item}->(@_); } my %ls = (); -sub levenflood { - my ($xchk, $id, $event, $chan) = @_; +sub levenflood +{ + my ($chk, $id, $event, $chan) = @_; my $text; if ($event->{type} =~ /^(public|notice|part|caction)$/) { - $text=$event->{args}->[0]; + $text = $event->{args}->[0]; } - return 0 unless defined($text); - return 0 unless length($text) >= 30; + return 0 unless ( defined($text) && (length($text) >= 30) ); if ( ! defined($ls{$chan}) ) { $ls{$chan} = [ $text ]; return 0; @@ -69,12 +70,12 @@ sub levenflood { return $ret; } -sub dnsbl { - my ($xchk, $id, $event, $chan, $rev) = @_; - my %chk = %{$xchk}; +sub dnsbl +{ + my ($chk, $id, $event, $chan, $rev) = @_; return unless index($event->{host}, '/') == -1; if (defined $rev) { - my $iaddr = gethostbyname( "$rev$chk{content}" ); + my $iaddr = gethostbyname( "$rev$chk->{content}" ); my @dnsbl = unpack( 'C4', $iaddr ) if defined $iaddr; return 1 if (@dnsbl); } @@ -82,9 +83,8 @@ sub dnsbl { } sub floodqueue { - my ($xchk, $id, $event, $chan, $rev) = @_; - my %chk = %{$xchk}; - my @cut = split(/:/, $chk{content}); + my ($chk, $id, $event, $chan, $rev) = @_; + my @cut = split(/:/, $chk->{content}); return 1 if ( flood_add( $chan, $id, $event->{host}, int($cut[1]) ) == int($cut[0]) ); return 0; } @@ -102,6 +102,22 @@ sub nickspam { my %cf=(); my %bs=(); +my $cfc = 0; +sub process_cf +{ + foreach my $nid ( keys %cf ) { + foreach my $xchan ( keys %{$cf{$nid}} ) { + next if $xchan eq 'timeout'; + foreach my $host ( keys %{$cf{$nid}{$xchan}} ) { + next unless defined $cf{$nid}{$xchan}{$host}[0]; + while ( time >= $cf{$nid}{$xchan}{$host}[0] + $cf{$nid}{'timeout'} ) { + last if ( $#{ $cf{$nid}{$xchan}{$host} } == 0 ); + shift ( @{$cf{$nid}{$xchan}{$host}} ); + } + } + } + } +} sub splitflood { my ($chk, $id, $event, $chan) = @_; @@ -117,19 +133,16 @@ sub splitflood { return 1; } push( @{$cf{$id}{$chan}{$text}}, time ); - foreach my $nid ( keys %cf ) { - foreach my $xchan ( keys %{$cf{$nid}} ) { - next if $xchan eq 'timeout'; - foreach my $host ( keys %{$cf{$nid}{$xchan}} ) { - next unless defined $cf{$nid}{$xchan}{$host}[0]; - while ( time >= $cf{$nid}{$xchan}{$host}[0] + $cf{$nid}{'timeout'} ) { - last if ( $#{ $cf{$nid}{$xchan}{$host} } == 0 ); - shift ( @{$cf{$nid}{$xchan}{$host}} ); - } - } - } + while ( time >= $cf{$id}{$chan}{$text}[0] + $cf{$id}{'timeout'} ) { + last if ( $#{$cf{$id}{$chan}{$text}} == 0 ); + shift ( @{$cf{$id}{$chan}{$text}} ); + } + $cfc = $cfc + 1; + if ( $cfc >= 100 ) { + $cfc = 0; + process_cf(); } - if ( $#{ @{$cf{$id}{$chan}{$text}}}+1 == int($cut[0]) ) { + if ( $#{@{$cf{$id}{$chan}{$text}}}+1 == int($cut[0]) ) { $bs{$id}{$text} = time; return 1; } @@ -140,11 +153,7 @@ sub re { my ($chk, $id, $event, $chan) = @_; my $match = $event->{args}->[0]; $match = $event->{nick} if ($event->{type} eq 'join'); - if ( defined($chk->{nocase}) ) { - return 1 if ($match =~ /$chk->{content}/i); - } else { - return 1 if ($match =~ /$chk->{content}/); - } + return 1 if ($match =~ /$chk->{content}/); return 0; } @@ -196,27 +205,34 @@ sub gecos { sub nuhg { my ( $chk, $id, $event, $chan) = @_; my $match = $event->{from} . '!' . $::sn{lc $event->{nick}}->{gecos}; - if ( defined($chk->{nocase}) ) { - return 1 if ($match =~ /$chk->{content}/i); - } else { - return 1 if ($match =~ /$chk->{content}/); - } + return 1 if ($match =~ /$chk->{content}/); return 0; } -sub flood_add { +my $sfc = 0; + +sub flood_add +{ my ( $chan, $id, $host, $to ) = @_; push( @{$sf{$id}{$chan}{$host}}, time ); while ( time >= $sf{$id}{$chan}{$host}[0] + $to ) { last if ( $#{ $sf{$id}{$chan}{$host} } == 0 ); shift( @{$sf{$id}{$chan}{$host}} ); } + $sf{$id}{'timeout'} = $to; + $sfc = $sfc + 1; + if ($sfc > 100) { + $sfc = 0; + flood_process(); + } return $#{ @{$sf{$id}{$chan}{$host}}}+1; } -sub flood_process { +sub flood_process +{ for my $id ( keys %sf ) { for my $chan ( keys %{$sf{$id}} ) { + next if $chan eq 'timeout'; for my $host ( keys %{$sf{$id}{$chan}} ) { next unless defined $sf{$id}{$chan}{$host}[0]; while ( time >= $sf{$id}{$chan}{$host}[0] + $sf{$id}{'timeout'} ) { @@ -228,5 +244,4 @@ sub flood_process { } } - -return 1; +1; diff --git a/modules/event.pl b/modules/event.pl index 971a542..e7b3a66 100644 --- a/modules/event.pl +++ b/modules/event.pl @@ -5,7 +5,6 @@ use strict; use Data::Dumper; use Text::LevenshteinXS qw(distance); use IO::All; -#require 'modules/inspect.pl'; sub cs { my ($chan) = @_; @@ -32,7 +31,7 @@ sub new $conn->add_default_handler(\&blah); $conn->add_handler('bannedfromchan', \&on_bannedfromchan); $conn->add_handler('mode', \&on_mode); - $conn->add_handler('join', sub { on_join( $self, @_ ) } ); #\&on_join); + $conn->add_handler('join', \&on_join); $conn->add_handler('part', \&on_part); $conn->add_handler('quit', \&on_quit); $conn->add_handler('nick', \&on_nick); @@ -49,7 +48,7 @@ sub new $conn->add_handler('kick', \&on_kick); $conn->add_handler('cping', \&on_ctcp); $conn->add_handler('cversion', \&on_ctcp); - $conn->add_handler('csource', \&on_ctcp); + $conn->add_handler('csource', \&on_ctcp_source); $conn->add_handler('ctime', \&on_ctcp); $conn->add_handler('cdcc', \&on_ctcp); $conn->add_handler('cuserinfo', \&on_ctcp); @@ -71,7 +70,7 @@ sub on_connect { #my @leven = (); sub on_join { - my ($self, $conn, $event) = @_; + my ($conn, $event) = @_; my %evcopyx = %{$event}; my $evcopy = \%evcopyx; my $nick = lc $event->{nick}; @@ -349,6 +348,14 @@ sub on_ctcp $::inspector->inspect($conn, $event); } +sub on_ctcp_source +{ + my ($conn, $event) = @_; + if (lc $event->{args}->[0] eq lc $conn->{_nick}) { + $conn->ctcp_reply($event->{nick}, 'SOURCE http://svn.linuxrulz.org/repos/antispammeta/trunk/'); + } +} + sub whois_identified { my ($conn, $event2) = @_; my $who = lc $event2->{args}->[1]; 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; diff --git a/modules/util.pl b/modules/util.pl index f13c854..a385790 100644 --- a/modules/util.pl +++ b/modules/util.pl @@ -14,6 +14,36 @@ my %oq; 'high' => 50, 'opalert'=> 9001 #OVER NINE THOUSAND!!! ); + +%::COLORS = +( + 'white' => '00', + 'black' => '01', + 'blue' => '02', + 'green' => '03', + 'red' => '04', + 'brown' => '05', + 'purple' => '06', + 'orange' => '07', + 'yellow' => '08', + 'ltgreen' => '09', + 'teal' => '10', + 'ltcyan' => '11', + 'ltblue' => '12', + 'pink' => '13', + 'grey' => '14', + 'ltgrey' => '15', +); + +%::RCOLOR = +( + $::RISKS{debug} => $::COLORS{purple}, + $::RISKS{info} => $::COLORS{blue}, + $::RISKS{low} => $::COLORS{green}, + $::RISKS{medium} => $::COLORS{orange}, + $::RISKS{high} => $::COLORS{red}, +); + sub new { my $module = shift; |
