summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-06-23 01:35:43 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-06-23 01:35:43 +0200
commit5b255f53971ebbd542ec762940c850b0a4438b55 (patch)
tree002a00bb97f29f6078d3d6e63c9f78e0f427fd13 /lib/rbot
parent847a977b228b35f5ab281a31dd3724a4db887dff (diff)
+ strip all colours and formatting when sending to a +c or +C channel
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb6
-rw-r--r--lib/rbot/message.rb1
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 3cd0cae8..932cc3b7 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index fddbef5f..abe53ce0 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -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