]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/url.rb
weather plugin: refactor HTML cleanup code
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / url.rb
index 524b0858aaab183e9d0b440e87fea03c03f1ac6f..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