Pregunta

Digamos que usted es un telnet en el IRC de averiguar cómo funciona todo. Como se emite mandatos el servidor devuelve datos de IRC que le dice lo que está haciendo. Una vez que he creado un script por defecto que es básicamente cómo se produce una conexión IRC normal entre servidor y cliente, si es que alguna vez se desvía de que no me dirá lo que está mal. Tengo que ser capaz de lanzar excepciones en base a lo que el servidor vuelve a mí. ¿Cómo puedo hacer que en Python?

¿Fue útil?

Solución

Aquí hay un tutorial que prácticamente le guía a través de un cliente de IRC usando sockets en Python:

Otros consejos

Twisted es un motor de red orientada a eventos escrito en Python, e incluye soporte para protocolos IRC. Para acceder a la funcionalidad IRC, importarlo:

from twisted.words.protocols import irc

aquí : ircLogBot.py - se conecta a un servidor IRC y registra todos los mensajes. El ejemplo __doc__:

"""An example IRC log bot - logs a channel's events to a file.

If someone says the bot's name in the channel followed by a ':',
e.g.

  <foo> logbot: hello!

    the bot will reply:

  <logbot> foo: I am a log bot

Run this script with two arguments, the channel name the bot should
connect to, and file to log to, e.g.:

  $ python ircLogBot.py test test.log

will log channel #test to the file 'test.log'.
"""
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top