diff options
| author | 2007-06-06 21:30:25 +0000 | |
|---|---|---|
| committer | 2007-06-06 21:30:25 +0000 | |
| commit | 04c4d4ae0d6fdfe9e59a50e79b40047a08feefb7 (patch) | |
| tree | 3db7aa17c73151e038f08e3cd0c1b2faffc0c482 /modules/classes.pl | |
| parent | 110cb874fc58ae4a214889bb8d6545201a57dd2f (diff) | |
Added files
Diffstat (limited to 'modules/classes.pl')
| -rw-r--r-- | modules/classes.pl | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/modules/classes.pl b/modules/classes.pl new file mode 100644 index 0000000..74b2899 --- /dev/null +++ b/modules/classes.pl @@ -0,0 +1,124 @@ +use strict; +use warnings; +use Data::Dumper; +#package Classes; + +sub Classes::dnsbl { + our (%aonx, $id, %dct, $event, $chan, $rev); + if (defined $rev) { + my $iaddr = hostip( "$rev$aonx{$id}{content}" ); + my @dnsbl = unpack( 'C4', $iaddr ) if defined $iaddr; + $dct{$id} = $aonx{$id} if (@dnsbl); + } +} + +sub Classes::floodqueue { + our (%aonx, $id, %dct, $event, $chan); + my @cut=split(/:/, $aonx{$id}{content}); + $dct{$id} = $aonx{$id} if ( flood_add( $chan, $id, $event->{host}, int($cut[1]) ) == int($cut[0]) ); +} + +sub Classes::nickspam { + our (%aonx, $id, %dct, $event, $chan); + my @cut = split(/:/, $aonx{$id}{content}); + if ( length $event->{args}->[0] >= int($cut[0]) ) { + %_ = map { $_=>$_ } lc keys %{$::sc{lc $chan}{users}}; + my @uniq = grep( $_{$_}, split( / /, lc $event->{args}->[0]) ); + $dct{$id} = $aonx{$id} if ( $#{ @uniq } >= int($cut[1]) ); + } +} + +my %cf=(); +my %bs=(); + +sub Classes::splitflood { + our (%aonx, $id, %dct, $event, $chan); + my $text; + my @cut = split(/:/, $aonx{$id}{content}); + $cf{$id}{timeout}=int($cut[1]); + if ($event->{type} =~ /^(public|notice|part|caction)$/) { + $text=$event->{args}->[0]; + } + return unless defined($text); + return unless length($text) >= 10; + if (defined($bs{$id}{$text}) && (time <= $bs{$id}{$text} + 600)) { + $dct{$id}=$aonx{$id}; + return; + } + 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}} ); + } + } + } + } + if ( $#{ @{$cf{$id}{$chan}{$text}}}+1 == int($cut[0]) ) { + $dct{$id}=$aonx{$id}; + $bs{$id}{$text} = time; + } +} + +sub Classes::re { + our (%aonx, $id, %dct, $event, $chan); + my $match = $event->{args}->[0]; + $match = $event->{nick} if ($event->{type} eq 'join'); + if ( (defined $aonx{$id}{nocase}) && ($aonx{$id}{nocase}) ) { + $dct{$id}=$aonx{$id} if ($match =~ /$aonx{$id}{content}/i); + } + else { + $dct{$id}=$aonx{$id} if ($match =~ /$aonx{$id}{content}/); + } +} + +sub Classes::nick { + our (%aonx, $id, %dct, $event, $chan); + if ( lc $event->{nick} eq lc $aonx{$id}{content} ) { + $dct{$id} = $aonx{$id}; + } +} + +sub Classes::ident { + our (%aonx, $id, %dct, $event, $chan); + if ( lc $event->{user} eq lc $aonx{$id}{content} ) { + $dct{$id} = $aonx{$id}; + } +} + +sub Classes::host { + our (%aonx, $id, %dct, $event, $chan); + if ( lc $event->{host} eq lc $aonx{$id}{content} ) { + $dct{$id} = $aonx{$id}; + } +} + +sub Classes::killsub { + undef &Classes::dnsbl; + undef &Classes::floodqueue; + undef &Classes::nickspam; + undef &Classes::re; +} +#$VAR1 = bless( { +# 'to' => [ +# '##asb-testing' +# ], +# 'format' => 'mode', +# 'from' => 'ChanServ!ChanServ@services.', +# 'user' => 'ChanServ', +# 'args' => [ +# '+o', +# 'AntiSpamMetaBeta', +# '' +# ], +# 'nick' => 'ChanServ', +# 'type' => 'mode', +# 'userhost' => 'ChanServ@services.', +# 'host' => 'services.' +# }, 'Net::IRC::Event' ); + +return 1; |
