X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fgeoip.rb;h=c76310d5b553fcb417a977b83dcd32e15d50b9cf;hb=052217de30c59206d7025b582d4604557a747470;hp=c67f1095bf19522fdf9d9f8a1b60463f5068f7a5;hpb=9586b15bfd4f0b616dcc3994262029c9b4f9a6b6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb index c67f1095..c76310d5 100755 --- a/data/rbot/plugins/geoip.rb +++ b/data/rbot/plugins/geoip.rb @@ -70,6 +70,12 @@ module ::GeoIP end end + JUMP_TABLE = { + "ipinfodb" => Proc.new { |ip| ipinfodb(ip) }, + "kapsi" => Proc.new { |ip| kapsi(ip) }, + "geoiptool" => Proc.new { |ip| geoiptool(ip) }, + } + def self.resolve(hostname, api) raise InvalidHostError unless valid_host?(hostname) @@ -79,15 +85,9 @@ module ::GeoIP raise InvalidHostError end - jump_table = { - "ipinfodb" => Proc.new { |ip| ipinfodb(ip) }, - "kapsi" => Proc.new { |ip| kapsi(ip) }, - "geoiptool" => Proc.new { |ip| geoiptool(ip) }, - } - - raise BadAPIError unless jump_table.key?(api) + raise BadAPIError unless JUMP_TABLE.key?(api) - return jump_table[api].call(ip) + return JUMP_TABLE[api].call(ip) end end @@ -153,7 +153,7 @@ class GeoIpPlugin < Plugin if m.replyto.class == Channel # check if there is an user on the channel with nick same as input given - user = m.replyto.users.find { |user| user.nick == params[:input] } + user = m.replyto.users.find { |usr| usr.nick == params[:input] } if user m.reply host2output(user.host, user.nick)