IRC channel topic HTTP API using Hubot

Hackatron’s team largely uses IRC to stay connected, we use it also to track next meetings schedules: the topic of #hackatron channel is set to something like “Next HCKTRN 7:00 pm, 01/29 @ Meme Coworking” so everybody who joins the chat room is always updated about our next meeting.

There’s a little drawback about this way of setting next meetings schedules: it can’t be shared easily. We don’t want to create a new Facebook event for every meeting but we’d like also an easy way to put it on http://hackatron.org so even who doesn’t want to connect to IRC can be updated about next Hackatron event.

Basically we’d like to access IRC channel topic through HTTP so we can show next event informations using Javascript but freenode hasn’t an API then how can we achieve this?

Here’s where Hubot, a chat bot developed originally at GitHub, comes to the rescue! We’re using it at #hackatron channel, his name is Hackabot, it’s a useful tool and it’s been an interesting topic to work on.

Giovanni made a Hubot script to access topic data using a public API which responds to HTTP requests. The script adds an IRC listener to topic event which stores inside robot’s brain the channel topic, and a HTTP listener to /hubot/topic/:channel which responds to GET requests with a Javascript function call wrapped around the selected channel topic.

The API responds with application/javascript content because it uses the JSONP communication technique, this way Giovanni simply put a little script in Hackatron static site to get the result dynamically.

Now we can finally say: get info about our next meeting at http://hackatron.org, or as usual by joining #hackatron at irc.freenode.net.