1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 17:55:42 -04:00
perlbuut/plugins/geoip.pm
Ryan Voots c74027840e fix a bug with help, i need to check $said->{backdressed} everywhere for errors, but i'll do that later
I've also attempted to make the substitution work on factoids, and actually save them.
i've also attempted to get geoip to work with the city database, we'll see
2010-03-12 20:15:19 -05:00

21 lines
507 B
Perl

use Geo::IP;
no warnings 'void';
sub {
my( $said, $pm ) = @_;
$Geo::IP::PP_OPEN_TYPE_PATH = "/home/simcop2387/geoip/";
my $gi = Geo::IP->open_type(GEOIP_CITY_EDITION_REV0, 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.