Changeset 738
- Timestamp:
- 05/14/06 01:12:46
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Filter/SpamAssassin.pm
r374 r738 3 3 use base qw( Plagger::Plugin ); 4 4 5 our $VERSION = '0.0 1';5 our $VERSION = '0.02'; 6 6 7 7 use Mail::SpamAssassin; 8 use MIME::Lite; 9 use Encode; 10 use Encode::MIME::Header; 8 11 9 12 sub register { … … 11 14 $context->register_hook( 12 15 $self, 13 'plugin.init' => \&init_spamassassin,16 'plugin.init' => \&init_spamassassin, 14 17 'update.entry.fixup' => \&filter, 15 18 ); … … 28 31 my $sa = $self->{spamassassin}; 29 32 my $entry = $args->{entry}; 30 my $tag = $self->conf->{spam_tag} || ' SPAM';33 my $tag = $self->conf->{spam_tag} || 'spam'; 31 34 32 35 # create a pseudo mail header to skip some of the sa's default tests 33 36 my $status = $sa->check_message_text( 34 join "\n", 'Subject: ' . $entry->title, "\n", $entry->body 37 MIME::Lite->new( 38 From => 'plagger@localhost', 39 To => 'plagger@localhost', 40 Subject => encode('MIME-Header', $entry->title_text), 41 Data => $entry->body_text, 42 )->as_string 35 43 ); 36 44 37 45 if ($status->is_spam) { 38 46 $context->log(debug => "spam found"); 39 40 $entry->title("[$tag] " . $entry->title) if $self->conf->{add_tag_to_title};41 47 $entry->body($entry->body . $status->get_report) if $self->conf->{add_report}; 42 48 $entry->add_tag($tag); … … 52 58 =head1 NAME 53 59 54 Plagger::Plugin::Filter::SpamAssassin - mark spams60 Plagger::Plugin::Filter::SpamAssassin - Find spam entries 55 61 56 62 =head1 SYNOPSIS 57 63 58 - module: SmartFeed::SpamAssassin64 - module: Filter::SpamAssassin 59 65 config: 60 spam_tag: SPAM 61 add_tag_to_title: 1 62 add_report: 0 66 spam_tag: spam 63 67 new: 64 68 local_tests_only: 1 65 69 config_text: 66 - score MISSING_SUBJECT 0.067 - score MISSING_HB_SEP 0.068 - score MISSING_HEADERS 0.069 - score EMPTY_MESSAGE 0.070 70 - score NO_RELAYS 0.0 71 71 - score NO_RECEIVED 0.0 72 - score TO_CC_NONE 0.073 72 74 73 =head1 CONFIG … … 78 77 =item spam_tag 79 78 80 Specifies a tag string that will be added to entry's title or 81 tag (category) 79 A string that will be added to the entry's tag. Defaults to 'spam'. 82 80 83 =item add_tag_to_title 84 85 If set to true, the tag (enclosed in brackets) will be added to spam 86 entry's title. 87 88 =item add_report 81 =item add_report (for debugging) 89 82 90 83 If set to true, the SpamAssassin's report will be added to spam
