Thread View: news.software.readers
11 messages
11 total messages
Started by Rejo Zenger
Sat, 01 Apr 2000 00:00
[slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Rejo Zenger
Date: Sat, 01 Apr 2000 00:00
Date: Sat, 01 Apr 2000 00:00
21 lines
1749 bytes
1749 bytes
Hi, Is it correct that i cannot have multiple followup-hooks that add custom header lines in different files? I would like to have multiple s-lang files that get sourced from within my slrnrc that all will, when needed, add custom header lines. I have been testing this lately a few times, but it seems it will only add hte lines that are specified in the file that gets sourced last. Is this correct, or am i doing wrong something else wrong here? -Rejo. -- = Rejo Zenger rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers --------------------------------------------------------------------------------
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: John E. Davis
Date: Sat, 01 Apr 2000 00:00
Date: Sat, 01 Apr 2000 00:00
15 lines
1107 bytes
1107 bytes
On 1 Apr 2000 15:30:57 +0200, Rejo Zenger <rejo.954595435f@sisterray.xs4all.nl>
wrote:
>Is it correct that i cannot have multiple followup-hooks that add custom
>header lines in different files?
No. You can always use something like
#v+
set_string_variable ("followup_custom_headers",
get_variable_value ("followup_custom_headers")
+ "Another_Header: value\n");
#v-
--John
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Dawn Owens-Nicholson
Date: Sat, 01 Apr 2000 00:00
Date: Sat, 01 Apr 2000 00:00
21 lines
1722 bytes
1722 bytes
Rejo Zenger wrote: > Is it correct that i cannot have multiple followup-hooks that add custom > header lines in different files? No, you can have as many followup hooks as you want in as many files as you want, but only one of them will do anything. If you load them all, as you discovered, only the last one loaded will work because each one redefines the hook loaded from the one before. Hooks are S-Lang functions, just like any other S-Lang function, with two small exceptions: hooks are global (not all the other functions you'll deal with are global) and hooks are commonly executed by slrn, not by another S-Lang function. You need to make a single followup hook that runs the code you want it to either loading the code from another file or executing already loaded code. If you post more details about what you're trying to do, maybe we can help you better.
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: John E. Davis
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
60 lines
3081 bytes
3081 bytes
On 2 Apr 2000 14:46:37 +0200, Rejo Zenger <rejo.954678191f@sisterray.xs4all.nl>
wrote:
[...]
> default_headers = get_variable_value ("custom_headers");
> default_followup_headers = get_variable_value ("followup_custom_headers");
[...]
> h = default_headers;
> h = sprintf ("%s\nMessage-ID: <rejo.%dm%s>", h, _time (), "@sisterray.xs4all.nl");
> set_string_variable ("custom_headers", h);
> }
>
> if (0 == (strcmp(current_newsgroup, "nl.support.sysadmin")))
> {
> h = sprintf ("%s\nApproved: <rejo.%da%s>", h, _time (), "@sisterray.xs4all.nl");
> set_string_variable ("custom_headers", h);
[...]
>However, in the next one, the Message-Id (and the Approved field when
>needed) field will be doubled. For example:
[...]
>Any idea? Thanks in advance for your help,
The above code fragments show that you are doubling these headers.
When you set a variable via set_string_variable, it stays set until
you call it again. Each time your hook gets called, your
message-id will get appended to custom_headers because you have coded
it that way. Similarly, your custom_headers will get an Approved
header added when you post to nl.support.sysadmin. However, unless
you set custom_headers again, the Approved header will remain part of
your custom headers.
You need to rethink how you are setting these headers. You should
probably use something like:
#v+
variable Fixed_Custom_Headers = "X-Whatever: foo\n";
variable Fixed_Followup_Headers = "";
define some_hook ()
{
variable custom_headers = Fixed_Custom_Headers;
variable followup_headers = Fixed_Followup_Headers;
if (current_newsgroup == "nl.support.sysadmin")
{
custom_headers += sprintf ("Approved: <rejo.%da%s>\n",
_time (), "@sisterray.xs4all.nl");
}
custom_headers += sprintf ("Message-ID: <rejo.%dm%s>",
_time (), "@sisterray.xs4all.nl");
.
.
set_string_variable ("custom_headers", custom_headers);
set_string_variable ("followup_custom_headers", followup_headers);
}
#v-
--John
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: John E. Davis
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
46 lines
1915 bytes
1915 bytes
On 2 Apr 2000 01:26:39 +0200, Rejo Zenger <rejo@sisterray.xs4all.nl>
wrote:
>So, what i have now are two separate files, but only one gets executed,
>although both are sourced. Any idea's what's the best way to deal with
>this?
There are several possibilites. You could always create a ``master''
followup hook that does:
#v+
static variable Followup_Hooks = NULL;
define add_followup_hook (hook)
{
variable h = struct {
hook, next
}
h.hook = hook;
h.next = Followup_Hooks;
Followup_Hooks = h;
}
define followup_hook ()
{
variable h = Followup_Hooks;
while (h != NULL)
{
@h.hook ();
h = h.next;
}
}
#v-
Then you can add a hook such as:
#v+
static define spamtraps_followup_hook ()
{
% whatever
}
add_followup_hook (&spamtraps_followup_hook);
#v-
--
John E. Davis Center for Space Research/AXAF Science Center
617-258-8119 One Hampshire St., Building NE80-6019
http://space.mit.edu/~davis Cambridge, MA 02139-4307
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Rejo Zenger
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
58 lines
3681 bytes
3681 bytes
++ <slrn8ef7v9.4df.davis@aluche.mit.edu>; John E. Davis:
>The above code fragments show that you are doubling these headers.
>When you set a variable via set_string_variable, it stays set until
>you call it again. Each time your hook gets called, your
>message-id will get appended to custom_headers because you have coded
[...]
Excellent explenation. It took some time for me to completly realize
what you were saying, but now this is clear to me. Thank you!
While testing things, i also ran into another problem of which the error
message wasn't very clear. I tried to set a variable to a string, but it
seems to be that the string nay not exceed 255 characters. Is that
correct? I have now solved this now like this:
variable Fixed_Custom_Headers = "";
Fixed_Custom_Headers += sprintf ("X-PGP-Id: ELG-E/DSS: 0x75FC50F3,
DSS/DH: 0x2C8059B5, RSA: 0xFAE40065\n");
Fixed_Custom_Headers += sprintf ("X-PGP-Keys: Available at keyserver
and website or finger <sister@xs4all.nl>.\n");
Fixed_Custom_Headers += sprintf ("X-Spamtrap: For quicker replies
please use the email address in my signature.\n");
The lines are rewrapped because of posting. I guess this isn't the best
method for solving this, but it works.
This leaves me with two additional questions (sorry for bugging you so
much). The first thing is this. I now have almost twice the same code
in my spamtraps.sl. This is because one of them is a followup-hook and
the other a post-hook. Is there a variable (or whatever those things are
called) which replaces the functions of both the "post-hook" and the
"followup-hook"? Say, a merged post- and followup-hook?
Second things is, i have noted these signs all prepending and trailing
quotes of scripts:
>#v+
[...]
>#v-
These denote a slang script is following? Or more like a diff thing? In
other words, do they have a special meaning?
Thanks a lot for your excellent time and help!
-Rejo.
PS. One last question, where can i learn more about s-lang? I have
looked for webpages on slang in relation to slrn, but i couldn't a thing
that comes close to what is usefull for me.
--
= Rejo Zenger rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Rejo Zenger
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
39 lines
2590 bytes
2590 bytes
++ <slrn8eciau.bg3.bluemoon@ux6.cso.uiuc.edu>; Dawn Owens-Nicholson: >If you post more details about what you're trying to do, maybe we can help >you better. Well, what i want is this: I have set a few followup-hooks that will change my From, Reply-To, Message-Id and add, if needed, an Approved field. These addressed need to be unique as i use them as spamtraps. See [1] for the ultimate details about these spamtraps. I also do have some other, more regular stuff, that needs to be changed from time to time, like group specific signatures. Now i would like to have the spamtrap part in a different file from the rest as i will make the spamtrap part available to the rest of the world - some people already showed interest. However, i don't feel the need (or the urge) to post the other parts to my homepage. As i don't want to remove the non-spamtrap bits out of the file everytime i change the spamtraps stuff, it would be nice to have them in a separate file. So, what i have now are two separate files, but only one gets executed, although both are sourced. Any idea's what's the best way to deal with this? Thanks for all the help, -Rejo. [1] <rejo.954454114m@sisterray.xs4all.nl> -- = Rejo Zenger rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers --------------------------------------------------------------------------------
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Rejo Zenger
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
111 lines
4630 bytes
4630 bytes
++ <slrn8ed5rk.2hf.davis@aluche.mit.edu>; John E. Davis:
>>So, what i have now are two separate files, but only one gets executed,
>>although both are sourced. Any idea's what's the best way to deal with
>>this?
>
>There are several possibilites. You could always create a ``master''
>followup hook that does:
[...]
Great! This is almost working perfectly. Almost, as in one way or
another it will add the Message-Id from the previous post again when
adding a new one. :-(
This is what i have now in news/slang/post.sl:
variable signature;
signature = get_variable_value ("signature");
define post_hook ()
{
variable h;
if (0 == (strcmp(current_newsgroup, "nl.newsgroups")))
{
signature = ".signature-nn";
set_string_variable ("signature", signature);
}
[other post_hook's]
}
And this in news/slang/spamtraps.sl:
[comments]
static define spamtraps_post_hook ()
{
variable default_username;
variable default_headers;
variable default_followup_headers;
default_username = get_variable_value ("username");
default_headers = get_variable_value ("custom_headers");
default_followup_headers = get_variable_value ("followup_custom_headers");
set_string_variable ("username", sprintf ("rejo.%df", _time ()));
set_string_variable ("replyto", sprintf ("rejo.%dr%s", _time (), "@sisterray.xs4all.nl"));
variable h;
{
h = default_headers;
h = sprintf ("%s\nMessage-ID: <rejo.%dm%s>", h, _time (), "@sisterray.xs4all.nl");
set_string_variable ("custom_headers", h);
}
if (0 == (strcmp(current_newsgroup, "nl.support.sysadmin")))
{
h = sprintf ("%s\nApproved: <rejo.%da%s>", h, _time (), "@sisterray.xs4all.nl");
set_string_variable ("custom_headers", h);
}
}
add_post_hook (&spamtraps_post_hook);
static define spamtraps_followup_hook ()
[see post_hook]
add_followup_hook (&spamtraps_followup_hook);
And this is what i have in .slrnrc:
$ grep interpret .slrnrc
interpret "news/slang/post.sl"
interpret "news/slang/followup.sl"
interpret "news/slang/spamtraps.sl"
So, what happens is this:
The first message that gets posted gets the correct headers:
Reply-To: rejo.954678191r@sisterray.xs4all.nl
X-PGP-Id: ELG-E/DSS 0x75FC50F3, DSS/DH 0x2C8059B5, RSA 0xFAE40065
X-PGP-Keys: Available at keyserver and website or finger <sister@xs4all.nl>.
X-Spamtrap: For quicker replies please use the email address in my signature.
Message-ID: <rejo.954678191m@sisterray.xs4all.nl>
However, in the next one, the Message-Id (and the Approved field when
needed) field will be doubled. For example:
Message-ID: <rejo.954678191m@sisterray.xs4all.nl>
Approved: <rejo.954678191a@sisterray.xs4all.nl>
Message-ID: <rejo.954678245m@sisterray.xs4all.nl>
Approved: <rejo.954678245a@sisterray.xs4all.nl>
In one way or another, it seems that the buffer no longer gets emptyied.
Any idea? Thanks in advance for your help,
-Rejo.
--
= Rejo Zenger rejo@sisterray.xs4all.nl
= http://mediaport.org/~sister (and my_urls.html) PGP: see headers
--------------------------------------------------------------------------------
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Dawn Owens-Nicholson
Date: Mon, 03 Apr 2000 00:00
Date: Mon, 03 Apr 2000 00:00
57 lines
3190 bytes
3190 bytes
Rejo Zenger wrote:
> While testing things, i also ran into another problem of which the error
> message wasn't very clear. I tried to set a variable to a string, but it
> seems to be that the string nay not exceed 255 characters. Is that
> correct?
Yes. Another way to make a larger string is to put your literals in an
array and concatenate the array elements.
> I now have almost twice the same code in my spamtraps.sl. This is because
> one of them is a followup-hook and the other a post-hook. Is there a
> variable (or whatever those things are called) which replaces the functions
> of both the "post-hook" and the "followup-hook"? Say, a merged post- and
> followup-hook?
There's no function for that but you could make a function containing the
shared code that is called by both hooks. If you're setting variables to
the same values in both, you could pass variables by reference to the
shared function:
define shared_function (a, b, c)
{
@a = 1;
@b = 2;
@c = 3;
}
define my_post_hook ()
{
variable post_a, post_b, post_c;
shared_function (&post_a, &post_b, &post_c);
}
define my_followup_hook ()
{
variable followup_a, followup_b, followup_c;
shared_function (&followup_a, &followup_b, &followup_c);
}
> These denote a slang script is following? Or more like a diff thing? In
> other words, do they have a special meaning?
They're to prevent slrn from marking up (and therefore altering) the content
of the article between those two marks. *Bold*, _underlined_ and
/italicized/ words are rendered differently than unadorned text. Check out
slrn/doc/changes.txt and the sample slrn.rc slrn/doc/slrn.rc for details on
configuring this markup.
> PS. One last question, where can i learn more about s-lang? I have
> looked for webpages on slang in relation to slrn, but i couldn't a thing
> that comes close to what is usefull for me.
Check out the doc directory of the standard S-Lang distribution from
space.mit.edu. It has documentation on S-Lang functions and an S-Lang
guide.
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: John E. Davis
Date: Tue, 04 Apr 2000 00:00
Date: Tue, 04 Apr 2000 00:00
11 lines
1364 bytes
1364 bytes
On 4 Apr 2000 20:38:28 GMT, Rejo Zenger <rejo.954880559f@sisterray.xs4all.nl> wrote: >Will do that. I think i have done so before and that i couln't find the >thing i was looking for, but i will do so one of these days again. Maybe >i have overlooked a thing. See http://space.mit.edu/%7Edavis/doc/slang/doc/html/slang.html. --John
Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Author: Rejo Zenger
Date: Tue, 04 Apr 2000 00:00
Date: Tue, 04 Apr 2000 00:00
29 lines
2519 bytes
2519 bytes
++ <slrn8efp14.d6i.bluemoon@ux6.cso.uiuc.edu>; Dawn Owens-Nicholson: >They're to prevent slrn from marking up (and therefore altering) the content >of the article between those two marks. *Bold*, _underlined_ and >/italicized/ words are rendered differently than unadorned text. Check out >slrn/doc/changes.txt and the sample slrn.rc slrn/doc/slrn.rc for details on >configuring this markup. Aah. I already about those markup stuff and i already use these, but i just didn't know what those marks were for. Thanks for explaining. >Check out the doc directory of the standard S-Lang distribution from >space.mit.edu. It has documentation on S-Lang functions and an S-Lang >guide. Will do that. I think i have done so before and that i couln't find the thing i was looking for, but i will do so one of these days again. Maybe i have overlooked a thing. Thanks for your answer. -Rejo. -- = Rejo Zenger rejo@sisterray.xs4all.nl = http://mediaport.org/~sister (and my_urls.html) PGP: see headers --------------------------------------------------------------------------------
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