]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
+ strip all colours and formatting when sending to a +c or +C channel
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 22 Jun 2008 23:35:43 +0000 (01:35 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 22 Jun 2008 23:35:43 +0000 (01:35 +0200)
lib/rbot/ircbot.rb
lib/rbot/message.rb

index 3cd0cae844d2584a5d8647edba4e309937993fac..932cc3b7322fb8ac73ebdcdcb61b581f15bd2c87 100644 (file)
@@ -914,6 +914,12 @@ class Bot
     end
 
     multi_line = original_message.to_s.gsub(/[\r\n]+/, "\n")
+
+    # if target is a channel with +c or +C modes, strip colours
+    if where.kind_of?(Channel) and where.mode.any?('c', 'C')
+      multi_line.replace(BasicUserMessage.stripcolour(multi_line).gsub(AttributeRx,''))
+    end
+
     messages = Array.new
     case opts[:newlines]
     when :join
index fddbef5f1173ab2c499263cb2cc8746fb349f632..abe53ce013245ebf217225ca848ff482c03887c9 100644 (file)
@@ -33,6 +33,7 @@ module Irc
   Reverse = "\026"
   Italic = "\011"
   NormalText = "\017"
+  AttributeRx = /#{Bold}|#{Underline}|#{Reverse}|#{Italic}|#{NormalText}/
 
   # Color is prefixed by \003 and followed by optional
   # foreground and background specifications, two-digits-max