Created
October 23, 2013 13:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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