]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/shortenurls.rb
spotify: handle errors
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / shortenurls.rb
index a7577e1b4a3ad7c783c3595faba785d6d7285919..3aee6f4dcc69ccaabdcc2bbbdd5ac560719cd524 100644 (file)
@@ -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'],
@@ -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]