Last active
December 17, 2015 04:08
-
-
Save mikesea/5548051 to your computer and use it in GitHub Desktop.
determine user's location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on :message, /where\s?is (.+)/ do |m| | |
nick = m.params[-1][/where\s?is (.+)/, 1] | |
if nick == @bot.nick | |
m.reply "#{@bot.nick} is both everywhere and nowhere." | |
return | |
end | |
user = @bot.user_list.find(nick) | |
if user | |
Thread.new do | |
m.reply "One moment, looking up #{user.nick}'s current location" | |
ip = user.host[/(\d+\.\d+\.\d+\.\d+)/, 1] | |
location = Geocoder.search(ip).first | |
m.reply "#{user.nick} is somewhere near #{location.city}, #{location.state}." | |
end | |
else | |
m.reply "Couldn't find user with the nick: #{nick}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment