1 # CrossAssassin.pm 2004/04/12 blarson
3 package Mail::CrossAssassin;
7 our @ISA = qw(Exporter);
8 our @EXPORT = qw(ca_init ca_keys ca_set ca_score ca_expire);
11 use Digest::MD5 qw(md5_base64);
16 our $addrpat = '\b\d{3,8}(?:-(?:close|done|forwarded|maintonly|submitter|quiet))?\@bugs\.debian\.org';
20 $addrpat = $ap if(defined $ap);
22 return if ($init && ! defined($dir));
23 $dir = "$ENV{'HOME'}/.crosssassassin" unless (defined($dir));
24 (mkdir $dir or die "Could not create \"$dir\"") unless (-d $dir);
26 tie %database, 'DB_File', "$dir/Crossdb"
27 or die "Could not initialize crosassasin database \"$dir/Crossdb\": $!";
34 my $m = join('',@$body);
35 $m =~ s/\n(?:\s*\n)+/\n/gm;
36 if (length($m) > 4000) {
39 push @keys, '0'.md5_base64($m2);
41 # $m =~ s/^--.*$/--/m;
42 $m =~ s/$addrpat/LOCAL\@ADDRESS/iogm;
43 push @keys, '1'.md5_base64($m);
44 return join(' ',@keys);
48 my @keys = split(' ', $_[0]);
52 foreach my $k (@keys) {
53 my ($count,$date) = split(' ',$database{$k});
55 $score = $count if ($count > $score);
56 $database{$k} = "$count $now";
59 return (wantarray ? @scores : $score);
63 my @keys = split(' ', $_[0]);
67 foreach my $k (@keys) {
68 my ($count,$date) = split(' ',$database{$k});
69 $score = $count if ($count > $score);
73 return (wantarray ? @scores : $score);
81 while (my ($k, $v) = each %database) {
83 my ($count, $date) = split(' ', $v);