🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #170942

Re: [Dialog] Filter out poster and responses

#170942
From: JoeB
Date: Tue, 09 Aug 2005 15:11
190 lines
7835 bytes
On Tue, 09 Aug 2005 15:26:12 +0200, Enrico Bauer wrote:

> *JoeB*  09.08.2005:
>> On Sat, 6 Aug 2005 15:11:19 +0200, Enrico Bauer wrote:
>>> 04.08.2005 05:14:38, *Ian Rastall*:
>>>> I'm kind of dense when it comes to figuring out filtering rules for
>>>> Dialog. :-) I'm looking to filter out not just a poster, but every
>>>> response to said poster.
>>>> I'm thinking this has to do with message-ID and references, [...]
>>> Right, you'll have to filter on the MID for the poster and that MID
>>> again in the references. This is only possible if that particular poster
>>> uses a FQDN, so that you can track it.
>> <delurk>
> 
> Hi there! :-)
> 
>> I have a script which works for me - it's a bit clunky, but it does the
>> job. I can post it if people would like...
>> // OnXover script to identify and kill posts by banned authors, and
>> // followups to those posts.
>> // How it works:
>> // As each set of headers are retrieved, the From and Message-ID headers
>> // are checked against lists of banned strings, allowing you to kill posts
>> // that are either from specific authors or posted through specific ISPs
>> // (for trolls who morph a lot.)
>> // If any of the banned strings are found anywhere in the relevant header,
>> // the message is killed and its message id is added to a list of banned
>> // message ids.
> 
> Brillant, Master Joe! Go ahead, show your script so we can test an wiki 
> it!

Well, I'm not sure about "Master"... :-)

Script is given below between the //START and //END markers.

Known issues: It's pretty inefficient, and will slow down header retrieval.
Also it doesn't manage the list of banned message ids, so periodically you
have to go and clear out that file.

I would definitely welcome any comments or improvements people can think of
- especially to make it more elegant or efficient.

//START

program OnXover; 
// OnXover script to identify and kill posts by banned authors, and
// followups to those posts.

// How it works:
// As each set of headers are retrieved, the From and Message-ID headers
// are checked against lists of banned strings, allowing you to kill posts
// that are either from specific authors or posted through specific ISPs
// (for trolls who morph a lot.)
// If any of the banned strings are found anywhere in the relevant header,
// the message is killed and its message id is added to a list of banned
// message ids.
// If a message passes these two checks, its References header is checked
// against the list of banned message ids. If a match is found, then the
// message is a followup, and is killed.

// To use:
// 1) Create a folder called c:\killfile
// 2) In this folder create blank text files called
//      killmsg.txt
//      killmid.txt
//      killfrom.txt

// In killfrom.txt, enter the strings in the From: header that you want to
// kill on.
// For example, if you want to kill messages from Iamatroll@troll.biz you
// could put Iamatroll or @troll.biz in killfrom.txt.

// In killmid.txt, enter the strings in the Message-ID header that you want
// to kill on.
// For example, if you want to kill all posts from googlegroups, you could
// put googlegroups.com in killmid.txt

// set these variables as the paths to the working files
const
  KillFromFile = 'c:\killfile\killfrom.txt';
  KillMidFile = 'c:\killfile\killMid.txt';
  KillMsgIdFile = 'c:\killfile\killmsg.txt';
  
function CheckFrom(FromHeader : string): boolean;
// check if author is to be killed
VAR 
   BadFromList : TStringList;
   Counter : Integer;
   Position : Integer;
   LowFromHeader : String;
   LowBadFrom : String;
begin      
   Result := false;
   BadFromList := TStringList.Create();
   BadFromList.LoadFromFile(KillFromFile);
   for counter := 0 to BadFromList.Count - 1 do
   begin
   LowFromHeader := AnsiLowerCase(FromHeader)
   LowBadFrom := AnsiLowerCase(BadFromList[Counter])
   Position := AnsiPos(LowBadFrom, LowFromHeader)
   if Position <> 0 then Result := true;
   if Result = true then Break;
   end;
   BadFromList.free;
end;

function CheckMid(Mid : string): boolean;
// check if mid is to be killed
VAR 
   MidList : TStringList;
   Counter : Integer;
   Position : Integer; 
