3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 21:09:31 +01:00
dbot/modules/tvdb/tvdb.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Module Name: theTVDB
* Description: Addes various TVDB functionality.
* Requires: node-tvdb [https://github.com/enyo/node-tvdb]
*/
var _ = require('underscore')._,
2014-02-20 21:10:45 +01:00
TVDB = require('tvdb');
2014-02-20 21:10:45 +01:00
var tvdb = function(dbot) {
this.commands = {
'~tvdb' : function(event) {
var query = event.input[1];
this.thetvdb.findTvShow(query, function(err, tvShows) {
if (err) {
event.reply(dbot.t('tvdb_error'));
} else {
// Handle tvShows.
var name = tvShows[0].name,
id = tvShows[0].id;
2014-02-20 21:10:45 +01:00
event.reply(dbot.t('tvdb_result', {
'name': name,
'id': id
}));
}
});
}
};
this.commands['~tvdb'].regex = [/^tvdb ([\d\w\s-]*)/, 2];
this.onLoad = function() {
this.thetvdb = new TVDB({ 'apiKey': this.config.api_key });
}.bind(this);
};
exports.fetch = function(dbot) {
2014-02-20 21:10:45 +01:00
return new tvdb(dbot);
};