Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created December 13, 2010 04:00
Show Gist options
  • Save FiXato/738633 to your computer and use it in GitHub Desktop.
Save FiXato/738633 to your computer and use it in GitHub Desktop.
Diff file for IRC Defender's flood module. Adds exclusion channel support. Based on 1.40 bl.
1c1
< # $Id: flood.pm 861 2004-11-24 11:30:33Z brain/FiXato $
---
> # $Id: flood.pm 861 2004-11-24 11:30:33Z brain $
21,29d20
< my $excluded_channel;
< my $excluded;
< my @excluded_channels;
< my $total_excluded;
<
< sub in_array {
< my $check = shift;
< return grep { $check eq $_ } @_;
< }
40a32
> main::message(" ");
42c34
< foreach (%chans) {
---
> foreach my $channel (%chans) {
46c38
< foreach (@lockchans) {
---
> foreach my $locked (@lockchans) {
48c40
< main::message(" $_\n");
---
> main::message(" $locked\n");
50,59d41
<
< main::message(" ");
< my $total_excluded = 0;
< main::message("\002Exclude channels:\002");
< foreach (@excluded_channels) {
< $total_excluded++;
< main::message($_ . "\n");
< }
< main::message("A total of\002 $total_excluded\002 channels are currently excluded.");
<
84,89c66,70
< if (in_array($comp,@lockchans)) { return 1; }
< # foreach my $chan (@lockchans) {
< # if ($comp eq $chan) {
< # return 1;
< # }
< # }
---
> foreach my $chan (@lockchans) {
> if ($comp eq $chan) {
> return 1;
> }
> }
135,151c116,122
< if (in_array($channel, @excluded_channels)) {
< my $notlocked_message = "ALERT! \002$channel\002 has been joined/parted " . $chans{$channel} . " times in the last $interval seconds and IS NOT locked due to being an exclusion channel.";
< main::globops($notlocked_message);
< main::message($notlocked_message);
< $chans{$channel} = 0;
< }
< else {
< main::mode($channel,"+CKmic");
< main::notice($channel,"Your channel has been joined/parted\002 " . $chans{$channel} . "\002 times in the last\002 $interval\002 seconds which constitutes a \002flood\002. As a countermasure the modes \002+CKmic\002 have been set to prevent more flooding. Please remove these commands when the situation has averted. These modes will be automatically reversed in\002 1\002 minute.");
< my $lock_message = "ALERT! \002$channel\002 has been joined/parted " . $chans{$channel} . " times in the last $interval seconds and has been temporarily locked!";
< main::globops($lock_message);
< main::message($lock_message);
< $chans{$channel} = 0;
< push @locktime, time+60;
< push @lockchans, $channel;
< $locked++;
< }
---
> main::mode($channel,"+CKmic");
> main::notice($channel,"Your channel has been joined/parted\002 " . $chans{$channel} . "\002 times in the last\002 $interval\002 seconds which constitutes a \002flood\002. As a countermasure the modes \002+CKmic\002 have been set to prevent more flooding. Please remove these commands when the situation has averted. These modes will be automatically reversed in\002 1\002 minute.");
> main::globops("ALERT! \002$channel\002 has been joined/parted " . $chans{$channel} . " times in the last $interval seconds and has been temporarily locked!");
> $chans{$channel} = 0;
> push @locktime, time+60;
> push @lockchans, $channel;
> $locked++;
229d199
< @excluded_channels = split(",",$main::dataValues{'excluded_channels'});
231d200
< main::message("Flood.pm loaded, with modifications by FiXato fixato\@chat4all.net, based on the exclusion mod by Rafe (Jay) rafe\@chat4all.be");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment