From 721ed5559858ec2fab4c2806f8c5b621df8ed414 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 20 Feb 2014 20:19:44 +0000 Subject: [PATCH] fix up wolframalpha --- modules/wolframalpha/README.md | 4 +- modules/wolframalpha/config.json | 4 +- modules/wolframalpha/strings.json | 4 +- modules/wolframalpha/wolframalpha.js | 64 +++++++++++++--------------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/modules/wolframalpha/README.md b/modules/wolframalpha/README.md index 9ec2965..d2a524a 100644 --- a/modules/wolframalpha/README.md +++ b/modules/wolframalpha/README.md @@ -19,7 +19,7 @@ appID has to be added into config.json. It can be obtained at http://products.wolframalpha.com/developers/ for free. `{ "ignorable": true, - "appID": "APP_ID_HERE" + "api_key": "APP_ID_HERE" }` ### Commands @@ -30,4 +30,4 @@ Example: + ~calculate (2+2) + ~calculate (x^2+2x+4) -### TODO \ No newline at end of file +### TODO diff --git a/modules/wolframalpha/config.json b/modules/wolframalpha/config.json index cca4bd1..e71ec72 100644 --- a/modules/wolframalpha/config.json +++ b/modules/wolframalpha/config.json @@ -1,4 +1,4 @@ { "ignorable": true, - "appID": "blah" -} \ No newline at end of file + "api_key": "blah" +} diff --git a/modules/wolframalpha/strings.json b/modules/wolframalpha/strings.json index 2f1ab84..2bf2c6e 100644 --- a/modules/wolframalpha/strings.json +++ b/modules/wolframalpha/strings.json @@ -1,8 +1,8 @@ { - "result": { + "wolf_result": { "en": "{output}" }, - "error": { + "wolf_error": { "en": "Something went wrong :( Example:'~calculate (2+2)'" } } diff --git a/modules/wolframalpha/wolframalpha.js b/modules/wolframalpha/wolframalpha.js index ef8674e..bf0105e 100644 --- a/modules/wolframalpha/wolframalpha.js +++ b/modules/wolframalpha/wolframalpha.js @@ -5,42 +5,38 @@ */ var _ = require('underscore')._, - Client = require('node-wolfram'); + Client = require('node-wolfram'); var wolframalpha = function(dbot) { - this.commands = { - '~calculate': function(event) { - var wolfram = new Client(this.config.appID); - var query = event.input[1]; - wolfram.query(event.input[1], function(err, result) { - if(err) - event.reply(dbot.t('error')); - else - { - var out = ""; - for(var a=0; a