10 my $conf = {bans => 'bans.txt',
11 bans_to_remove => 'bans_to_remove.txt',
12 bans_to_keep => 'bans_to_keep.txt',
13 minimum_age => 1209600, # two weeks
18 getopt('b:k:r:a:',$options);
20 $conf->{bans} = $options->{b} || $conf->{bans};
21 $conf->{bans_to_remove} = $options->{r} || $conf->{bans_to_remove};
22 $conf->{bans_to_keep} = $options->{k} || $conf->{bans_to_keep};
23 $conf->{minimum_age} = $options->{a} || $conf->{minimum_age};
25 my $bans_fh = new IO::File $conf->{bans}, 'r' or die "Unable to open file $conf->{bans} for reading: $!";;
27 my $bans_r_fh = new IO::File $conf->{bans_to_remove}, 'w' or
28 die "Unable to open file $conf->{bans_to_remove} for writing: $!";
30 my $bans_k_fh = new IO::File $conf->{bans_to_keep}, 'w' or
31 die "Unable to open file $conf->{bans_to_keep} for writing: $!";
36 # pull the ban and the times.
37 print {$bans_k_fh} $_ and next unless my ($channel, $banmask, $time) =
38 $_ =~ /(\#\w+)\:\s+ban\s+([\w\d\*\@\%\!\-\_\.]+)\s+\[by\s*.*?\,\s+(\d+)\s+secs/;
39 print {$bans_k_fh} $_ and next unless $time > $conf->{minimum_age};
41 # Ignore bans against specific users.
42 print {$bans_k_fh} $_ and next if $banmask =~ /^\%?\w/;
45 print {$bans_k_fh} $_ and next if $banmask =~ /\*\!.*?\@.*\*.*/;
47 push @bans_to_remove, $banmask;
51 while (my @unbans = splice(@bans_to_remove,0,$conf->{max_ubans})) {
52 print {$bans_r_fh} q(/mode -), q(b) x ($#unbans+1), q( ), join(' ',@unbans);
53 print {$bans_r_fh} qq(\n);