UNPKG

hubot-scripts

Version:

Allows you to opt in to a variety of scripts

33 lines (30 loc) 674 B
# Description: # Grab XKCD comic image urls # # Dependencies: # None # # Configuration: # None # # Commands: # hubot xkcd - The latest XKCD comic # hubot xkcd <num> - XKCD comic <num> # # Author: # twe4ked module.exports = (robot) -> robot.respond /xkcd\s?(\d+)?/i, (msg) -> if msg.match[1] == undefined num = '' else num = "#{msg.match[1]}/" msg.http("http://xkcd.com/#{num}info.0.json") .get() (err, res, body) -> if res.statusCode == 404 msg.send 'Comic not found.' else object = JSON.parse(body) msg.send object.alt msg.send object.title msg.send object.img