Python IRC Bot

One of the things in which I never reached a decent level of knowledge is IRC. I mean I know the basic stuff in order to connect to servers, join channels, send/receive files etc. What I know nothing of is actually IRC server or channel administration… I am not going to learn or write more about it now.

What I need at the moment is an automatic IRC client, a bot. I want it to be able to connect to the specified server and channel and stay there without sending any messages, but keep logs of all the conversation at that channel, so I do not miss anything… I need a bot with a CLI interface, so I can set it to run from my always-on machine’s terminal, no GUIs and no unnecessary resource consumption. In other words I need the bot to be able to:

  • connect to a server and try to reconnect automatically if the connection is lost
  • identify my nick to the server
  • join the specified channel and keep a log of the conversation
  • play the request-response (ping-pong) game with the server so to be able to stay online as long as I want
  • be extremely reliable.

Well, this is not a hell of features! I guess a bot with these capabilities would be very easy to implement in Python, but no time for this kind of stuff… A google search returned some interesting results about such bots. I think I’ll stick to clients written in Python only because this is the language I know well enough, so, in case I need to modify anything, it will be rather easy.

So, here is supybot, phenny, pynfo and pyfibot. All seem to cover my needs, but I think I’ll stick to the supybot. Its website seemed more organised and I have the feeling that I will find any kind of help easily, if I need it.

Apart from these ready-made clients, here are a few articles where the authors document the creation of such a bot with very primitive functionality: IRC bot in python from scratch and a simple IRC bot written in python (note: pages are down).

Furthermore, if help about the IRC commands or the protocol itself is required, take a loog at IRChelp.org and at IRC RFCs .

PS: so where am I supposed to test these bots? Freenode or should I quickly set up a local IRC server?

Python IRC Bot by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2007 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

2 responses on “Python IRC Bot

  1. George Notaras Post authorPermalink →

    Hi Aggelos, I didn’t know about this. I guess I will set up a server locally to test things…

    Thanks for bringing it to my attention. :)