diff --git a/modules/500px/500px.js b/modules/500px/500px.js new file mode 100644 index 0000000..89e61ca --- /dev/null +++ b/modules/500px/500px.js @@ -0,0 +1,56 @@ +/** + * Module Name: 500px + * Description: Adds various 500px functionality. + * Requires: node-500px [http://mjgil.github.io/five-px/] + */ + +var _ = require('underscore')._, + API500px = require('500px').API500px, + api500px = new API500px(this.config.consumerKey);//dependencies + +var foo = 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 + '~r500px':function(){ + + var random = Math.floor(Math.random() * 30); + api500px.photos.getPopular({'sort': 'created_at', 'rpp': '30'}, function(error, results) { + if (error) { + event.reply(dbot.t('error')); + } else { + // getting photo name and url from results json http://is.gd/hALYmR + var name=results.photos[random].name, + url=results.photos[random].image_url; + event.reply(dbot.t('result',{'name':name,'url'=url})); + } + }); + + } + + }; + + 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 foo(dbot); //name of module +}; diff --git a/modules/500px/README.md b/modules/500px/README.md new file mode 100644 index 0000000..5e9e6fc --- /dev/null +++ b/modules/500px/README.md @@ -0,0 +1,34 @@ +## 500px + +Adds various 500px functionality. + +### Description + +This module provides a command which allows users to search for a random popular 500px photo. + +### Dependencies + +It has following dependencies: ++ [node-500px](https://github.com/ro-ka/node-500px) + +### config.json + +ignorable and consumerKey has to be configurated. It can be obtained at http://developers.500px.com +``` +{ + "ignorable": true, + "consumerKey": "CONSUMERKEY_HERE" +} +``` + +### Commands + + +#### ~r500px +Responds with a random popular 500px photo. +Example: ++ ~r500px + +### TODO + +Photo by user etc. \ No newline at end of file diff --git a/modules/500px/config.json b/modules/500px/config.json new file mode 100644 index 0000000..17552f2 --- /dev/null +++ b/modules/500px/config.json @@ -0,0 +1,4 @@ +{ + "ignorable": true, + "consumerKey": "CONSUMERKEY_HERE" +} \ No newline at end of file diff --git a/modules/500px/strings.json b/modules/500px/strings.json new file mode 100644 index 0000000..b0a684d --- /dev/null +++ b/modules/500px/strings.json @@ -0,0 +1,8 @@ +{ + "result":{ + "en": "{name} - {url}" + }, + "error": { + "en": "Something went wrong :( Example:'~r500px'" + } +} diff --git a/modules/500px/usage.json b/modules/500px/usage.json new file mode 100644 index 0000000..b8fccfb --- /dev/null +++ b/modules/500px/usage.json @@ -0,0 +1,3 @@ +{ + "~r500px": "~r500px" +} \ No newline at end of file