🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #139160

[Dialog] Kill Followup Script

#139160
From: JoeB
Date: Fri, 12 Dec 2003 23:27
132 lines
5771 bytes
Hi all.

Please find attached my first attempt at Dialog scripting. (Please don't
laugh.)

In certain groups, a perfectly normal thread will be going on, until a
well-known troll posts a response. From that point on the thread
degenerates into ad hominems and a tedious slanging match. I have no
interest in the thread from that point: this script is intended to address
that.

What the script does is check each message's author against a (user
defined) list of posters. If the posting is from one such, the message id
is compared against a list of already-banned ids, and added if it does not
already exist: the message is then killed.

Each message's references are then checked against the banned ids, and if
they contain the id, the message is again killed.

The practical upshot is to kill all posts, and followups to those posts, by
particular authors, without nuking the whole thread.

Now the disclaimers: I'm very new to Dialog and Pascal - I heard about it a
week ago - and I'm no programmer. The script is basically a Lego job,
bolted together from concepts lifted wholesale from the existing body of
Dialog scripts. I realise that the script is crude, and could do with
improvement: to that end I would be delighted for any input the more
skilled regulars could provide... the more the merrier :-)

Usage:

1) Create two blank text files as defined in the Const section.
2) Cut and paste the *entire* From: line into the killauth text file. (The
whole string - for example "RandomTroll" <randomtroll@foo.org> - is
required, not just the nickname.
3) Assign the script below to the OnXOver event, compile, run and save.

<script starts>

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

// set these variables as the paths to the working files - create empty
text files in these locations
const
  KillAuthFile = 'c:\killauth.txt'; // file of Froms to kill - must contain
full string, not just name
  KillMsgIdFile = 'c:\killmsg.txt'; // autogenerated file of msgids to kill   
  
function CheckAuth(AuthName : string): boolean;
// check if author is to be killed
VAR 
   AuthList : TStringList; 
begin
   AuthList := TStringList.Create();
   Authlist.LoadFromFile(KillAuthFile);
   Result := authlist.indexof(AuthName) > -1
   AuthList.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 checkauth(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 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 pos(msglist[n],XoverData.References)>0
      THEN xoverdata.deleted := true; // and kill the followup
   end
   msglist.free;    
end;   

begin
end.

<script ends>

Things I think that are wrong with the script:
1) There's probably a setting in Dialog to do exactly this already :-)
2) The whole From: string is required, which does not handle morphs very
well. But I can't figure out how to get the NNTP-Posting-Host from the
initial OnXOver event. Or maybe some sort of regex?
3) I've no idea what impact it has on performance when downloading headers.
4) I believe I should have used try/finally contructions, but I couldn't
get the syntax right.
5) The KillMsgIdFile will probably have to be cleared out periodically.
6) Some poster's newsreaders appear to mangle the References: header, so
the script is not 100% effective. But it helps :-)

Hope this is of use to some people, and, as I said, I would greatly
appreciate any comments that would improve (a) the script and (b) my
scripting.

JoeB
Technical Details
Message-ID: <acvkac1u7d89.1ovm1kafvs4m9$.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!internal1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!mephistopheles.news.clara.net!newspeer.clara.net!news.clara.net!demeter.uk.clara.net

Show Full Headers
Complete Article Headers
Message-ID: <acvkac1u7d89.1ovm1kafvs4m9$.dlg@40tude.net>
Subject: [Dialog] Kill Followup Script
Date: Fri, 12 Dec 2003 23:27:07 +0000
From: JoeB <morph@clara.co.uk>
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!internal1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!mephistopheles.news.clara.net!newspeer.clara.net!news.clara.net!demeter.uk.clara.net
Newsgroups: news.software.readers
User-Agent: 40tude_Dialog/2.0.8.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@clara.net (please include full headers)
X-Trace: 82a004409015000094002002f1dd38637050a1c8e060060b7480689c3fda4ef5
NNTP-Posting-Date: Fri, 12 Dec 2003 23:27:49 +0000
Lines: 132