X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fgeoip.rb;fp=data%2Frbot%2Fplugins%2Fgeoip.rb;h=99ed71eb15b4617d6a865cb3fd93d50b54539d17;hb=41d45296886b4814744fc2d1422838d643399a61;hp=3b7bf75169a4d7e7de883abd5da6bd15a839008f;hpb=ac4c4b7f6b93fe0d33148a6630fad55812acf11b;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/geoip.rb b/data/rbot/plugins/geoip.rb index 3b7bf751..99ed71eb 100755 --- a/data/rbot/plugins/geoip.rb +++ b/data/rbot/plugins/geoip.rb @@ -183,32 +183,30 @@ class GeoIpPlugin < Plugin } rescue GeoIP::InvalidHostError, RuntimeError if nick - return _("#{nick}'s location could not be resolved") + return _("%{nick}'s location could not be resolved") % { :nick => nick } else - return _("#{host} could not be resolved") + return _("%{host} could not be resolved") % { :host => host } end rescue GeoIP::BadAPIError return _("The owner configured me to use an API that doesn't exist, bug them!") end - res = _("%{thing} is #{nick ? "from" : "located in"}") % { - :thing => (nick ? nick : Resolv::getaddress(host)), - :country => geo[:country] - } - - res << " %{city}" % { - :city => geo[:city] - } unless geo[:city].to_s.empty? + location = [] + location << geo[:city] unless geo[:city].nil_or_empty? + location << geo[:region] unless geo[:region].nil_or_empty? or geo[:region] == geo[:city] + location << geo[:country] unless geo[:country].nil_or_empty? - res << " %{region}," % { - :region => geo[:region] - } unless geo[:region].to_s.empty? || geo[:region] == geo[:city] + if nick + res = _("%{nick} is from %{location}") + else + res = _("%{host} is located in %{location}") + end - res << " %{country}" % { - :country => geo[:country] + return res % { + :nick => nick, + :host => host, + :location => location.join(', ') } - - return res end end