X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fshortenurls.rb;h=782a4e2723e816671c35b655aec7d03debde6296;hb=7b792bea7a644309623d67b5d49528ae13da3e7b;hp=7eeb005f8fce8705569e695e04a1f467d24217d6;hpb=3a0e00e10d1e4cfdbd035baf1d483d072d73a986;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/shortenurls.rb b/data/rbot/plugins/shortenurls.rb index 7eeb005f..782a4e27 100644 --- a/data/rbot/plugins/shortenurls.rb +++ b/data/rbot/plugins/shortenurls.rb @@ -15,13 +15,17 @@ require "shorturl" require "uri" class ShortenURLs < Plugin - # starting from about shorturl 0.8.4, the WWW module is not defined + # 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'], :requires_rescan => true, :desc => "List of nonfunctioning shorturl services") + Config.register Config::StringValue.new('shortenurls.favorite_service', + :default => 'tinyurl', + :desc => "Default shortening service. Probably only applies when other plugins " + + "use this one for shortening") attr_accessor :services def initialize @@ -56,7 +60,14 @@ class ShortenURLs < Plugin return nil end - service = (params[:service] || m.plugin).to_sym + if params.has_key? :service + service = params[:service] + elsif m != nil and m.plugin != nil + service = m.plugin + else + service = @bot.config['shortenurls.favorite_service'] + end + service = service.to_sym service = :rubyurl if service == :shorturl tried = []