Say you are telneting into IRC to figure out how it all works. As you issue commands the IRC server returns data telling you what it's doing. Once I have created a default script that basically is how a normal IRC connection between server and client occurs, if it ever deviates from that it won't tell me what is wrong. I need to be able to throw exceptions based on what the server returns to me. How do I do that in python?
A:
Twisted is an event-driven networking engine written in Python, and includes support for IRC
protocols. To access IRC
functionality, import it:
from twisted.words.protocols import irc
See an example here: ircLogBot.py - connects to an IRC server and logs all messages. The example __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'.
"""
gimel
2009-07-13 17:57:27
+1
A:
Here's a tutorial which pretty much walks you through an IRC client using sockets in Python:
ars
2009-07-13 18:14:26
I've already looked at that and I'll revisit this evening. I'm trying to understand how to view the chat in an object oriented way. Thanks!
NoahClark
2009-07-13 18:28:57
I see. Some other articles by that author (http://www.devshed.com/cp/bio/Peyton-McCullough/) go over using the Python-IRC library, which is an OO wrapper around IRC functionality (based on a quick read). Maybe looking at how they do it will help.
ars
2009-07-13 18:35:47
Thank you, I'll check that out too.
NoahClark
2009-07-13 18:38:03