]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/url.rb
lastfm: allow bolding in translations in nowplaying
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / url.rb
index 8d12f303f62cc8c3792fcffcf81879cd972e8544..4ff27fab834b2c97fd5c49605986ae0a7331e977 100644 (file)
@@ -31,6 +31,9 @@ class UrlPlugin < Plugin
   Config.register Config::ArrayValue.new('url.only_on_channels',
     :desc => "Show link info only on these channels",
     :default => [])
+  Config.register Config::ArrayValue.new('url.ignore',
+    :desc => "Don't show link info for urls from users represented as hostmasks on this list. Useful for ignoring other bots, for example.",
+    :default => [])
 
   def initialize
     super
@@ -71,7 +74,7 @@ class UrlPlugin < Plugin
     checks.flatten!
 
     unless checks.grep(@no_info_hosts).empty?
-      return "Sorry, info retrieval for #{url.host} (#{checks.first}) is disabled"
+      return ( opts[:always_reply] ? "Sorry, info retrieval for #{url.host} (#{checks.first}) is disabled" : false )
     end
 
     logopts = opts.dup
@@ -125,15 +128,20 @@ class UrlPlugin < Plugin
   def handle_urls(m, params={})
     opts = {
       :display_info => @bot.config['url.display_link_info'],
-      :channels => @bot.config['url.only_on_channels']
+      :channels => @bot.config['url.only_on_channels'],
+      :ignore => @bot.config['url.ignore']
     }.merge params
     urls = opts[:urls]
     display_info= opts[:display_info]
     channels = opts[:channels]
+    ignore = opts[:ignore]
+
     unless channels.empty?
       return unless channels.map { |c| c.downcase }.include?(m.channel.downcase)
     end
 
+    ignore.each { |u| return if m.source.matches?(u) }
+
     return if urls.empty?
     debug "found urls #{urls.inspect}"
     list = m.public? ? @registry[m.target] : nil
@@ -147,6 +155,7 @@ class UrlPlugin < Plugin
       reply = nil
       begin
         title = get_title_for_url(urlstr,
+                                  :always_reply => m.address?,
                                   :nick => m.source.nick,
                                   :channel => m.channel,
                                   :ircline => m.message)