summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/shortenurls.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-13 21:47:52 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-13 21:47:52 +0000
commit3a71d6fa59b62a0660dbc377c0b71181ba2e4b98 (patch)
treef4f7d9998d4bd42a406bcea445fcd5d0a1fcccc2 /data/rbot/plugins/shortenurls.rb
parent1002684a7491dd8c160f81c00c4b5a4dcb5ac260 (diff)
shortenurls plugin: shortenurls.services_blacklist config variable
Diffstat (limited to 'data/rbot/plugins/shortenurls.rb')
-rw-r--r--data/rbot/plugins/shortenurls.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/data/rbot/plugins/shortenurls.rb b/data/rbot/plugins/shortenurls.rb
index 4cb96c35..120d40d0 100644
--- a/data/rbot/plugins/shortenurls.rb
+++ b/data/rbot/plugins/shortenurls.rb
@@ -17,11 +17,20 @@ require "uri"
class ShortenURLs < Plugin
include WWW
+ Config.register Config::ArrayValue.new('shortenurls.services_blacklist',
+ :default => ['rubyurl', 'shorterlink'],
+ :requires_rescan => true,
+ :desc => "List of nonfunctioning shorturl services")
+
attr_accessor :services
def initialize
super
+ @blacklist = @bot.config['shortenurls.services_blacklist'].map { |s| s.intern }
# Instead of catering for all the services, we only pick the ones with 'link' or 'url' in the name
- @services = ShortURL.valid_services.select { |service| service.to_s =~ /(?:link|url)/ } << :shorturl
+ @services = ShortURL.valid_services.select { |service| service.to_s =~ /(?:link|url)/ } - @blacklist
+ if @services.include?(:rubyurl)
+ @services << :shorturl
+ end
end
# return a help string when the bot is asked for help on this plugin
@@ -46,7 +55,7 @@ class ShortenURLs < Plugin
return nil
end
- service = params[:service] || m.plugin.to_sym
+ service = params[:service].to_sym || m.plugin.to_sym
service = :rubyurl if service == :shorturl
tried = []
@@ -54,6 +63,7 @@ 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