From bab36d5af33284b2e887898a19714d53a0d6a48c Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 11 Apr 2016 18:08:20 +0000 Subject: [PATCH] better geoip --- modules/dns/dns.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/dns/dns.js b/modules/dns/dns.js index 1145070..290b4ac 100644 --- a/modules/dns/dns.js +++ b/modules/dns/dns.js @@ -3,7 +3,8 @@ * Description: Performs and reports on basic DNS functions. */ var dnsm = require('dns'), - request = require('request'); + request = require('request'), + http = require('http'); var dns = function(dbot) { var commands = { @@ -30,16 +31,16 @@ var dns = function(dbot) { }, '~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); - } - }); + var ip = event.params[1]; + request.get('http://ipinfo.io/'+ip, { + 'json': true + }, function(err, res, body) { + if(!err && body) { + event.reply(ip + ' is located in '+ body.city + ', ' + body.country + '. Hostname: ' + body.hostname + '. ISP: ' + body.org); + } else { + event.reply('No info about ' + ip); + } + }); }, '~dnsbl': function(event) {