X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fshortenurls.rb;h=3aee6f4dcc69ccaabdcc2bbbdd5ac560719cd524;hb=16336b4a240a4265d1f2df1e30d7b68d3a924287;hp=120d40d089f7f0e99463ab66732f74b7e779e7db;hpb=3a71d6fa59b62a0660dbc377c0b71181ba2e4b98;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/shortenurls.rb b/data/rbot/plugins/shortenurls.rb index 120d40d0..3aee6f4d 100644 --- a/data/rbot/plugins/shortenurls.rb +++ b/data/rbot/plugins/shortenurls.rb @@ -15,7 +15,8 @@ require "shorturl" require "uri" class ShortenURLs < Plugin - include WWW + # starting from about shorturl 0.8.4, the WWW module is not defined + include WWW rescue nil Config.register Config::ArrayValue.new('shortenurls.services_blacklist', :default => ['rubyurl', 'shorterlink'], @@ -55,7 +56,7 @@ class ShortenURLs < Plugin return nil end - service = params[:service].to_sym || m.plugin.to_sym + service = (params[:service] || m.plugin).to_sym service = :rubyurl if service == :shorturl tried = [] @@ -63,10 +64,10 @@ class ShortenURLs < Plugin begin tried << service - raise WWW::InvalidService, "#{service} blacklisted" if @blacklist.include?(service) - short = WWW::ShortURL.shorten(url, service) - raise WWW::InvalidService, "#{service} returned an empty string for #{url}" unless short and not short.empty? - rescue WWW::InvalidService + raise InvalidService, "#{service} blacklisted" if @blacklist.include?(service) + short = ShortURL.shorten(url, service) + raise InvalidService, "#{service} returned an empty string for #{url}" unless short and not short.empty? + rescue InvalidService pool = services - tried if pool.empty? m.reply "#{service} failed, and I don't know what else to try next" unless params[:called]