This commit is contained in:
reality 2016-04-11 18:15:10 +00:00
parent bab36d5af3
commit a5657a5a36

View File

@ -7,6 +7,10 @@ var dnsm = require('dns'),
http = require('http'); http = require('http');
var dns = function(dbot) { var dns = function(dbot) {
if(!_.has(dbot.db, 'ip')) {
dbot.db.ip = {};
}
var ips = dbot.db.ip;
var commands = { var commands = {
'~lookup': function(event) { '~lookup': function(event) {
domain = event.params[1]; domain = event.params[1];
@ -32,15 +36,21 @@ var dns = function(dbot) {
'~geoip': function(event) { '~geoip': function(event) {
var ip = event.params[1]; var ip = event.params[1];
request.get('http://ipinfo.io/'+ip, { if(_.has(ips, ip)) {
'json': true body = ips[ip];
}, function(err, res, body) { event.reply(ip + ' is located in '+ body.city + ', ' + body.country + '. Hostname: ' + body.hostname + '. ISP: ' + body.org);
if(!err && body) { } else {
event.reply(ip + ' is located in '+ body.city + ', ' + body.country + '. Hostname: ' + body.hostname + '. ISP: ' + body.org); request.get('http://ipinfo.io/'+ip, {
} else { 'json': true
event.reply('No info about ' + ip); }, 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);
}
ips[ip] = body;
});
}
}, },
'~dnsbl': function(event) { '~dnsbl': function(event) {