🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #80368

Re: Can Cleanfeed filter on a specific user? (File based solution)

#80368
From: D. Stussy
Date: Wed, 11 Mar 2009 02:41
68 lines
3698 bytes
"Jeffrey M. Vinocur" <jeff@litech.org> wrote in message
news:gp7244$ut5$1@puck.litech.org...
> In article <gp4jp2$tc5$1@optima7.xanadu-bbs.net>,
> John F. Morse <dont.bother> wrote:
> >
> >Can your my $badpeople = 'aol\.com'; be added to in the future with the
> >alternation metacharacter '|' ? Such as:
> >
> >my $badpeople = 'aol\.com'|'gmail\.com'|'microsoft\.com'|'ex-wife';
> >
> >and so forth?
>
> Eek not quite like that.
>
> The single quotes define a string.  The equals sign puts that
> string into a variable.  When you use the variable in a regular
> expression (or almost anywhere else), the contents of that string
> are inserted in place of the variable.
>
> So you can't do
>
> my $badpeople = 'aol\.com'|'gmail\.com'|'microsoft\.com'|'ex-wife';
>
> any more than you can do
>
> print 'aol\.com'|'gmail\.com'|'microsoft\.com'|'ex-wife';
>
> because there's nothing magical about combining strings with | to
> make some extra special kinda of string that you're then putting
> into a variable.  (The | used as top-level syntax like you're
> doing means something totally different.)
>
> But you -can- absolutely do what you're intending, by making one
> long string that goes into a variable, and then putting that into
> the regular expression.  (It's the regular expression that makes
> the | mean what you think it means.)  Like this:
>
> my $badpeople = 'aol\.com|gmail\.com|microsoft\.com|ex-wife';

My solution was file based (cleanfeed.local):

sub local_filter_last {
        return reject('MI5 Spam')
                if $lch{subject} =~
/M.*I.*5.*P.*E.*R.*S.*E.*C.*U.*T.*I.*O.*N/i;
        return reject('Banned From header address %1')
                if $Bad_From and ($hdr{'From'} =~ /($Bad_From)/i);
        return reject('Banned Sender header address %1')
                if $Bad_From and ($hdr{'Sender'} =~ /($Bad_From)/i);
        return reject('Banned Reply-To header address %1')
                if $Bad_From and ($hdr{'Reply-To'} =~ /($Bad_From)/i);
}

sub local_config {
...
        read_regex('bad_from',\$Bad_From);
}


As it turns out, the read_file subroutines work from the cleanfeed.local
file too.  However, I'm not certain about the "%1" parameter - except that
"$1" didn't work.  What do I need there - or do I need to put the "if"
clause first?

Added bonus - my "MI5 Persecution" killer.  ;-)
Occasionally, it does still show up!

Technical Details
Message-ID: <gp78cd$689$1@aux.snarked.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!feeder1.news.weretis.net!weretis.net!news.snarked.org!not-for-mail
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <gp3fbd$k29$1@optima7.xanadu-bbs.net> <gp4hp7$u1j$1@puck.litech.org> <gp4jp2$tc5$1@optima7.xanadu-bbs.net> <gp7244$ut5$1@puck.litech.org>

Show Full Headers
Complete Article Headers
Message-ID: <gp78cd$689$1@aux.snarked.org>
Subject: Re: Can Cleanfeed filter on a specific user? (File based solution)
Date: Tue, 10 Mar 2009 19:41:17 -0700
From: "D. Stussy" <spam@bde-arc.ampr.org>
References: <gou9pu$a8c$1@optima7.xanadu-bbs.net> <gp3fbd$k29$1@optima7.xanadu-bbs.net> <gp4hp7$u1j$1@puck.litech.org> <gp4jp2$tc5$1@optima7.xanadu-bbs.net> <gp7244$ut5$1@puck.litech.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!feeder1.news.weretis.net!weretis.net!news.snarked.org!not-for-mail
Newsgroups: news.software.nntp
Lines: 68
Reply-To: "D. Stussy" <replies@newsgroups.kd6lvw.ampr.org>
NNTP-Posting-Host: pool-71-106-211-188.lsanca.dsl-w.verizon.net
X-Trace: aux.snarked.org 1236739277 6409 71.106.211.188 (11 Mar 2009 02:41:17
 GMT)
X-Complaints-To: newsmaster@snarked.org
NNTP-Posting-Date: Wed, 11 Mar 2009 02:41:17 +0000 (UTC)
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478