17 parse_banlist [options]
20 --bans, -b list of bans (bans.txt)
21 --remove, -r file to save bans to remove (bans_to_remove.txt)
22 --keep, -k file to save bans to keep (bans_to_keep.txt)
23 --debug, -d debugging level (Default 0)
24 --help, -h display this help
25 --man, -m display manual
33 Debug verbosity. (Default 0)
37 Display brief useage information.
53 # XXX parse config file
55 my %options = (debug => 0,
61 remove => 'bans_to_remove.txt',
62 keep => 'bans_to_keep.txt',
68 GetOptions(\%options,'age|a=i','unbans|u=i','bans|b=s','remove|r=s',
69 'pattern|p!','keep|k=s','debug|d+','help|h|?','man|m',
70 'user|specific-user|s!','wide|wide-bans|w!',
73 pod2usage() if $options{help};
74 pod2usage({verbose=>2}) if $options{man};
76 $DEBUG = $options{debug};
78 my $bans_fh = new IO::File $options{bans}, 'r' or die "Unable to open file $options{bans} for reading: $!";;
80 my $bans_r_fh = new IO::File $options{remove}, 'w' or
81 die "Unable to open file $options{remove} for writing: $!";
83 my $bans_k_fh = new IO::File $options{keep}, 'w' or
84 die "Unable to open file $options{keep} for writing: $!";
89 # pull the ban and the times.
90 print {$bans_k_fh} "nomatch: $_" and next unless my ($channel, $banmask, $time) =
91 $_ =~ /(\#\w+)\:\s+ban\s+([^\s]+)\s+\[by\s*.*?\,\s+(\d+)\s+secs/;
92 print {$bans_k_fh} "time: $_" and next unless $time > $options{age};
94 # Ignore bans against specific users.
96 print {$bans_k_fh} "user: $_" and next if $banmask =~ /^\%?\w/
100 print {$bans_k_fh} "wide: $_" and next if $banmask =~ /\*\!.*?\@.*\*.*/;
103 push @bans_to_remove, $banmask;
107 while (my @unbans = splice(@bans_to_remove,0,$options{unbans})) {
108 print {$bans_r_fh} q(/mode -), q(b) x ($#unbans+1), q( ), join(' ',@unbans);
109 print {$bans_r_fh} qq(\n);