mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
geoip
This commit is contained in:
parent
e5ac647de4
commit
5aeeb77065
@ -2,7 +2,8 @@
|
||||
* Module Name: DNS
|
||||
* Description: Performs and reports on basic DNS functions.
|
||||
*/
|
||||
var dnsmod = require('dns');
|
||||
var dnsmod = require('dns'),
|
||||
request = require('request');
|
||||
|
||||
var dns = function(dbot) {
|
||||
var commands = {
|
||||
@ -26,6 +27,19 @@ var dns = function(dbot) {
|
||||
event.reply(dbot.t("rdns",{"domain": domain, "ip": ip}));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
'~geoip': function(event) {
|
||||
var ip = event.params[1];
|
||||
request.get('http://www.telize.com/geoip/'+ip, {
|
||||
'json': true
|
||||
}, function(err, response, body) {
|
||||
if(!err && body && !_.has(body, 'code')) {
|
||||
event.reply(ip + ' is located in '+ body.postal_code + ', ' + body.city + ', ' + body.country + ' and is hosted by ' + body.isp);
|
||||
} else {
|
||||
event.reply('No info about ' + ip);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
this.commands = commands;
|
||||
|
Loading…
Reference in New Issue
Block a user