X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fgeoip.rb;h=615511728df524469571276977a16965ac1579f7;hb=7324b329dee26fd429033f85c1ec06e799b07994;hp=7b03e7e52bd0d77ffe2fa6bc4b8dc984f25f51e9;hpb=9340ab24696230a7f5debecf272b44ad91886b9c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb index 7b03e7e5..61551172 100755 --- a/data/rbot/plugins/geoip.rb +++ b/data/rbot/plugins/geoip.rb @@ -9,7 +9,7 @@ # # Resolves the geographic locations of users (network-wide) and IP addresses -module GeoIP +module ::GeoIP class InvalidHostError < RuntimeError; end GEO_IP_PRIMARY = "http://lakka.kapsi.fi:40086/lookup.yaml?host=" @@ -19,7 +19,9 @@ module GeoIP REGEX = { :country => %r{Country:.*? (.*?)}m, :region => %r{Region:.*?(.*?)}m, - :city => %r{City:.*?(.*?)}m + :city => %r{City:.*?(.*?)}m, + :lat => %r{Latitude:.*?(.*?)}m, + :lon => %r{Longitude:.*?(.*?)}m } def self.valid_host?(hostname) @@ -82,12 +84,13 @@ class GeoIpPlugin < Plugin # need to see if the whois reply was invoked by this plugin return unless @stack.has_nick?(nick) + if m.target + msg = host2output(m.target.host, m.target.nick) + else + msg = "no such user on "+@bot.server.hostname.split(".")[-2] + end @stack[nick].each do |source| - if m.target - @bot.say source, host2output(m.target.host, m.target.nick) - else - @bot.say source, "no such user on "+@bot.server.hostname.split(".")[-2] - end + @bot.say source, msg end @stack.clear(nick) @@ -157,4 +160,4 @@ class GeoIpPlugin < Plugin end plugin = GeoIpPlugin.new -plugin.map "geoip [:input]", :action => 'geoip' \ No newline at end of file +plugin.map "geoip [:input]", :action => 'geoip', :thread => true