mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 19:52:36 +01:00
further development was precipitated
This commit is contained in:
parent
e1a8360b27
commit
0e9827a2fc
@ -9,11 +9,20 @@ var rain = function(dbot) {
|
|||||||
var commands = {
|
var commands = {
|
||||||
'~rain': function(event) {
|
'~rain': function(event) {
|
||||||
var apikey = dbot.config.rain.apikey;
|
var apikey = dbot.config.rain.apikey;
|
||||||
var precip = event.params[1];
|
var place = "Aberystwyth"; // you probably need to change the formulae if you change location
|
||||||
var score = 2 * Math.pow(precip,0.5);
|
var url = "http://api.wunderground.com/api/" + apikey + "/conditions/q/CA/" + place + ".json";
|
||||||
score = Math.ceil(score);
|
request(url, function(error, response, body) {
|
||||||
if (score > 10) { score = 11; }
|
if(response.statusCode == "200") {
|
||||||
event.reply(dbot.t("rain-"+score));
|
var data = JSON.parse(body);
|
||||||
|
var precip = data["precip_1hr_metric"];
|
||||||
|
var score = 2 * Math.pow(precip,0.5);
|
||||||
|
score = Math.ceil(score);
|
||||||
|
if (score > 10) { score = 11; }
|
||||||
|
} else {
|
||||||
|
var score = "e";
|
||||||
|
}
|
||||||
|
event.reply(dbot.t("rain-"+score+"[ " + score + " ]"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,5 +34,8 @@
|
|||||||
},
|
},
|
||||||
"rain-11": {
|
"rain-11": {
|
||||||
"english" : "LOL U PROBABLY DIED"
|
"english" : "LOL U PROBABLY DIED"
|
||||||
|
},
|
||||||
|
"rain-e": {
|
||||||
|
"english" : "Unable to fetch weather data."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user