From 5aeeb770657e1e6136f74c27e31a9039e0ad2657 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 15 Feb 2015 18:26:25 +0000 Subject: [PATCH] geoip --- modules/dns/dns.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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;