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

8
app.js
View File

@ -35,6 +35,7 @@ var getDnDCharacter = require('./plugins/getCharacter')();
var getDiceString = require('./plugins/getDice')(); var getDiceString = require('./plugins/getDice')();
var getUrlString = require('./plugins/getUrl')(); var getUrlString = require('./plugins/getUrl')();
var getTweet = require('./plugins/getTweet')(config); var getTweet = require('./plugins/getTweet')(config);
var getInstantAnswer = require('./plugins/getInstantAnswer')(config);
// Configure logger // Configure logger
// create a write stream (in append mode) // create a write stream (in append mode)
@ -112,6 +113,13 @@ var handleMessage = function(from, to, message) {
client.say(to, ''+character); client.say(to, ''+character);
} }
// Instant Answer
if (res = message.match(/^\.wtf (.+)$/i)) {
getInstantAnswer(res[1]).then(function(answer) {
client.say(to, '' + answer);
})
}
// Throw dice // Throw dice
if (res = message.match(/^\.heit(a|ä) ([0-9]+)d([0-9]+)$/i)) { if (res = message.match(/^\.heit(a|ä) ([0-9]+)d([0-9]+)$/i)) {
var th = getDiceString(res[2], res[3]); 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[5]);
console.log(res[7]); 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 tweet = "https://twitter.com/lanxu/status/266184139324157952";
var config = require('./config'); var config = require('./config');
@ -25,7 +36,7 @@ getTweet(sta).then(
console.log(tweet); console.log(tweet);
} }
); );
*/
/* /*

View File

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