有没有办法检索IRC频道的纬度和经度细节,以便我可以在地图上找到相同的内容。
感谢。
答案 0 :(得分:1)
要获取频道中人员的位置,您只需查看他们的主机名 - IRC上的姓名由昵称,用户名和主机名组成,格式为昵称!username @ hostname。
主机名可以是三件事之一 - IP地址,DNS名称或“斗篷”。您可以使用DNS客户端将主机名转换为IP地址,然后使用IP地址,您可以使用IP地理定位工具(例如具有良好免费API的ipinfodb.com),并检索纬度和经度每个用户。
如果主机名是斗篷,并且其格式因网络而异,那么除非您拥有IRC网络的高级权限,否则无法获得该用户的真实IP /主机名(以及因此位置)。
答案 1 :(得分:1)
Radoslaw Zielinski(pld-linux dot org的radek)在XChat IRC客户端编写了一个用于昵称地理定位的Perl脚本:
我写了一个简单的插件来查找Maxmind GeoIP查找数据库中的IP地址,你可以在这里找到它:xchat-geo.pl。有关安装说明,请参阅“perldoc xchat-geo.pl”。
<强>用法:强>
/geo some_nickname
<强>输出:强>
[17:33] ==&gt; some_nickname |美国旧金山CA 37.7525 -122.3194 n = somenick@some.host
原创博文:www.radek.cc/2009/09/06/irc-xchat-geolocation-plugin /
需要您安装:
#!/usr/bin/perl -w
use strict;
use Geo::IP ();
our $VERSION = '0.04';
=head1 NAME
xchat-geo.pl - geolocation plugin for xchat
=head1 SYNOPSIS
perl -MCPAN -e 'install Geo::IP'
chmod +x xchat-geo.pl
mv xchat-geo.pl ~/.xchat/
# in xchat
/unload .xchat/xchat-geo.pl
/load .xchat/xchat-geo.pl
/geo some-nickname
=head1 DESCRIPTION
Usage:
/geo some_nickname
[17:33] ==> some_nickname | US San Francisco CA 37.7525 -122.3194
n=somenick@some.host
Provides a single C</geo> command, which attempts to lookup the IP address in
the maxmind GeoIP database.
Requires the Geo::IP module to be installed, along with the GeoIP City (or its
free GeoLite counterpart); see L<http://www.maxmind.com/app/ip-location> and
L<http://www.maxmind.com/app/geolitecity>.
On my machine, the installed databases look like this:
$ ls -l /usr/share/GeoIP
lrwxrwxrwx 1 root root 15 Sep 6 16:54 GeoIPCity.dat -> GeoLiteCity.dat
-rw-r--r-- 1 root root 877738 Sep 6 16:25 GeoIP.dat
-rw-r--r-- 1 root root 27711885 Sep 6 16:31 GeoLiteCity.dat
Released 2009-09-06
=head1 AUTHOR
Radoslaw Zielinski E<lt>radek@pld-linux.orgE<gt>
http://radek.cc/2009/09/06/irc-xchat-geolocation-plugin/
=head1 LICENSE
GPL v3
=cut
our $geo = Geo::IP->open_type( Geo::IP::GEOIP_CITY_EDITION_REV1 ) # Geo::IP::GEOIP_STANDARD
or die "can't load the GeoIP database";
Xchat::print('xchat geo starting');
Xchat::register( 'xchat geo', $VERSION, 'geo location for xchat', \&unload );
Xchat::hook_print( 'Join', \&Join, );
Xchat::hook_command( 'geo', sub { geo(@_); Xchat::EAT_ALL; }, );
# for debugging / plugin development
#Xchat::hook_command( 'xev', sub { eval $_[1][0]; Xchat::EAT_ALL; }, );
sub Join {
my ( $user, $channel, $host ) = @{ $_[0] };
my $r = record_from_ihost($host);
Xchat::printf( "-\x0311->\x03\t\x02%s \x0f\x0314(\x0311%s\x0314) \x03has joined %s [\x0308%s\x0f]",
$user, $host, $channel,
$r && ref $r
? join( ', ', map { defined $_ ? $_ : '' } $r->country_code, $r->city, $r->region, $r->postal_code, )
: '' );
return Xchat::EAT_XCHAT;
}
# /geo some_nickname
sub geo {
my ($cmd) = @_;
defined $cmd->[1] && length $cmd->[1]
or return Xchat::print('nick?');
my $user = Xchat::user_info( $cmd->[1] )
or return Xchat::print("no such nick $cmd->[1]");
my $r = record_from_ihost( $user->{host} )
or return;
return ref $r
? Xchat::print(
' ==> ' . join "\t", $user->{nick}, $r->country_code, $r->city, $r->region,
$r->latitude, $r->longitude, $r->postal_code, $user->{host}
)
: Xchat::print($r);
}
# input: nick and hostname, as reported by xchat
# - n=user@hostname
# - n=user@IP.address
# - n=user@some/freenode/cloak (useless)
# output: a string with error message or a Geo::IP record
sub record_from_ihost {
my $ihost = shift
or return;
( my $nick = $ihost ) =~ s/^.=|\@.*//g;
$ihost =~ /^ [^@]* \@ (?: ((?:\d{1,3}\.){3}\.\d{1,3}) | ([a-zA-Z\d_-]+\.[.a-zA-Z\d_-]+) ) (?: \s.* )? $/x
or return "no useful host for <$nick> -- $ihost";
my $r = ( $1 ? $geo->record_by_ip($1) : $geo->record_by_name($2) )
or return "no useful geo info for <$nick> -- $ihost " . ( $1 ? "1: $1" : "2: $2" );
return $r;
}
sub unload {
undef $geo;
Xchat::print('xchat geo exiting');
}
# vim: ts=4 sw=4 noet