Thread View: news.software.readers
1 messages
1 total messages
Started by Alain GUERIN
Wed, 02 Jul 2003 13:44
Customizing posts
Author: Alain GUERIN
Date: Wed, 02 Jul 2003 13:44
Date: Wed, 02 Jul 2003 13:44
100 lines
4460 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads