1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 16:45:40 -04:00
perlbuut/plugins/geoip.pm
2010-03-12 04:00:02 -05:00

20 lines
458 B
Perl

use Geo::IP;
no warnings 'void';
sub {
my( $said, $pm ) = @_;
my $gi = Geo::IP->open("/home/simcop2387/geoip/GeoLiteCity.dat", GEOIP_STANDARD);
print "Record for $said->{body}: ";
if( $said->{body} =~ /[a-zA-Z]/ ) {
print $gi->country_code_by_name( $said->{body} );
}
else {
print $gi->country_code_by_addr( $said->{body} );
}
};
__DATA__
geoip 192.168.32.45 or geoip example.com; returns the country associated with the resolved IP address.