update wolfram alpha module

This commit is contained in:
Enrico Fasoli 2015-04-27 20:56:20 +02:00
parent a9ee8ac6ad
commit 7e6c60dd61

View File

@ -4,6 +4,12 @@
# 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)
#
@ -18,10 +24,7 @@ module.exports = (robot) ->
res.send 'contattando Wolfram Alpha...'
wolfram.query res.match[1], (err, result) ->
if err then return res.send err
#res.send JSON.stringify result
parseSubPod = (subpod) -> subpod.value
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('')