]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/url.rb
weather plugin: fix 163
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / url.rb
index 0896c87ee4f7ffd03440f2bdefc3a974d47d6ea1..9cd73736c06166b13eb838729d59cb3f22cfd3ad 100644 (file)
@@ -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
@@ -164,6 +166,7 @@ class UrlPlugin < Plugin
 
     escaped = URI.escape(m.message, OUR_UNSAFE)
     urls = URI.extract(escaped, ['http', 'https'])
+    return if urls.empty?
     Thread.new { handle_urls(m, urls) }
   end