Skip to content

Instantly share code, notes, and snippets.

@wingrunr21
Created October 23, 2013 13:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wingrunr21/7118744 to your computer and use it in GitHub Desktop.
Save wingrunr21/7118744 to your computer and use it in GitHub Desktop.
A simple catchall script for Hubot to process anything it doesn't know how to handle via Wolfram|Alpha
Wolfram = require('wolfram-alpha').createClient(process.env.HUBOT_WOLFRAM_APPID)
module.exports = (robot) ->
robot.catchAll (msg) ->
r = new RegExp "^(?:#{robot.alias}|#{robot.name}) (.*)", "i"
matches = msg.message.text.match(r)
if matches != null && matches.length > 1
Wolfram.query matches[1], (e, result) ->
if result and result.length > 0
msg.send result[1]['subpods'][0]['text']
else
msg.send 'Beats me'
msg.finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment