🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #127537

Customizing posts

#127537
From: Alain GUERIN
Date: Wed, 02 Jul 2003 13:44
100 lines
4460 bytes
Hello,
I tried to modified the editing window with postkey, in order to have the
hello message in the language of the news group.
I failes as there was no way to open by program the newsgroup list and
detect the newsgroup.

>From the script made by matija and the advises from Juergen Haible, I try
another way and now I have it.

This new script is working for new posts and for following posts.

It add a line at the beginning of the post depending on the newsgroup:
it could be adapted to any header information line, for example to insert an
hello depending on the time of the day or whatever you want.

program OnBeforeSendingMessage;

type
   TLanguage = (LFrench, LEnglish, LGerman);     
   
function FindLanguage(VAR List : TStringList; LanguageFileName: string;
NewsHeader : string): boolean;
begin
   list.LoadFromFile(LanguageFileName);
   Result := list.indexof(NewsHeader) > -1

(*  where each line is a newsgroup in the language tested:

Newsgroups: news.software.readers
Newsgroups: carlokok.public.pascalscript

This function could be modify to avoy to have 'Newsgroups: ' in each line of
the text file by deleting it from Newsheader *)

end;

function SelectLanguage(NewsHeader : String):TLanguage;

var 
   list: TStringList;


begin                   
   Result := LFrench;
   list := TStringList.Create();
   IF FindLanguage(List,'C:\Mes documents\English groups.txt',NewsHeader)
THEN
      Result := LEnglish
   ELSE 
      IF FindLanguage(List,'C:\Mes documents\German groups.txt',NewsHeader)
THEN
      	Result := LGerman;
   list.free;    

(* or in code option:
   IF (POS('news.software.readers', NewsHeader) > 0) 
   OR (POS('carlokok.public.pascalscript', NewsHeader) > 0) THEN
      Result := LEnglish;
but it is case sensitive in this way ;-)                                   
*)
end;                                    

function OnBeforeSendingMessage(var Message: TStringlist; Servername:
string; IsEmail: boolean):boolean;

var
   HeaderCount : INTEGER;
   InsertionContent : String;              
   Language : TLanguage;

begin
//Your code goes here
//Return false to prevent sending the passed message
   HeaderCount := 0;
   WHILE (HeaderCount < Message.count) AND (pos(':',
Message.Strings[HeaderCount]) > 0) DO
   BEGIN                      
      IF pos('Newsgroups:', Message.Strings[HeaderCount]) = 1 THEN
         Language := SelectLanguage(Message.Strings[HeaderCount]);
      HeaderCount:=HeaderCount+1;
   END;
   case Language of
      LFrench : 
         InsertionContent :='Bonjour,';
      LEnglish: 
         InsertionContent :='Hello,';
      LGerman: 
         InsertionContent :='Guten Tag,';
   end;
   IF InsertionContent <> '' THEN
      message.insert (HeaderCount+1, InsertionContent);   
   result:=true;
end;

begin                    
end.

If this message begins with "bonjour", I have a bug in my script :-)
-- 
A.G.
Technical Details
Message-ID: <3f02e1c2$0$23997$626a54ce@news.free.fr>
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!news5.aus1.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.nuthinbutnews.com!propagator2-sterling!In.nntp.be!news.completel.fr!ircam.fr!usenet-fr.net!proxad.net!feeder2-1.proxad.net!news1-1.free.fr!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <3f02e1c2$0$23997$626a54ce@news.free.fr>
Subject: Customizing posts
Date: Wed, 2 Jul 2003 15:44:34 +0200
From: Alain GUERIN <news40@spamout-alain-guerin.com.invalid>
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!news5.aus1.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.easynews.com!easynews.com!easynews!news-out.nuthinbutnews.com!propagator2-sterling!In.nntp.be!news.completel.fr!ircam.fr!usenet-fr.net!proxad.net!feeder2-1.proxad.net!news1-1.free.fr!not-for-mail
Newsgroups: news.software.readers
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Reply-To: news40@alain-guerin.com
Organization: NA
X-Face: GOI#J$,onz-'Uz6us^h!d&!=/wSO@@FxWc?}1i_p@/E%ViONg.TD9>V7VA4(S/j%&mb%4uD
 ,=8(bmy`{t`AM[~^Y#8*]ZJ;
 {y2%EU,B'%$9[qEDa)B{/P4+eTD5E4{Un+XE$|RWd(=aNN%(,yP,cG
 =k=7dqQ"euLbBTVKLCV-Ql@aFEdzF1F6GU4b}qG%JPDjL'~T2;
 -03s=7s5[QUH@>GQ!CLJ@S{%K[m1
 $j`EsD+M&'5>>&-'tfiB0p',<4e0SN,4NDZ:f._qI9vVW0[r\~yk7{.GmY^cN*&/=5qjcH&Q; $
User-Agent: 40tude_Dialog/2.0.5.1
Lines: 100
NNTP-Posting-Date: 02 Jul 2003 15:44:34 MEST
NNTP-Posting-Host: 81.57.20.30
X-Trace: 1057153474 news1-1.free.fr 23997 81.57.20.30:1090
X-Complaints-To: abuse@proxad.net