🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #243698

[Dialog] Random Header Generator Script

#243698
From: Sqwertz
Date: Sun, 12 Dec 2010 07:50
202 lines
9218 bytes
Somebody asked me what script I was using for generating 
random User-Agent headers for 40tude dialog.  This is the 
modified script I use.  It's based on ChangeAnyHeaderRandom
in the script library.  I have made a bunch of changes to 
localize it for Windows-American English, and numerous coding 
changes as well.

It could easily be adapted to change any other header(s) 
as well (that are not set or changed by your news server).  
For example, it could automatically change your From: with 
a random or static string when posting VIA certain servers.

I wasn't able to translate any of the German, so the popup 
texts are terser than the original script (quick and dirty).

You probably can't use this in tandem with the 
ChangeAnyHeader script since I think I made some symbols 
conflict with that script.  But this script can be used to 
replace that script.

I'm archiving it here since I've 
tweaked this script on every new Dialog installation and am
tired of doing it from scratch ;-)

The script requires the .DLL from:
https://www.nicohaase.de/2007/08/21/dialog-erweiterung.htm
I don't see this DLL at dialog.datalist.org and have asked
the webmaster to add it to his site (Sorry, I forget your
name... Colin?).

In a nutshell, you just need to add the script(s) to dialog 
and compile the Event trigger only.  Post a test message and 
a default UserAgent.ini file will be created in the Dialog 
directory  c:\program files\40tude (you can configure that 
in the script for your post WinXp installations).  A popup will 
tell you the file was created.

Then you edit your UserAgent.ini and add any User Agent strings
you want. You'll need to change the max random number generator 
variable in the script so that it knows how many strings you've 
placed in UserAgents.ini and recompile the Event trigger script
(OnBeforeSendingMessage).

The script is heavily based on:
http://dialog.datalist.org/scripts/CustomizeUserAgentRandom_include.html
And more instructions, notesm and original attributions can be 
found there.  You may post here or email me if you have any 
questions.

Note to Relf:  I don't give a shit how YOU do it with your Tonka 
Toy and don't care to see any more of your atrocious code.  Besides,
you killfiled me long ago (supposedly) so you won't even see this.

Steve Wertz
swertz@cluemail.com



For the OnBeforeSendingMessage trigger script:

------------------------------------------------------------------------------
program OnBeforeSendingMessage;
{$I ChangeAnyHeader.ds}   

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
  result:=true;

  //possibly some other calls to scripts

  result := result and ChangeAnyHeaderRandom ( Message, IsEmail );

end;

begin
end.
-----------------------------------------------------------------------------

For the Custom Script 'ChangeAnyHeader.ds'  (The include file)

-----------------------------------------------------------------------------

procedure Init_ChangeAnyHeaderRandom ( var DialogOrdner      : String;
                                       var MaxRandomKey      : integer;
                                       var ChangeHeader      : String;
                                       var AddOnChangeHeader : String;
                                       var ChangeInEmails    : Boolean;
                                       var ChangeInNews      : Boolean;
                                       var AddOnChangeRandom : Boolean
);

begin

//  ----------------------------------------------------
//  Configuration settings
//  ----------------------------------------------------
    
    // set the header you want to change here, e.g. 'User-Agent'
    ChangeHeader := 'User-Agent:';
    AddOnChangeHeader := ' (Simply the best usenet experience)';
    
    // True if you want it to genenerate a random header from the list, otherwise use the default you defined above
    AddOnChangeRandom := true;
    // Directory that will contain the UserAgents.ini file
    DialogOrdner := 'c:\program files\40tude dialog\';
    // Number of entries in the UserAgent.ini file.  Change this if you add more/less than 10 entries.
    MaxRandomKey := 10

    // change header in emails and/or postings
    // set 'true' or 'false'
    ChangeInEmails := false;
    ChangeInNews := true;
//  ----------------------------------------------------
//  End of configuration settings
//  ---------------------------------------------------- 

end;

   // --------------------------------------------------------------- //
   // ----  No user maintainable parts below this line -------------- //
   // --------------------------------------------------------------- //

function ChangeAnyHeaderRandom_MessageBox( hWnd : Cardinal; lpText, lpCaption : PChar; uType : longword ) : Integer;
   external 'MessageBoxA@user32.dll stdcall';

function randomNumber( max : integer ) : integer; external 'randomNumber@dExt.dll';
procedure dateicheck ( dateiname: string ); external 'legeDateiAn@dExt.dll';

