mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
food suggest
This commit is contained in:
parent
e46135d1ec
commit
9d682455f5
@ -31,6 +31,25 @@ var food = function(dbot) {
|
||||
}
|
||||
};
|
||||
this.commands['~recipe'].regex = [/^recipe (.+)$/, 2];
|
||||
|
||||
this.listener = function(event) {
|
||||
var match = event.message.match(new RegExp(dbot.config.name + ': what should i (have|eat|make)\\??( for dinner)?\\??', 'i'));
|
||||
if(match) {
|
||||
request.get('http://food2fork.com/api/search', {
|
||||
'qs': {
|
||||
'key': this.config.api_key,
|
||||
},
|
||||
'json': true
|
||||
}, function(error, response, body) {
|
||||
if(_.isObject(body) && _.has(body, 'recipes') && body.recipes.length > 0) {
|
||||
var num = _.random(0, body.recipes.length - 1),
|
||||
recipe = body.recipes[num];
|
||||
|
||||
event.reply('You should make ' + recipe.title + '. See: ' + recipe.source_url);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
|
Loading…
Reference in New Issue
Block a user