mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 16:09:27 +01:00
500px random popular photo
This commit is contained in:
parent
fb14f24927
commit
c6fdd3bdbc
56
modules/500px/500px.js
Normal file
56
modules/500px/500px.js
Normal file
@ -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
|
||||
};
|
34
modules/500px/README.md
Normal file
34
modules/500px/README.md
Normal file
@ -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.
|
4
modules/500px/config.json
Normal file
4
modules/500px/config.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"ignorable": true,
|
||||
"consumerKey": "CONSUMERKEY_HERE"
|
||||
}
|
8
modules/500px/strings.json
Normal file
8
modules/500px/strings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"result":{
|
||||
"en": "{name} - {url}"
|
||||
},
|
||||
"error": {
|
||||
"en": "Something went wrong :( Example:'~r500px'"
|
||||
}
|
||||
}
|
3
modules/500px/usage.json
Normal file
3
modules/500px/usage.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"~r500px": "~r500px"
|
||||
}
|
Loading…
Reference in New Issue
Block a user