forked from GitHub/dbot
fix up wolframalpha
This commit is contained in:
parent
03f2ac16b5
commit
721ed55598
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"ignorable": true,
|
||||
"appID": "blah"
|
||||
"api_key": "blah"
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"result": {
|
||||
"wolf_result": {
|
||||
"en": "{output}"
|
||||
},
|
||||
"error": {
|
||||
"wolf_error": {
|
||||
"en": "Something went wrong :( Example:'~calculate (2+2)'"
|
||||
}
|
||||
}
|
||||
|
@ -10,24 +10,21 @@ var _ = require('underscore')._,
|
||||
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 wolfram = new Client(this.config.api_key),
|
||||
query = event.params[1];
|
||||
wolfram.query(query, function(err, result) {
|
||||
if(err) {
|
||||
event.reply(dbot.t('wolf_error'));
|
||||
console.log(err);
|
||||
} else {
|
||||
var out = "";
|
||||
for(var a=0; a<result.queryresult.pod.length; a++)
|
||||
{
|
||||
for(var a=0; a<result.queryresult.pod.length; a++) {
|
||||
var pod = result.queryresult.pod[a];
|
||||
out += pod.$.title;
|
||||
out +=": ";
|
||||
for(var b=0; b<pod.subpod.length; b++)
|
||||
{
|
||||
for(var b=0; b<pod.subpod.length; b++) {
|
||||
var subpod = pod.subpod[b];
|
||||
for(var c=0; c<subpod.plaintext.length; c++)
|
||||
{
|
||||
for(var c=0; c<subpod.plaintext.length; c++) {
|
||||
var text = subpod.plaintext[c];
|
||||
console.log('\t', text);
|
||||
out += text;
|
||||
@ -35,12 +32,11 @@ var wolframalpha = function(dbot) {
|
||||
}
|
||||
}
|
||||
}
|
||||
event.reply(dbot.t('result',{'output':out}));
|
||||
event.reply(dbot.t('wolf_result',{'output':out}));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
Loading…
Reference in New Issue
Block a user