Article View: es.comp.os.linux.programacion
Article #16967Programa en slrn para rellenar el filtro de leafnode
From: Gorka Olaizola
Date: Tue, 07 Mar 2000 00:00
Date: Tue, 07 Mar 2000 00:00
120 lines
4517 bytes
4517 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hola,
He acabado hoy un peque�o script en slang para el slrn para filtrar el
email de la cabecera "From" y mandarlo directamente al fichero de filtros
de leafnode. Lo adjunto al final.
Parece que funciona bien, saca el email del campo From y pone la expresi�n
regular en el fichero de filtros. No funciona bien en un caso, por ejemplo
com mi From no saca bien la direcci�n, pero por m�s vueltas que le doy no
consigo que funcione. Es la primera vez que me meto con expresiones
regulares y estoy un poco perdido.
Agradecer�a si entre todos podeis mejorar la b�squeda del email.
El problema est� en la expresi�n regular de esta l�nea.
Lo que va entre \\( y \\) es la parte de la expresi�n
que luego se mandar� al filtro.
matched = string_match(strtrim(linea), ".*[ (<]\\(.*@.*\\)[>) ]", 1);
Para usarlo en slrn pulsar la tecla ^f (Control-f)
Espero que os sirva.
- ------------------------------ Cortar aqu� --------------------------------
% [spambuster.sl]
%
% Copyright(c) mar mar 7 22:38:57 CET 2000 Gorka Olaizola
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
% --------------------------------------------------------------------
%
% Uso: Pon este script en ~/.slrn/ y esta l�nea en tu .slrnrc:
% interpret ".slrn/spam-buster.sl"
%
% Que hace: Manda el email del campo From directamente a
% /etc/news/leafnode/filters
%
% Gracias a los posteadores habituales de es.comp.os.linux.*
%
% Normas del grupo en http://linux-es.com/es.comp.os.linux.*/
% --------------------------------------------------------------------
variable email = "olsago@jet.es";
variable fichero="/etc/news/leafnode/filters";
define leer_from(fichero)
{
variable fp, linea;
variable matched, pos, len;
variable nombre="ERROR - ponte en contacto con "+email;
fp = fopen (fichero, "r");
while (fgets(&linea, fp) > 0) {
if (strncmp(linea, "From", 4)==0)
break;
}
matched = string_match(strtrim(linea), ".*[ (<]\\(.*@.*\\)[>) ]", 1);
if (matched) {
(pos, len) = string_match_nth(1);
nombre = substr (linea, pos+1, len);
}
return nombre;
}
define filtrar_from()
{
variable errcode=0;
variable spammer="";
variable tmpfile="/tmp/slrn.spambuster-tmpfile";
variable cmd="su -c";
errcode=save_current_article(tmpfile);
if (errcode!=0) {
error("No puedo crear el archivo temporal");
return();
}
spammer = leer_from(tmpfile);
errcode = system(sprintf("%s \"echo \'\^\(\?i:from\):.\*\[ \(<\]%s\'>>%s\"", cmd, spammer, fichero, 3));
if (errcode!=0)
{
error("Se ha producido un error. Posiblemente la contrase�a de root era incorrecta");
}
else
{
message("Un filtro m�s, otro spammer menos");
}
return();
}
definekey ("filtrar_from", "^f", "article");
- ------------------------------ Cortar aqu� --------------------------------
- --
|||
(- -)
oOOo(_)oOOo--------------------------------------------------------------
| "Smile... tomorrow will be worse." Murphy |
|-------------------------------------------------------------------------|
| olsago @ jet.es -=[Debian GNU/Linux 2.1]=- KeyID:0x659ADB2A |
| http://personales.jet.es/olsago/ http://fly.to/luzluciernaga |
-------------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE4xXmAAJWwPWWa2yoRAlxHAKCO4NQAxYYclCVkkloOppXcNKbXLgCfYvPP
EYxVFTLfd1SczgPiPSCMj90=
=/1xX
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<slrn8cauc3.ml3.gorka@conan.hondarribia.org>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,3ecccdb8f1103ce6,start X-Google-Attributes: gidf86c8,public From: gorka@news.hondarribia.org (Gorka Olaizola) Subject: Programa en slrn para rellenar el filtro de leafnode Date: 2000/03/07 Message-ID: <slrn8cauc3.ml3.gorka@conan.hondarribia.org> X-Deja-AN: 594441153 Content-Transfer-Encoding: 8bit Organization: Organización organizada de organizadores organizados Content-Type: text/plain; charset=iso-8859-1 User-Agent: slrn/0.9.5.3 (UNIX) Mime-Version: 1.0 Reply-To: olsago@jet.es Newsgroups: es.comp.os.linux.programacion