File Coverage

blib/lib/Siesta/Plugin/MetaDiscussion.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package Siesta::Plugin::MetaDiscussion;
2 1     1   807 use strict;
  1         2  
  1         29  
3 1     1   375 use Siesta::Plugin;
  0            
  0            
4             use base 'Siesta::Plugin';
5             use Siesta;
6              
7             our $VERSION='0.03';
8              
9              
10             # "I have always taken you with a grain of salt. On your birthday when you asked me
11             # to do a striptease to the theme from Mighty Mouse, I said okay. When we were at
12             # that hotel on prom night and you asked me to sleep underneath the bed in case
13             # your mother burst in, I did it. And even when we were at my Grandmother's funeral
14             # and you told most of my relatives that you could see her nipples through her
15             # burial dress, I let it slide, but if you think I'm gonna suffer anymore of your
16             # shit with a smile now that we've broken up, you're in for a big fucking
17             # disappointment." - Rene, Mallrats
18              
19              
20             sub description {
21             'Remove MetaDiscussion';
22             }
23              
24              
25              
26             sub process {
27             my $self = shift;
28             my $mail = shift;
29             my $list = $self->list;
30              
31             my %trigger_phrases = (
32             'supercite' => 2,
33             'jeopardy style' => 1.5,
34             'top posting' => 1,
35             'rfc1855' => 2,
36             '1855' => 0.9,
37             'oneliner' => 0.9,
38             'oneliners' => 1.0,
39             'reply-to' => 1.0,
40             'reply-to munging' => 2.0,
41             );
42             my $score = 0;
43              
44             for (keys(%trigger_phrases)) {
45             $score += $trigger_phrases{$_} * $mail->body() =~ /$_/i;
46             }
47              
48             return if ($score < $self->pref('threshold'));
49              
50             if ($self->pref('approve')) {
51             my $id = $mail->defer(
52             why => "metadiscussion post requires approval",
53             who => $list->owner);
54             $mail->reply( to => $list->owner->email,
55             from => $list->return_path,
56             subject => "deferred message",
57             body => Siesta->bake('metadisucssion_approve',
58             list => $list,
59             mail => $mail,
60             deferred => $id),
61             );
62             }
63             else {
64             $mail->reply( to => $list->owner->email,
65             from => $list->return_path,
66             body => Siesta->bake('metadiscussion_dropped',
67             list => $list,
68             mail => $mail)
69             );
70             }
71              
72              
73             return 1 unless $self->pref('tell_user');
74              
75             $mail->reply( from => $list->return_path,
76             body => Siesta->bake('metadiscussion_held',
77             extra => "\nYour message is now held in an approval queue.")
78              
79             );
80             return 1;
81             }
82              
83             sub options {
84             +{
85             'tell_user'
86             => {
87             description => "should we tell the user if their post is rejected/delayed",
88             type => "boolean",
89             default => 0,
90             },
91             'approve'
92             => {
93             description => "should we hold suspected metadiscussion posts for approval",
94             type => "boolean",
95             default => 1,
96             },
97             'threshold'
98             => {
99             description => "the score at which a post is rejected/delayed",
100             type => "number",
101             default => 4,
102             },
103             };
104             }
105              
106             1;
107              
108             =pod
109              
110             =head1 NAME
111              
112             Siesta::Plugin::MetaDiscussion - reject messages to a mailing list about mailing lists
113              
114             =head1 DESCRIPTION
115              
116             THIS HAS BEEN TOTALLY UNTESTED, WAIT FOR RELEASE 0.02 UNLESS YOU WANT TO
117             DO DEBUGGING. IT DOESNT EVEN PASS TESTS ON MY BOX ... MUHAHAHAHAHAHA!
118              
119             (Fixed now and released as 0.02 but this note kept in for historical reasons - Simon)
120              
121              
122             =head1 COPYRIGHT
123              
124             (c)opyright 2003 - Greg McCarroll
125              
126             =head1 FIXED BY
127              
128             Simon Wistow
129              
130             =cut
131              
132