AppSec expert Niroshan Rajadurai says putting developers at the center of everything will enable you to meet your security goals.
For the past year or so we’ve been telling people about Hubot, our amazing Campfire bot. We have a lot of fun working on Hubot. He makes us laugh, he ships our code, he is the interface to our CI server, and a whole lot more. Over the last year, he’s grown bigger and messier. So we decided to rewrite him from scratch, open source him, and share him with everyone.
Hubot is a library and an executable that wraps up all the logic of connecting to chat servers. Right now there are adapters for Campfire and IRC, but adding stuff like Hipchat or other services should be pretty trivial. The main hubot library is where the core of Hubot lives, but it just scratches the surface.
These are where Hubot’s scripts reside. This is where the magic happens. The fun stuff, the serious stuff, the weird stuff… hubot-scripts is designed as a place where we can share scripts with the entire community at large. You can browse it for interesting scripts, drop them into your own bot, and contribute your own work to the repository.
At his core, Hubot simply idles in various rooms and waits for specific strings to go by in the chat.
robot.hear /problem??/i, (msg) -> msg.send "http://cl.ly/BG7R/trollface.jpg"
With this snippet, Hubot will listen for the phrase
problem?, and then dutifully embed the classic trollface image into the chat.
Sometimes listening for strings isn’t what you want. Sometimes you want to command Hubot to do your bidding. For that, the robot has a different method.
robot.respond /(image|img)( me)? (.*)/i, (msg) -> imagery = msg.match msg.http('http://ajax.googleapis.com/ajax/services/search/images') .query(v: "1.0", rsz: '8', q: query) .get() (err, res, body) -> images = JSON.parse(body) images = images.responseData.results msg.send msg.random images
This snippet pulls down a random image from Google Image Search. Something like
hubot image me pugs would find a random pug image and paste it into the channel.
We really love Hubot. It’s a shared side project that everyone at GitHub can (and does!) contribute to on a regular basis. For us, Hubot’s much more than just a repository and a collection of scripts… he’s part of our culture.
We’re giving you the core of Hubot, and some of the scripts that make up Hubot. But it’d be a shame if you just stopped there. Build out some of your own scripts. Let your company take your bot however you’re destined to take it. We bet you’ll enjoy it as much as we do.