diff --git a/modules/dns/dns.js b/modules/dns/dns.js index fbc38cb..5ca97c6 100644 --- a/modules/dns/dns.js +++ b/modules/dns/dns.js @@ -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;