Article View: es.comp.os.linux.programacion
Article #13373Python+IRC
From: Jesús Carrete Montaña
Date: Mon, 26 Feb 2001 20:42
Date: Mon, 26 Feb 2001 20:42
70 lines
2918 bytes
2918 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Buenas.
Estoy haciendo un programa en python que tiene que conectar a
un servidor IRC. Me he armado del RFC correspondiente, pero tengo un
problema bastante gordo: el servidor me tira por ping timeout. Os pego
una parte del c�digo:
- ---
Connection=telnetlib.Telnet()
#Mandamos USER y NICK
try:
Connection.open(Server,Port)
Connection.write("USER "+UserName+" "+HostName+" "+ServerName+" "\
+RealName)
Connection.write("NICK "+NickName)
except EOFError:
print "Couldn't stabilish connection."
PingRe=re.compile("(PING) \:(.*)", re.M)
#proceso de mensajes
#muy sencillo, de momento es un busy loop que espera un ping
while Exit==0:
try:
Messages=Connection.read_eager()
except EOFError: #Connection closed
Exit=1
print "Connection has been closed. Exiting."
continue
if not Messages=="":
print Messages #Just for debug purposes
PING = PingRe.search(Messages)
if not PING == None :
print "PONG "+PING.group(1)
Connection.write("PONG "+PING.group(1)+"\n")
- ---
Deber�a funcionar, �no? Si hago lo mismo por telnet a mano parece
funcionar. �Podr�a ser algo relacionado con el formato d elos EOL
quiz�s?
Un saludo y gracias por vuestro tiempo y ayuda.
- --
"!Dios aleje de nosotros la serenidad de los ignorantes!
�Dios aparte de nosotros la paz de los cobardes!" (De Gasparin)
Jes�s Carrete Monta�a (Kuantiko) <kuantiko@escomposlinux.org>
LRU #158442 -> I use free software. | PGP Key -> pgp.rediris.es
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Processed by Mailcrypt and GnuPG
iD8DBQE6mr+TfUtQQKOnZ1IRAoO2AKC6CgSQ/ImX9rFwmsiccC7XdUdWngCglVWB
R8V3t7ir7HLrnlU3q03DH5s=
=+Oy/
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<87d7c5fa79.fsf@relativistic.homeip.net>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!109-coru-x12.libre.retevision.ES!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,f1050350a83d78c5,start X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-02-26 12:50:07 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!109-coru-x12.libre.retevision.ES!not-for-mail From: kuantiko@escomposlinux.org (Jesús Carrete Montaña) Newsgroups: es.comp.os.linux.programacion Subject: Python+IRC Date: 26 Feb 2001 21:42:02 +0100 Lines: 70 Sender: kuantiko@relativistic.homeip.net Message-ID: <87d7c5fa79.fsf@relativistic.homeip.net> NNTP-Posting-Host: 109-coru-x12.libre.retevision.es (62.83.49.109) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 983220531 26426950 62.83.49.109 (16 [54696]) User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7