Module Puppy - Giving Hubot a drop of Drupal knowledge
We've been using the delightful Hubot chat bot with Campfire for a while now and I've been looking to ways to add Drupal-related features to it.
One idea was to add a
module me <query> command that searches for modules. Unfortunately drupal.org doesn't offer an API, but the update module uses a humongous XML file that contains some useful information like name, short name, creator and url for all projects hosted on drupal.org.
I wrote a little Sinatra app called Module Puppy that pulls down and parses relevant data from this XML file and makes it available via a simple JSON API. The app is hosted on Heroku which uses PostgreSQL as the default database. This meant that I could use the very nice multi-column search feature in PostgreSQL (easy with the texticle gem).
This makes Hubot listen for the phrase:
there's a module for <something>
and also, the more direct command:
<bot name> module me <something>
In practice, it looks like this: