# Description: # accede a wolfram alpha # # Dependencies: # "wolfram":"0.3.1" # # Configuration: # WOLFRAM_API_KEY - self explanatory # # Commands # hubot wolfram/wfa/quanto fa/compute ... - pone la domanda a Wolfram Alpha # # Author: # Enrico Fasoli (fazo96) # module.exports = (robot) -> if not process.env.WOLFRAM_API_KEY? console.log 'NO WOLFRAM_API_KEY SET!' return # no api key, no wolfy wolfram = require('wolfram').createClient process.env.WOLFRAM_API_KEY robot.respond /(?:quanto fa|compute|wfa|wolfram) (.+)/i, (res) -> res.send 'contattando Wolfram Alpha...' wolfram.query res.match[1], (err, result) -> if err then return res.send err parseSubPod = (subpod) -> subpod.value or subpod.image parsePod = (pod) -> '\n=== ' + pod.title + '\n' + pod.subpods.map(parseSubPod).join('\n') res.send (parsePod(pod) for pod in result).join('')