begin      
   Result := false;
   MidList := TStringList.Create();
   MidList.LoadFromFile(KillMidFile);
   for counter := 0 to MidList.Count - 1 do
   begin
   Position := AnsiPos(MidList[Counter], Mid)
   if Position <> 0 then Result := true;
   if Result = true then Break;
   end;
   //Result := MidList.indexof(Mid) > -1
   MidList.free;
end;

function CheckKnownId(KnownId : string): boolean;
// check to see if we already knowthis msgid so we don't add it again
VAR 
   KnownIdList : TStringList; 
begin
   KnownIdList := TStringList.Create();
   KnownIdlist.LoadFromFile(KillMsgIdFile);
   Result := KnownIdlist.indexof(KnownId) > -1 
   KnownIdList.free;
end;  

procedure AddNewId(NewId: string);
// add a new msgid to the kill list 
VAR 
   IdList: TStringList;  
begin
   IdList := TStringList.Create();
   IdList.LoadFromFile(KillMsgIdFile);
   IdList.Add(NewId);
   IdList.SaveToFile(KillMsgIdFile);
   IdList.Free;
end;

procedure OnXover(Var XoverData:TXoverData);
var 
   Msglist: TStringList; 
   n: integer;         
begin // check to see if we kill this author                 
   if CheckFrom(xoverdata.from) then
      // if we do, check to see if this is a new msgid 
       begin
         if not checkknownid(xoverdata.msgid) then // if it's new, add it 
         addnewid(xoverdata.msgid);
         xoverdata.deleted := true; // and kill the parent article  
       end;
   if CheckMid(xoverdata.msgid) then
      // if we do, check to see if this is a new msgid 
       begin
         if not checkknownid(xoverdata.msgid) then // if it's new, add it 
         addnewid(xoverdata.msgid);
         xoverdata.deleted := true; // and kill the parent article  
       end;
      // if it's not a killed mid, check to see if it's a followup  
      // if it's not a killed author, check to see if it's a followup   
   msglist := TStringList.Create();     
   msglist.LoadFromFile(KillMsgIdFile);   
   for n := 0 to msglist.count - 1 do 
   begin
      IF AnsiPos(msglist[n],XoverData.References)>0
      THEN xoverdata.deleted := true; // and kill the followup
   end
   msglist.free;    
end;   

begin
end.

//END

JoeB
-- 
The address in the headers is a spamtrap - please use joe at fallingonion
dot com if you prefer to use email.
Technical Details
Message-ID: <zzespx3v4cvm.1tem014ux6n19$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!feed3.newsreader.com!newsreader.com!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!sn-xit-03!sn-xit-08!sn-post-01!supernews.com!news.supernews.com!not-for-mail
References: <46mt8sd5poif.19xmque1k1z94.dlg@40tude.net> <060805.151119.nsr.19@ID-5349.user.uni-berlin.de> <1ojqok8pcz58m.wqz9e7zf1hgc.dlg@40tude.net> <1123593972.89@Henniku.newsoffice.de>

Show Full Headers
Complete Article Headers
Message-ID: <zzespx3v4cvm.1tem014ux6n19$.dlg@40tude.net>
Subject: Re: [Dialog] Filter out poster and responses
Date: Tue, 9 Aug 2005 16:11:58 +0100
From: JoeB <joe_bidgood@spanners4us.com>
References: <46mt8sd5poif.19xmque1k1z94.dlg@40tude.net> <060805.151119.nsr.19@ID-5349.user.uni-berlin.de> <1ojqok8pcz58m.wqz9e7zf1hgc.dlg@40tude.net> <1123593972.89@Henniku.newsoffice.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!feed3.newsreader.com!newsreader.com!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!sn-xit-03!sn-xit-08!sn-post-01!supernews.com!news.supernews.com!not-for-mail
Newsgroups: news.software.readers
Organization: joe_bidgood@spanners4us.com
User-Agent: 40tude_Dialog/2.0.11.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: joe_bidgood@spanners4us.com
Reply-To: joe_bidgood@spanners4us.com
X-Complaints-To: abuse@supernews.com
Lines: 190