Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Dialog] Scripting question

1 view
Skip to first unread message

Ernie Ramaker

unread,
Oct 27, 2003, 6:46:37 PM10/27/03
to

I have this script to add a Distribution-header to outgoing messages:

program OnBeforeSendingMessage;

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
message.insert (1, 'Distribution: world');
end;

begin
end.

Now, if I wanted to check which newsgroup the message is sent to, and
then only add the header if that group is "foo.bar", how would I go
about doing that?

Jarrod Cifer

unread,
Oct 27, 2003, 11:54:02 PM10/27/03
to
Ernie Ramaker, upon reaching Nirvana, postulated:

> Now, if I wanted to check which newsgroup the message is sent to, and
> then only add the header if that group is "foo.bar", how would I go
> about doing that?

I'm not a scripting expert, but you might want to take a look at
http://40tude.com/dialog/wiki/index.php/JustifyMessage

The script contains the function you're looking for and you should be able
to extract it for your own use.
--
J. Cifer

matija

unread,
Oct 28, 2003, 2:26:56 AM10/28/03
to
Ernie Ramaker, completely geschtonkenflapped, wrote:
> Now, if I wanted to check which newsgroup the message is sent to, and
> then only add the header if that group is "foo.bar", how would I go
> about doing that?

program OnBeforeSendingMessage;

const cNewsgroups = 'Newsgroups: ';
cGroup = 'foo.bar';
cDistribution = 'Distribution: world';

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

var i : integer;
begin
for i := 0 to message.count-1 do
begin
if copy(message.strings[i], 1, length(cNewsgroups)) = cNewsgroups then
begin
if pos(cGroup, message.strings[i]) > 0 then
begin
message.insert (1, cDistribution);
break;
end;
end;
end;
end;

begin
end.


of course, this won't work properly if you're posting to a
group called 'megafoo.bar' :)

(all possible typos and compile errors are due to the fact that
i woke up a couple of minutes ago.)


--
there is a cheer. the gnomes have learned a new way to say hooray. [-shpongle]

address is scrambled - remove SPAMISEVIL to reply

Ernie Ramaker

unread,
Oct 28, 2003, 4:41:20 AM10/28/03
to
matija:

> (all possible typos and compile errors are due to the fact that
> i woke up a couple of minutes ago.)

Thanks, Matija! It works perfectly.

matija

unread,
Oct 28, 2003, 6:21:37 AM10/28/03
to
Ernie Ramaker, completely geschtonkenflapped, wrote:

sometimes i scare myself. if i'm able to make a working piece
of code exactly four and a half minutes after being violently
woken up from my sleep, well...

0 new messages