Article View: news.software.readers
Article #64636Re: [slrn] scoring feature idea
From: Christian Perrier
Date: Sat, 19 Aug 2000 00:00
Date: Sat, 19 Aug 2000 00:00
105 lines
4078 bytes
4078 bytes
Kaz Kylheku <kaz@ashi.footprints.net> wrote :
>It would be nice, in a slrn score file entry, to have some syntax for referring
>to attributes of the parent articles. For example some special prefix symbol,
>like @.
For such purposes, I use the included macro. The idea is to "open"
the article from idiot@moron.com and then launch the macro (I do
this by assigning Ctrl-K to the macro).
You can combine this with an automatic system for removing expired entries
from your score file...like Felix Schueller's cleanscore.pl
I am not the original author of this. I only adapted it to my needs.
Unfortunately, I did not keep track of original authors (who are
regular readers of this group). Apologies to them.
This only works on a Unix system with GNU 'date' installed (it is
maybe OK with Cygnus port of GNU date on NT with some
modifications). One has first to define a call_external function,
designed to cal an external command and return its output.
% implements ("my");
define call_external (cmd)
{
variable
tempfile = "/tmp/tempfile",
retval = Global->system (sprintf ("%s >%s", cmd, tempfile)),
fp = fopen (tempfile, "r"),
contents = "";
if (fp == NULL) error ("Can\'t open temp file: " + errno_string (errno));
foreach (fp) using ("line") contents += ();
if (fclose (fp) == -1)
error ("Can\'t close temp file: " + errno_string (errno));
% return (retval, contents);
return (contents);
}
% test the code out, show how it works.
% variable r, c;
% (r,c) = my->system ("ls");
% vmessage ("return value: %d", r);
% message (c);
define kill_thread ()
{
variable scorefile = "/home/bubulle/News/Score"; % <= EDIT THIS LINE!
variable killthread_score = "-100" ;
variable killthread_duration = "30 days" ;
if (is_group_mode ())
error (_function_name () + " doesn\'t work in group mode.");%
variable fp = fopen (scorefile, "a");
% variable fp = fopen (get_variable_value ("scorefile"), "a");
if (fp == NULL) error ("Couldn\'t open scorefile: " + errno_string (errno));
variable line;
% foreach (["[*] % Killing " + extract_article_header ("Subject"),
foreach ([
"",
"[" + extract_article_header ("Newsgroups") + "]",
" % Killing thread : " + extract_article_header ("Subject"),
" Score:: =" + killthread_score,
" Expires: " + string (call_external ("date --date='" + killthread_duration +"' +%d-%m-%Y"))
])
{
line = () + "\n";
if (-1 == fputs (line, fp))
error ("Can\'t write to scorefile: " + errno_string (errno));
}
variable
msgID,
header = "References",
refs = extract_article_header (header);
!if (strlen (refs)) % Must be a thread-starter
{
header = "Message-ID";
refs = extract_article_header (header);
}
foreach (strtok (refs))
{
msgID = ();
if (-1 == fputs (sprintf (" %s: %s\n", header, msgID), fp))
error ("Can\'t write to scorefile: " + errno_string (errno));
}
if (-1 == fclose (fp))
error ("Can\'t close scorefile: " + errno_string (errno));
}
definekey ("kill_thread", "^K", "article");
Technical Details
Message-ID:
<8nlg46$h2$2@mykerinos>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-mailReferences:
<slrn8pr44j.jck.kaz@ashi.FootPrints.net>Show Full Headers
Complete Article Headers
Message-ID: <8nlg46$h2$2@mykerinos> Subject: Re: [slrn] scoring feature idea Date: Sat, 19 Aug 2000 00:00:00 +0000 From: bubulle@mykerinos.kheops.frmug.org (Christian Perrier) References: <slrn8pr44j.jck.kaz@ashi.FootPrints.net> 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: 660055959 Content-Transfer-Encoding: 8bit Mail-Copies-To: never X-Server-Date: 19 Aug 2000 08:22:30 GMT Content-Type: text/plain; charset=iso-8859-1 Organization: | :noitazinagrO User-Agent: slrn/0.9.6.2 (Linux) Mime-Version: 1.0 Reply-To: bubulle@kheops.frmug.org Newsgroups: news.software.readers