From fb14f249277f381a6e28f78bde9383575de3c893 Mon Sep 17 00:00:00 2001 From: thoso Date: Thu, 20 Feb 2014 07:23:25 +0100 Subject: [PATCH] TVDB module Added a tvdb module, needs to request apikey. may or may not work due to tvshow array. --- modules/tvdb/README.md | 32 +++++++++++++++++++++ modules/tvdb/config.json | 4 +++ modules/tvdb/strings.json | 8 ++++++ modules/tvdb/tvdb.js | 59 +++++++++++++++++++++++++++++++++++++++ modules/tvdb/usage.json | 3 ++ 5 files changed, 106 insertions(+) create mode 100644 modules/tvdb/README.md create mode 100644 modules/tvdb/config.json create mode 100644 modules/tvdb/strings.json create mode 100644 modules/tvdb/tvdb.js create mode 100644 modules/tvdb/usage.json diff --git a/modules/tvdb/README.md b/modules/tvdb/README.md new file mode 100644 index 0000000..fd22daa --- /dev/null +++ b/modules/tvdb/README.md @@ -0,0 +1,32 @@ +## theTVDB + +Addes various TVDB funtionalities. + +### Description + +This module provides a command which allows users to search for series on theTVDB.com. + +### Dependencies + +It has following dependencies: ++ [node-tvdb](https://github.com/enyo/node-tvdb) + +### config.json + +ignorable and apiKey can be set. A key can be requested at http://thetvdb.com/?tab=apiregister +``` +{ + "ignorable": true, + "apiKey": "blah" +} +``` + +### Commands + + +#### ~tvdb [series] +Searches for series on theTVDB +Example: ++ ~tvdb How I met your Mother + +### TODO \ No newline at end of file diff --git a/modules/tvdb/config.json b/modules/tvdb/config.json new file mode 100644 index 0000000..1f5a2d7 --- /dev/null +++ b/modules/tvdb/config.json @@ -0,0 +1,4 @@ +{ + "ignorable": true, + "apiKey": "blah" +} \ No newline at end of file diff --git a/modules/tvdb/strings.json b/modules/tvdb/strings.json new file mode 100644 index 0000000..a08974e --- /dev/null +++ b/modules/tvdb/strings.json @@ -0,0 +1,8 @@ +{ + "result": { + "en": "{name} - {banner} - http://thetvdb.com/?id={id}" + }, + "error": { + "en": "Something went wrong :( Example:'~tvdb How I met your Mother'" + } +} diff --git a/modules/tvdb/tvdb.js b/modules/tvdb/tvdb.js new file mode 100644 index 0000000..fdb11dc --- /dev/null +++ b/modules/tvdb/tvdb.js @@ -0,0 +1,59 @@ +/** + * Module Name: theTVDB + * Description: Addes various TVDB functionality. + * Requires: node-tvdb [https://github.com/enyo/node-tvdb] + */ + +var _ = require('underscore')._, + TVDB = require('tvdb'), + thetvdb = new TVDB({ apiKey: this.config.apiKey });//dependencies + +var tvdb = function(dbot) { //name of module + + this.ApiRoot = 'API_ROOT_HERE'; + + this.internalAPI = { + //code for internal api here + }; + + this.api = { + //code for api here + }; + + this.commands = { + //code for commands here + '~tvdb' : function(){ + var query = event.input[1]; + thetvdb.findTvShow(query, function(err, tvShows) { + if (err) + { + event.respond(dbot.t('error'); + return; + } + else + { + // Handle tvShows. + var name=tvShows[0].SeriesName, + banner=tvShows[0].banner, + id=tvShows[0].id; + event.reply(dbot.t('result',{'name':name,'banner'=banner,'id'=id})); + } + }; + + } + }; + + this.onLoad = function() { + //code for stuff to be done on load here + }; + + this.onDestroy = function() { + //stuff to be done on destroy here + }; + } + +}; + +exports.fetch = function(dbot) { + return new tvdb(dbot); //name of module +}; diff --git a/modules/tvdb/usage.json b/modules/tvdb/usage.json new file mode 100644 index 0000000..c22bf02 --- /dev/null +++ b/modules/tvdb/usage.json @@ -0,0 +1,3 @@ +{ + "~tvdb": "~tvdb [series]" +} \ No newline at end of file