forked from GitHub/dbot
Merge branch 'master' of github.com:reality/depressionbot
This commit is contained in:
commit
87387878a7
@ -295,6 +295,7 @@ var commands = function(dbot) {
|
||||
commands['reload'].access = 'admin';
|
||||
commands['unload'].access = 'admin';
|
||||
commands['load'].access = 'admin';
|
||||
commands['version'].access = 'admin';
|
||||
commands['setconfig'].access = 'admin';
|
||||
commands['showconfig'].access = 'moderator';
|
||||
commands['join'].access = 'moderator';
|
||||
|
@ -9,12 +9,12 @@ var dent = function(dbot) {
|
||||
var username = dbot.config.dent.username,
|
||||
password = dbot.config.dent.password,
|
||||
info,
|
||||
auth = "Basic " +
|
||||
auth = "Basic " +
|
||||
new Buffer(username + ":" + password).toString("base64");
|
||||
|
||||
request.post({
|
||||
'url': 'http://identi.ca/api/statuses/update.json?status=' +
|
||||
content,
|
||||
escape(content),
|
||||
'headers': {
|
||||
'Authorization': auth
|
||||
}
|
||||
@ -36,7 +36,7 @@ var dent = function(dbot) {
|
||||
this.onLoad = function() {
|
||||
if(dbot.config.dent.dentQuotes === true && _.has(dbot.modules, 'quotes')) {
|
||||
dbot.api.command.addHook('~qadd', function(key, text) {
|
||||
this.api.post(key + ': ' + text);
|
||||
this.api.post(key + ': ' + text);
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this);
|
||||
|
16
modules/rain/README.md
Normal file
16
modules/rain/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
## Rain
|
||||
|
||||
Quietly judges your choice of climate.
|
||||
|
||||
### Description
|
||||
|
||||
It's a well documented fact that looking out of the window is sometimes far too much effort. However, sometimes you just need toknow how wet it is outside: this module queries for the precipitation level, and tells you when you need a raincoat.
|
||||
|
||||
### Configuration
|
||||
#### apikey
|
||||
This module requires a Wunderground API key. You can register for one, for free, at http://www.wunderground.com/weather/api/
|
||||
|
||||
### Commands
|
||||
|
||||
#### ~rain
|
||||
Polls the rainfall in the last hour, and returns an appropriate string.
|
6
modules/rain/config.json
Normal file
6
modules/rain/config.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": [ "command" ],
|
||||
"ignorable": true,
|
||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/rain/README.md",
|
||||
"apikey": "7707e78c7125741e"
|
||||
}
|
43
modules/rain/rain.js
Normal file
43
modules/rain/rain.js
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Module Name: Rain
|
||||
* Description: Quietly judges your choice of climate.
|
||||
*/
|
||||
var request = require('request'),
|
||||
_ = require('underscore')._;
|
||||
|
||||
var rain = function(dbot) {
|
||||
var commands = {
|
||||
'~rain': function(event) {
|
||||
var apikey = dbot.config.rain.apikey;
|
||||
var place = event.input[1];
|
||||
if (!place) { var place = "Aberystwyth"; }
|
||||
var url = "http://api.wunderground.com/api/" + apikey + "/conditions/q/" + place + ".json";
|
||||
request(url, function(error, response, body) {
|
||||
if(response.statusCode == "200") {
|
||||
var data = JSON.parse(body);
|
||||
var obs = data["current_observation"];
|
||||
if (obs) {
|
||||
var precip = obs["precip_1hr_metric"];
|
||||
var score = 2 * Math.pow(precip,0.5);
|
||||
score = Math.ceil(score);
|
||||
if (score > 10) { score = 11; }
|
||||
} else {
|
||||
var score = "u";
|
||||
}
|
||||
} else {
|
||||
var score = "e";
|
||||
}
|
||||
event.reply(dbot.t("rain-"+score,{"place": place}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
commands['~rain'].regex = [/~rain (.+)/, 2];
|
||||
this.commands = commands;
|
||||
this.on = 'PRIVMSG';
|
||||
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new rain(dbot);
|
||||
};
|
44
modules/rain/strings.json
Normal file
44
modules/rain/strings.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"rain-0": {
|
||||
"english" : "It's not raining in {place}."
|
||||
},
|
||||
"rain-1": {
|
||||
"english" : "It's raining in {place}."
|
||||
},
|
||||
"rain-2": {
|
||||
"english" : "It's raining rather a lot in {place}."
|
||||
},
|
||||
"rain-3": {
|
||||
"english" : "It's raining shitloads."
|
||||
},
|
||||
"rain-4": {
|
||||
"english" : "It's raining fucktons."
|
||||
},
|
||||
"rain-5": {
|
||||
"english" : "It's raining whales (in {place})!"
|
||||
},
|
||||
"rain-6": {
|
||||
"english" : "IT'S SO FUCKING WET OUT HERE MAN"
|
||||
},
|
||||
"rain-7": {
|
||||
"english" : "I AM SO MOIST RIGHT NOW"
|
||||
},
|
||||
"rain-8": {
|
||||
"english" : "You used a #3 pencil instead of #2, didn't you?"
|
||||
},
|
||||
"rain-9": {
|
||||
"english" : "WELCOME TO ATLANTIS"
|
||||
},
|
||||
"rain-10": {
|
||||
"english" : "GET INSIDE"
|
||||
},
|
||||
"rain-11": {
|
||||
"english" : "LOL U PROBABLY DIED"
|
||||
},
|
||||
"rain-e": {
|
||||
"english" : "Unable to fetch weather data."
|
||||
},
|
||||
"rain-u": {
|
||||
"english": "Location too ambigious to process."
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user