Added .wtf command

This commit is contained in:
lanxu 2015-11-22 12:01:33 +02:00
parent 89a5df9e2b
commit a075e3fe2c
3 changed files with 22 additions and 2 deletions

10
app.js
View File

@ -35,6 +35,7 @@ var getDnDCharacter = require('./plugins/getCharacter')();
var getDiceString = require('./plugins/getDice')();
var getUrlString = require('./plugins/getUrl')();
var getTweet = require('./plugins/getTweet')(config);
var getInstantAnswer = require('./plugins/getInstantAnswer')(config);
// Configure logger
// create a write stream (in append mode)
@ -111,7 +112,14 @@ var handleMessage = function(from, to, message) {
var character = getDnDCharacter();
client.say(to, ''+character);
}
// Instant Answer
if (res = message.match(/^\.wtf (.+)$/i)) {
getInstantAnswer(res[1]).then(function(answer) {
client.say(to, '' + answer);
})
}
// Throw dice
if (res = message.match(/^\.heit(a|ä) ([0-9]+)d([0-9]+)$/i)) {
var th = getDiceString(res[2], res[3]);

View File

@ -11,7 +11,18 @@ var res = text.match(regExp);
console.log(res[5]);
console.log(res[7]);
var DDG = require('node-ddg-api').DDG;
var ddg = new DDG('my-app-name');
ddg.instantAnswer('dw', {skip_disambig: '0'}, function(err, response) {
console.log(response);
console.log('"' + response.RelatedTopics[0].Text + '" | ' + response.RelatedTopics[0].FirstURL);
});
/*
var tweet = "https://twitter.com/lanxu/status/266184139324157952";
var config = require('./config');
@ -25,7 +36,7 @@ getTweet(sta).then(
console.log(tweet);
}
);
*/
/*

View File

@ -27,6 +27,7 @@
"node-uuid": "latest",
"irc": "latest",
"googleapis": "latest",
"node-ddg-api": "latest",
"twitter": "latest"
},
"devDependencies": {