Written January 12, 2004
Posted December 19, 2006

Genericbot is a generic framework for an IRC bot, written in Perl. It only depends on one module: IO::Socket::INET, which should be a standard module in a modern Perl distribution.

Genericbot will, in its current form, join channel #test on (which may or may not actually exist), and sit there. If anyone addresses it directly or /msgs it, it will respond with a simple sentence. If the connection is dropped for any reason, genericbot will re-join the channel after a timeout period.

Genericbot is intended to be used as the basis for bots that actually do interesting things, like shorten URLs, or look up search terms on, etc. It should provide enough functionality that all you need to do is add the interesting stuff, and it should Just Work.

Genericbot does the following interesting things:

  • Handles PINGs automatically
  • Reconnects to the channel if the connection to the server is lost for any reason (including KILL), but gracefully goes away if commanded to.
  • Responds to housekeeping requests, like "help", "die", "status"
  • Provides a simple example function showing how to respond to a comment
  • Learns about PING intervals on your server and adjusts its timeout alarm automatically (this is easily disabled if you want it to maintain a set timeout)
  • Responds publically if publically addressed, or via /msg if addressed via /msg
  • Code is moderately fault-tolerant to alert the programmer to mistakes being made
  • Code is commented well enough that a moderately skilled Perl programmer should be able to understand everything that's going on

Click here to download genericbot


Added December 19, 2006

Urlbot is a project started ages ago (initial coding date unknown), with the goal of automatically shortening long URLs pasted into an IRC session. This is particularly useful for people running terminal-based IRC clients, which wrap the URLs, usually making them impossible to copy and paste.

I first became aware of it around 2005, when it became clear that it would make a good test case for building a real-world bot out of genericbot. I have finally explored it, and come up with a perfectly functional system.

This version of urlbot is based on genericbot, with modifications and additions taken from the old urlbot code. In general, code snippets were used rather than huge chunks of code. This version is definitely a modified genericbot, and not a modified urlbot.

This urlbot retains all the features of genericbot, as listed above. It also adds:

  • Expanded "status" and "help" commands
  • Scans every line of text received for URLs, and shortens those over a set limit (by submitting them to external shortening services)
  • Automatically switches services if the current one doesn't appear to be functional
  • Maintains a "seen" database, tracking nick, date, and last thing said by everyone on monitored channels
  • Capable of joining multiple channels at user command
  • "Switch" command allows manual switching of URL shortening services
  • Keeps a log of URLs mentioned, and provides a web-server based system for retrieving them

Download the urlbot system

Created by Ian Johnston. Questions? Please mail me at reaper at obairlann dot net.