Re: filter_nnrpd.pl
- From
- Serguei Revtov (2:5021/19.1)
- To
- All
- Date
- 2007-01-17T23:37:22Z
- Area
- RU.UNIX.FTN
Hi!
Карбонка наловила упоминание всуя ж)
Вот реально работающий фильтр, через который сейчас это сообщение и уйдет,
пропущенный через grep -v '^#'. Тут не совсем unix-way т.к.используется не
крон, а зацикленный скрипт, проверяющий флажки (в частности вызывающий
send-ifgate по флагу scan.flg). И, естественно, надо поменять адрес...
Возможно, это не последняя и не самая удачная версия. Но это то, что
осталось поблизости.
my %config = (checkincludedtext => 0,
includedcutoff => 40,
includedratio => 0.6,
quotere => '^[>:]',
antiquotere => '^[<]', # so as not to reject dict(1) output
);
sub filter_post {
my $rval = "" ; # assume we'll accept.
system ("/usr/local/bin/alarm sirpc filter_post");
if ($config{checkincludedtext}) {
my ($lines, $quoted, $antiquoted) = analyze($body);
if ($lines > $config{includedcutoff}
&& $quoted - $antiquoted > $lines * $config{includedratio}) {
$rval = "Article contains too much quoted text";
}
}
if( $hdr{"Newsgroups"} =~ /fido/ )
{
$from_suff = $hdr{'From'};
$ftn_suffix = "p2000.f19.n5021.z2";
$x_ftn_suffix = "2\:5021/19.2000";
if ( $from_suff =~ /.*[pP](\d+)\.[fF](\d+)\.[nN](\d+)\.[zZ](\d)/ ) {
$ftn_suffix = "p$1.f$2.n$3.z$4";
$x_ftn_suffix = "$4\:$3/$2.$1";
} elsif ( $from_suff =~ /.*[fF](\d+)\.[nN](\d+)\.[zZ](\d)/ ) {
$ftn_suffix = "f$1.n$2.z$3";
$x_ftn_suffix = "$3\:$2/$1";
}
$crc = time;
$hdr{"Message-ID"} = sprintf("\<%08u\@$ftn_suffix\>",$crc);
$modify_headers = 1;
$hdr{"X-FTN-MSGID"} = sprintf("$x_ftn_suffix %08x",$crc);
$modify_headers = 1;
}
open (FLAG, ">/usr/news/flag/scan.flg");
close (FLAG);
return $rval;
}
sub analyze {
my ($lines, $quoted, $antiquoted) = (0, 0, 0);
local $_ = shift;
do {
if ( /\G$config{quotere}/mgc ) {
$quoted++;
} elsif ( /\G$config{antiquotere}/mgc ) {
$antiquoted++;
}
} while ( /\G(.*)\n/gc && ++$lines );
return ($lines, $quoted, $antiquoted);
}
--- Opera Mail/9.01 (Win32)
* Origin: Home (2:5021/19.1)
SEEN-BY: 50/12 13 400/814 450/1024 5000/5000 5010/53 5011/13 5012/46 5015/28
SEEN-BY: 5019/26 40 5020/400 545 1982 2238 2871 4441 5021/2 19 29 42 49 5025/3
SEEN-BY: 5027/12 5035/38 5054/1 8 9 37 45 67 89 5059/9 5062/10 5063/3 5064/7
SEEN-BY: 5076/1 5077/70 5084/9 5085/13 5095/20 5096/18 6001/10
PATH: 5021/19 29 5020/545 5054/1 37