Skip to content

Instantly share code, notes, and snippets.

@silentrob
Created December 22, 2014 08:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silentrob/d056f913823bdd1ff590 to your computer and use it in GitHub Desktop.
Save silentrob/d056f913823bdd1ff590 to your computer and use it in GitHub Desktop.
weather.js
var request = require("request");
exports.weather = function(cb) {
if (this.message.names) {
var location = this.message.names[0]
request.get("http://api.openweathermap.org/data/2.5/find?q="+location+"&type=like&units=metric&mode=json", function(err, res, body) {
var results = JSON.parse(body);
if (results.list.length != 0) {
cb(null, "It is " + results.list[0]['weather'][0]['description']);
} else {
cb(null, "I'm not near a window.");
}
});
} else {
cb(null, "I'm not near a window.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment