A bot that connects to IRC and parses commands from the IRC users to do physical tasks.

The bot connects to a chosen IRC network and joins a specified channel. It automatically handles ping requests. It parses incoming private messages and stores them as IrcMessages. The IrcMessage passed to each of a list of MessageHandlers. These can perform actions and optionally send a reply back to either a user or channel.


I've released the core code as a library:

Import libraryIrcBot

The IrcBot class can connect to a channel on an IRC network. Users on the same network can send messages to the bot that are parsed by message handlers. The included handlers read digital/analog inputs and write digital outputs or echo messages back to the command sender/channel. Users can write their own message handlers inheriting from the MessageHandler class to perform different actions.


I've been running a demonstration on the #oxford-hack-space channel on freenode (I'm the user nick_ on that channel and others, including #mbed, drop by and say hello). It is using the basic In/Output handlers I've written. The DigitalOutHandler controls turns on/off an LED, the DigitalInHandler reports that state of a push button and the AnalogInHandler measures the voltage in a potential divider. These are connected on a bread board with my mbed and a RJ45 ethernet socket on a cool components breakout board.

In the demo video below I turn on and off an LED, read a button when it is on and off and read the value on a pot. The commands and responses on IRC were:


14:57 <@nick_> mbedbot: WRITE GREENLED ON
14:57 < mbedbot> SET GREENLED ON
14:57 <@nick_> mbedbot: READ BUTTON
14:57 < mbedbot> BUTTON is OFF
14:57 <@nick_> mbedbot: READ BUTTON
14:57 < mbedbot> BUTTON is ON
14:57 <@nick_> mbedbot: READ POT
14:57 < mbedbot> POT = 0.138608 V
14:57 <@nick_> mbedbot: WRITE GREENLED OFF
14:57 < mbedbot> SET GREENLED OFF

Schematic for demo Demo in breadboard


  • LightSensorHandler - Check if the lights are on using the command "LIGHTS?"
  • DigitalOutHandler - Turn on/off a digital output with "WRITE <NAME> ON/OFF"
  • DigitalInHanlder - Read a digital input with "READ <NAME>"
  • AnalogInHanlder - Read an analog input with "READ <NAME>"
  • EchoHandler - Echo a message back with "ECHO <msg>"

Planned improvements

  • Allow users to specified a list of IRC nicknames allowed to use a handler
  • Have the handlers automatically determine whether to respond to an IRC channel or a specific IRC user
  • Automatically detect lost connections and attempt to reconnect
  • Identify with the IRC network so the bot's nickname can be registered
  • Have the bot provide a list of available commands
  • Write a bunch more handlers
  • Add a power supply (or use PoE?) so the breadboard can be left connected for long periods

Eventually my plan is to write handlers for some sensors (temperate, light level, etc.) and outputs (IR remote control, etc.) to deploy the mbedbot at the Oxford Hackspace. If people have any cool ideas for the kinds of electronics the bot could control from IRC commands please add comments below.

Please log in to post comments.