From c6fdd3bdbcad9a59346f7a60c1ed6f8ed8925c2b Mon Sep 17 00:00:00 2001 From: thoso Date: Thu, 20 Feb 2014 08:40:24 +0100 Subject: [PATCH] 500px random popular photo --- modules/500px/500px.js | 56 ++++++++++++++++++++++++++++++++++++++ modules/500px/README.md | 34 +++++++++++++++++++++++ modules/500px/config.json | 4 +++ modules/500px/strings.json | 8 ++++++ modules/500px/usage.json | 3 ++ 5 files changed, 105 insertions(+) create mode 100644 modules/500px/500px.js create mode 100644 modules/500px/README.md create mode 100644 modules/500px/config.json create mode 100644 modules/500px/strings.json create mode 100644 modules/500px/usage.json 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