function ChangeAnyHeaderRandom(var Message:TStringlist;IsEmail:boolean) : boolean;

var i                 : integer;
    s                 : String;
    ChangeHeader      : String;
    AddOnChangeHeader : String;
    ChangeInEmails    : Boolean;
    ChangeInNews      : Boolean;
    AddOnChangeRandom : Boolean;
    FileStringList    : TStringList;   
    DialogOrdner      : string;
    keyrandom         : string;
    MaxRandomKey      : integer;
    
begin
  
Init_ChangeAnyHeaderRandom ( DialogOrdner, MaxRandomKey, ChangeHeader, AddOnChangeHeader, ChangeInEmails, ChangeInNews, AddOnChangeRandom );
 
keyrandom := inttostr(randomNumber(MaxRandomKey)+1)

if (DirectoryExists(DialogOrdner) = false) then 
    begin 
        ChangeAnyHeaderRandom_MessageBox(0,'The folder ' + DialogOrdner + ' does not exist.','Script failed', 48+4096+0);
        Result := false;
    end
else
  begin
   if (FileExists(DialogOrdner + 'UserAgents.ini') = false) then 
     begin
       dateicheck ( DialogOrdner + 'UserAgents.ini' );

       FileStringList := TStringList.create;
       FileStringList.Clear;
       FileStringList.Add('1=(Guided Consideration)')
       FileStringList.Add('2=(IMHO the best User-Agent)')
       FileStringList.Add('3=(the best usenet experience!)')
       FileStringList.Add('4=(Free Windows-Newsreader)')
       FileStringList.Add('5=(Newsreader with Unicode-Support)')
       FileStringList.Add('6=( www.40tude.com/dialog/ )')
       FileStringList.Add('7=( news:de.comm.software.40tude-dialog )')
       FileStringList.Add('8=(Crying with the cats.)')
       FileStringList.Add('9=(Dressed to kill)')
       FileStringList.Add('10=(My Newsreader No.1)')     
       FileStringList.SaveToFile(DialogOrdner + 'UserAgents.ini');
       WriteToLog ( 'Eine neue Datei wurde erstellt' ,4);
       ChangeAnyHeaderRandom_MessageBox(0, 'A default UserAgents.ini file has been created in ' + DialogOrdner + ' with 10 entries.', 'Good to Go', 64+4096+0);
       FileStringList := TStringList.create;
       FileStringList.LoadFromFile(DialogOrdner + 'UserAgents.ini');
     end
   else
     begin
       FileStringList := TStringList.create;
       FileStringList.LoadFromFile(DialogOrdner + 'UserAgents.ini');
     end

   if AddOnChangeRandom then AddOnChangeHeader := ' ' + FileStringList.Values[keyrandom]
   
   if ((IsEmail=true)  and (ChangeInEmails=true)) or
      ((IsEmail=false) and (ChangeInNews=true)) then begin
         s := Message.text;
         i := 1;
         while (Message.Strings[i]<>'') do begin
            if pos(ChangeHeader,Message.Strings[i]) = 1 then begin
               Message.Strings[i] := changeheader + AddOnChangeHeader;
               s := Message.text; 
            end;
            i := i + 1;
         end; {end of while}
      message.text := s;
    end;
  result := true;
  end;
end;
 
Technical Details
Message-ID: <isulxkb484a0$.dlg@sqwertz.org>
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!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!postnews7.readnews.com!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <isulxkb484a0$.dlg@sqwertz.org>
Subject: [Dialog] Random Header Generator Script
Date: Sun, 12 Dec 2010 01:50:58 -0600
From: Sqwertz <sqwertz@cluemail.compost>
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!border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!198.186.194.249.MISMATCH!transit3.readnews.com!news-out.readnews.com!postnews7.readnews.com!not-for-mail
Newsgroups: news.software.readers
User-Agent: MacSOUP/2.6b4 (Mac OS X version 10.4.5)
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Lines: 202
NNTP-Posting-Host: 6418ab74.blocknews.net
X-Trace: DXC=bJ_eK<_cia?]PWc[l53bf;
 GTXUl?iR^P<<X<c6\A0782YX_n_cE\Ge1?R\\JEjWJ4=PB7fBSDkC66[WMY^^J91:>
X-Complaints-To: abuse@blocknews.net
X-Original-Bytes: 8945