Skip to content

Instantly share code, notes, and snippets.

@jsit
Created June 22, 2021 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsit/516862ad189108bf618624566e2c387f to your computer and use it in GitHub Desktop.
Save jsit/516862ad189108bf618624566e2c387f to your computer and use it in GitHub Desktop.
Kill messages from user and all replies to messages from user in slrn
% Path: pingwin.icm.edu.pl!agh.edu.pl!news.wnaft.agh.edu.pl!news.memax.krakow.pl!news.sim.pl!lublin.pl!uw.edu.pl!news.nask.pl!orion.cst.tpsa.pl!news.task.gda.pl!news.icm.edu.pl!home.extravaganza.pl!jr211
% From: jr211@students.mimuw.edu.pl (Jan Rekorajski)
% Newsgroups: pl.comp.os.advocacy
% Subject: Re: Dajcie =?iso-8859-2?Q?ju=BF_spok=F3j?= Expertowi
% Date: 12 Apr 1999 02:38:42 GMT
% Organization: The Shire
% Lines: 249
% Message-ID: <slrn7h2n5i.17q.jr211@home.extravaganza.pl>
% References: <N6VM2.4295$_u5.498155@news.tpnet.pl> <370A77BD.7FDDBAED@vela.filg.uj.edu.pl> <Pine.LNX.4.02.9904070915210.829-100000@manjak.knm.org.pl> <c7g16c39by.fsf@home.bti.pl> <slrn7gn3dv.s0.druzus@uran.nat.org.pl> <370BD987.C4BDC2D8@fnet.pl>
% NNTP-Posting-Host: pf157.warszawa.ppp.tpnet.pl
% Mime-Version: 1.0
% Content-Type: text/plain; charset=iso-8859-2
% Content-Transfer-Encoding: 8bit
% X-Trace: sunsite.icm.edu.pl 923925846 20295 212.160.57.157 (12 Apr 1999 14:04:06 GMT)
% X-Complaints-To: abuse@news.icm.edu.pl
% NNTP-Posting-Date: 12 Apr 1999 14:04:06 GMT
% User-Agent: slrn/0.9.5.4 (UNIX)
% Xref: pingwin.icm.edu.pl pl.comp.os.advocacy:28049
%
% On Thu, 08 Apr 1999 00:17:43 +0200, Zbigniew Okoñ <okon@fnet.pl> wrote:
% >Przemyslaw Czerpak napisa³:
% >>
% >> ps. Score z slrna jest super.
% >
% >Zgadza siê. Ale tego, o czym pisa³em, nie potrafi :(.
% >
%
% Troche pó¼no, ale... Potrafi :)
% Slrn ma przecierz w sobie interpreter S-lang.
% Po napisaniu kilku funkcji mogê killowaæ wszelkich Expertów i tych co próbuj±
% z nimi dyskutowaæ...
%
% My¶lê ¿e nikt siê za 5K kilfile-a nie obrazi :)
%
% Przepis (wymaga slang 1.3.x - mo¿e ¼le dzia³aæ ze starszymi wersjami):
%
% 1) do ~/.slrnrc dopisaæ linijkê:
%
% interpret ".slrn.sl"
%
% 2) do ~/.slrn.sl wpisaæ:
%
% -- tu ci±æ ---
definekey ("kill_idiot", "^K", "article");
define kill_idiot()
{
variable rsp, idiot, group, score, fp, score_file;
idiot = extract_article_header("From");
group = current_newsgroup();
score = read_mini("Score", "-9999", "");
if (Integer_Type != _slang_guess_type(score) )
error("Integer expected.");
rsp = get_response("tTaA", "Which newsgroups: \001This group, \001All groups");
if (rsp == 'a' or rsp == 'A' )
group = ".*";
score_file = make_home_filename("News/Score.idiots");
fp = fopen(score_file, "a");
if (fp == NULL)
error("Connot open Score.idiots.");
fputs(group, fp);
fputs("\n", fp);
fputs(score, fp);
fputs("\n", fp);
fputs(idiot, fp);
fputs("\n", fp);
fclose(fp);
message("Exit group for changes to take effect.");
}
define idiot_test(what, idiots)
{
variable tl;
tl = idiots;
while (tl != NULL) {
if (0 != string_match(what, tl.text, 1))
return tl.score;
tl = tl.next;
}
return 0;
}
define article_mode_hook ()
{
variable msgid_cache, score_file, num, b;
variable msgid, from, group, ref, buf, n, tl, fp;
variable root, tail, iroot, itail, new_score;
variable msgid_list = struct { text, date, score, next };
variable idiots_list = struct { text, score, next };
group = current_newsgroup();
msgid_cache = make_home_filename(".slrn.msgid-cache");
score_file = make_home_filename("News/Score.idiots");
iroot = NULL;
itail = NULL;
fp = fopen(score_file, "r");
if (fp == NULL)
return;
while (-1 != fgets(&buf, fp)) {
buf = strtrim(buf);
if (0 != string_match(group, buf, 1)) {
fgets(&buf, fp);
n = atof(buf);
fgets(&buf, fp);
if (iroot == NULL) {
iroot = @idiots_list;
itail = iroot;
} else {
itail.next = @idiots_list;
itail = itail.next;
}
itail.text = strtrim(buf);
itail.score = n;
itail.next = NULL;
}
}
fclose(fp);
root = NULL;
tail = NULL;
num = 0;
fp = fopen(msgid_cache, "r");
if (fp != NULL) {
while (-1 != fgets(&buf, fp)) {
if (0 == string_match(buf, group, 1))
continue;
if (root == NULL) {
root = @msgid_list;
tail = root;
} else {
tail.next = @msgid_list;
tail = tail.next;
}
n = strchop(buf, ':', 0);
tail.text = strtrim(n[3]);
tail.score = int(atof(strtrim(n[2])));
tail.next = NULL;
num++;
}
fclose(fp);
}
do {
msgid = extract_article_header("Message-ID");
n = 0;
tl = root;
while (tl != NULL) {
if (0 != string_match(tl.text, msgid, 1)) {
set_header_score(get_header_score() + tl.score);
n = 1;
break;
}
tl = tl.next;
}
if (n != 0)
continue;
from = extract_article_header("From");
ref = extract_article_header("References");
new_score = 0;
new_score = idiot_test(from, iroot);
if (0 != new_score) {
n = get_header_score() + new_score;
set_header_score(int(n));
if (root == NULL) {
root = @msgid_list;
tail = root;
} else {
tail.next = @msgid_list;
tail = tail.next;
}
tail.text = msgid;
tail.score = new_score;
tail.date = extract_article_header("Date");
tail.next = NULL;
} else {
tl = root;
while (tl != NULL) {
if (0 != string_match(ref, tl.text, 1)) {
n = get_header_score() + tl.score;
set_header_score(int(n));
break;
}
tl = tl.next;
}
}
% } while (1 == header_down(1));
} while (0 != header_next_unread());
fp = fopen(msgid_cache, "a");
if (fp == NULL)
return;
tl = root;
while (tl != NULL) {
num--;
if (num >= 0) {
tl = tl.next;
continue;
}
n = strchop(tl.date, ' ', 0);
buf = n[2];
if (2 == strlen(buf))
buf = "19" + buf;
switch (strup(n[1]))
{ case "JAN" : buf += " 01 "; }
{ case "FEB" : buf += " 02 "; }
{ case "MAR" : buf += " 03 "; }
{ case "APR" : buf += " 04 "; }
{ case "MAY" : buf += " 05 "; }
{ case "JUN" : buf += " 06 "; }
{ case "JUL" : buf += " 07 "; }
{ case "AUG" : buf += " 08 "; }
{ case "SEP" : buf += " 09 "; }
{ case "OCT" : buf += " 10 "; }
{ case "NOV" : buf += " 11 "; }
{ case "DEC" : buf += " 12 "; }
{ buf += " 00 "; };
b = n[0];
if (2 != strlen(b))
buf += "0" + b;
else
buf += b;
() = fputs(buf, fp);
fputs(":", fp);
fputs(group, fp);
fputs(":", fp);
fputs(string(tl.score), fp);
fputs(":", fp);
fputs(tl.text, fp);
fputs("\n", fp);
tl = tl.next;
}
fclose(fp);
}
% -- tu ci±æ --
%
% 3) do ~/News/Score.idiots wpisujemy:
% -- tu ci±æ --
% pl.*
% -9999
% Expert
% -- tu ci±æ --
%
% schemat jest taki:
% grupa(y) - regexp
% score - od 9999 do -9999
% charakterystyczny kawa³ek z From:
%
% 4) regularnie przeczyszczaæ zbiór ~/.slrn.msgid-cache
%
% Janek
%
% --
% ---=======================================================================----
% Jan Rêkorajski | Come to think of it, there are already a million monkeys on a
% a.k.a | million typewriters, and Usenet is NOTHING like Shakespeare.
% Mr. Baggins | Blair Houghton
% ---=======================================================================----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment