Skip to content

Commit

Permalink
Meaningless update to locate.rb.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistos committed May 8, 2009
1 parent 13aef2d commit f71f64a
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions locate.rb
Expand Up @@ -20,14 +20,14 @@ def initialize
@requests = 0
@agent = WWW::Mechanize.new
end

def bindWhoisResponse
$reby.bind( "raw", "-", "311", "locate_ip", "$locate" )
end
def unbindWhoisResponse
$reby.unbind( "raw", "-", "311", "locate_ip", "$locate" )
end

def locate_ip( from, keyword, text )
return if(
keyword != "311" or
Expand All @@ -39,25 +39,30 @@ def locate_ip( from, keyword, text )
unbindWhoisResponse
@requests = 0
end

ip_address = text.split()[ 3 ]

threads = []
country = ""
region = ""
city = ""
timezone = ""


begin
doc = Hpricot( open( "http://www.geobytes.com/IpLocator.htm?GetLocation&ipaddress=#{ip_address}" ) )
country = doc.at( "[@name='ro-no_bots_pls13']" )[ 'value' ]
region = doc.at( "[@name='ro-no_bots_pls15']" )[ 'value' ]
city = doc.at( "[@name='ro-no_bots_pls17']" )[ 'value' ]
timezone = doc.at( "[@name='ro-no_bots_pls9']" )[ 'value' ]
# doc = Hpricot( open( "http://www.geoip.co.uk/?IP=#{ip_address}" ) )
# data = doc.at('#mapinfo .textleft').to_enum( :traverse_text ).zip( doc.at('#mapinfo .textright' ).to_enum(:traverse_text)).map{ |a,b|
# [ a.inner_text.strip,b.inner_text.delete(':').strip ]
# }
# country = data[ 3 ][ 1 ]
# region = data[ 5 ][ 1 ]

doc = Hpricot( open( "http://www.geobytes.com/IpLocator.htm?GetLocation&ipaddress=#{ip_address}" ) )
country = doc.at( "[@name='ro-no_bots_pls13']" )[ 'value' ]
region = doc.at( "[@name='ro-no_bots_pls15']" )[ 'value' ]
city = doc.at( "[@name='ro-no_bots_pls17']" )[ 'value' ]
rescue Exception => e
$reby.log e.message
$reby.log e.message
end

if not city.empty?
put "I estimate that #{@ip_nick} is somewhere near #{city}, #{region}, #{country}.", @ip_channel
t = time_in( city, region, country )
Expand All @@ -70,11 +75,11 @@ def locate_ip( from, keyword, text )
put "Unable to !locate #{@ip_nick}.", @ip_channel
end
end

def put( message, destination = ( @channel || 'Pistos' ) )
$reby.putserv "PRIVMSG #{destination} :#{message}"
end

def locate( nick, userhost, handle, channel, args )
@ip_nick = args.split()[ 0 ]
@ip_channel = channel
Expand All @@ -83,7 +88,7 @@ def locate( nick, userhost, handle, channel, args )
bindWhoisResponse
$reby.putserv "WHOIS #{@ip_nick}"
end

def time_in( city, region, country )
@time_place = nil
place = CGI.escape( "#{city}, #{region}, #{country}" )
Expand Down

0 comments on commit f71f64a

Please sign in to comment.