Changeset 738

Show
Ignore:
Timestamp:
05/14/06 01:12:46
Author:
charsbar
Message:

Filter::SpamAssassin?: cut off some options and made it slim

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Filter/SpamAssassin.pm

    r374 r738  
    33use base qw( Plagger::Plugin ); 
    44 
    5 our $VERSION = '0.01'; 
     5our $VERSION = '0.02'; 
    66 
    77use Mail::SpamAssassin; 
     8use MIME::Lite; 
     9use Encode; 
     10use Encode::MIME::Header; 
    811 
    912sub register { 
     
    1114    $context->register_hook( 
    1215        $self, 
    13         'plugin.init' => \&init_spamassassin, 
     16        'plugin.init'        => \&init_spamassassin, 
    1417        'update.entry.fixup' => \&filter, 
    1518    ); 
     
    2831    my $sa    = $self->{spamassassin}; 
    2932    my $entry = $args->{entry}; 
    30     my $tag   = $self->conf->{spam_tag} || 'SPAM'; 
     33    my $tag   = $self->conf->{spam_tag} || 'spam'; 
    3134 
    3235    # create a pseudo mail header to skip some of the sa's default tests 
    3336    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 
    3543    ); 
    3644 
    3745    if ($status->is_spam) { 
    3846        $context->log(debug => "spam found"); 
    39  
    40         $entry->title("[$tag] " . $entry->title) if $self->conf->{add_tag_to_title}; 
    4147        $entry->body($entry->body . $status->get_report) if $self->conf->{add_report}; 
    4248        $entry->add_tag($tag); 
     
    5258=head1 NAME 
    5359 
    54 Plagger::Plugin::Filter::SpamAssassin - mark spam
     60Plagger::Plugin::Filter::SpamAssassin - Find spam entrie
    5561 
    5662=head1 SYNOPSIS 
    5763 
    58   - module: SmartFeed::SpamAssassin 
     64  - module: Filter::SpamAssassin 
    5965    config: 
    60       spam_tag: SPAM 
    61       add_tag_to_title: 1 
    62       add_report: 0 
     66      spam_tag: spam 
    6367      new: 
    6468        local_tests_only: 1 
    6569        config_text: 
    66           - score MISSING_SUBJECT 0.0 
    67           - score MISSING_HB_SEP  0.0 
    68           - score MISSING_HEADERS 0.0 
    69           - score EMPTY_MESSAGE   0.0 
    7070          - score NO_RELAYS       0.0 
    7171          - score NO_RECEIVED     0.0 
    72           - score TO_CC_NONE      0.0 
    7372 
    7473=head1 CONFIG 
     
    7877=item spam_tag 
    7978 
    80 Specifies a tag string that will be added to entry's title or 
    81 tag (category) 
     79A string that will be added to the entry's tag. Defaults to 'spam'. 
    8280 
    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) 
    8982 
    9083If set to true, the SpamAssassin's report will be added to spam