diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-12-10 21:46:40 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-12-10 21:46:40 +0100 |
commit | 9586b15bfd4f0b616dcc3994262029c9b4f9a6b6 (patch) | |
tree | 03c1f81c5b9879ace0288703b427c084950151d1 /data | |
parent | 4daa83b9ebf896da5bb24bd7b7ff1866dcf98cb2 (diff) |
geoip: blogama is dead, long live ipinfodb
Sadly, the new ipinfodb API requires an API key, and I don't know yet if
I'm allowed to redistributed it (I'm betting on no, but in case I can
it will added with an appropriate patch).
Diffstat (limited to 'data')
-rwxr-xr-x | data/rbot/plugins/geoip.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb index 99ed71eb..c67f1095 100755 --- a/data/rbot/plugins/geoip.rb +++ b/data/rbot/plugins/geoip.rb @@ -44,11 +44,16 @@ module ::GeoIP return YAML::load(yaml) end - def self.blogama(ip) - url = "http://ipinfodb.com/ip_query.php?ip=" - debug "Requesting #{url+ip}" + IPINFODB_URL = "http://api.ipinfodb.com/v2/ip_query.php?key=%{key}&ip=%{ip}" - xml = Irc::Utils.bot.httputil.get(url+ip) + def self.ipinfodb(ip) + url = IPINFODB_URL % { + :ip => ip, + :key => Irc::Utils.bot.config['geoip.ipinfodb_key'] + } + debug "Requesting #{url}" + + xml = Irc::Utils.bot.httputil.get(url) if xml obj = REXML::Document.new(xml) @@ -75,7 +80,7 @@ module ::GeoIP end jump_table = { - "blogama" => Proc.new { |ip| blogama(ip) }, + "ipinfodb" => Proc.new { |ip| ipinfodb(ip) }, "kapsi" => Proc.new { |ip| kapsi(ip) }, "geoiptool" => Proc.new { |ip| geoiptool(ip) }, } @@ -107,8 +112,11 @@ end class GeoIpPlugin < Plugin Config.register Config::ArrayValue.new('geoip.sources', - :default => [ "blogama", "kapsi", "geoiptool" ], - :desc => "Which API to use for lookups. Supported values: blogama, kapsi, geoiptool") + :default => [ "ipinfodb", "kapsi", "geoiptool" ], + :desc => "Which API to use for lookups. Supported values: ipinfodb, kapsi, geoiptool") + Config.register Config::StringValue.new('geoip.ipinfodb_key', + :default => "", + :desc => "API key for the IPinfoDB geolocation service") def help(plugin, topic="") "geoip [<user|hostname|ip>] => returns the geographic location of whichever has been given -- note: user can be anyone on the network" |