From: Giuseppe Bilotta Date: Sun, 22 Jun 2008 23:35:43 +0000 (+0200) Subject: + strip all colours and formatting when sending to a +c or +C channel X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=5b255f53971ebbd542ec762940c850b0a4438b55;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git + strip all colours and formatting when sending to a +c or +C channel --- 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