🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #59973

Re: [slrn/ s-lang] multiple post-hooks addind custom-headers

#59973
From: John E. Davis
Date: Sun, 02 Apr 2000 00:00
60 lines
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

Technical Details
Message-ID: <slrn8ef7v9.4df.davis@aluche.mit.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <rejo.954595435m@sisterray.xs4all.nl> <slrn8eciau.bg3.bluemoon@ux6.cso.uiuc.edu> <rejo.954628360m@sisterray.xs4all.nl> <slrn8ed5rk.2hf.davis@aluche.mit.edu> <rejo.954678191m@sisterray.xs4all.nl>

Show Full Headers
Complete Article Headers
Message-ID: <slrn8ef7v9.4df.davis@aluche.mit.edu>
Subject: Re: [slrn/ s-lang] multiple post-hooks addind custom-headers
Date: Sun, 02 Apr 2000 00:00:00 +0000
From: davis@space.mit.edu (John E. Davis)
References: <rejo.954595435m@sisterray.xs4all.nl> <slrn8eciau.bg3.bluemoon@ux6.cso.uiuc.edu> <rejo.954628360m@sisterray.xs4all.nl> <slrn8ed5rk.2hf.davis@aluche.mit.edu> <rejo.954678191m@sisterray.xs4all.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 605744662
X-Trace: dreaderd 954703850 2956 18.75.2.45
Organization: Center for Space Research
User-Agent: slrn/0.9.6.3 (Linux)
Reply-To: davis@space.mit.edu
Newsgroups: news.software.readers