]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/url.rb
translator.rb: improved help message from translators
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / url.rb
index 7a752ec6c19b6e2ede3f55a29457d2089d0b975a..9cd73736c06166b13eb838729d59cb3f22cfd3ad 100644 (file)
@@ -83,13 +83,13 @@ class UrlPlugin < Plugin
         extra << "#{Bold}type#{Bold}: #{resp['content-type']}" unless title
         if enc = resp['content-encoding']
           logopts[:extra] << ", encoding: #{enc}"
-          extra << "#{Bold}encoding#{Bold}: #{enc}"
+          extra << "#{Bold}encoding#{Bold}: #{enc}" if @bot.config['url.first_par'] or not title
         end
 
         size = resp['content-length'].first.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2') rescue nil
         if size
           logopts[:extra] << ", size: #{size} bytes"
-          extra << "#{Bold}size#{Bold}: #{size} bytes"
+          extra << "#{Bold}size#{Bold}: #{size} bytes" if @bot.config['url.first_par'] or not title
         end
       end
     rescue Exception => e
@@ -120,19 +120,21 @@ class UrlPlugin < Plugin
       next unless urlstr =~ /^https?:/
       title = nil
       debug "Getting title for #{urlstr}..."
+      reply = nil
       begin
         title = get_title_for_url(urlstr,
                                   :nick => m.source.nick,
                                   :channel => m.channel,
                                   :ircline => m.message)
         debug "Title #{title ? '' : 'not '} found"
+        reply = "#{LINK_INFO} #{title}" if title
       rescue => e
-        m.reply "Error #{e.message}"
+        reply = "Error #{e.message}"
       end
 
       if display_info > urls_displayed
-        if title
-          m.reply("#{LINK_INFO} #{title}", :overlong => :truncate)
+        if reply
+          m.reply(reply, :overlong => :truncate)
           urls_displayed += 1
         end
       end
@@ -163,7 +165,8 @@ class UrlPlugin < Plugin
     return if m.address?
 
     escaped = URI.escape(m.message, OUR_UNSAFE)
-    urls = URI.extract(escaped)
+    urls = URI.extract(escaped, ['http', 'https'])
+    return if urls.empty?
     Thread.new { handle_urls(m, urls) }
   end