From 5b255f53971ebbd542ec762940c850b0a4438b55 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 23 Jun 2008 01:35:43 +0200 Subject: + strip all colours and formatting when sending to a +c or +C channel --- lib/rbot/ircbot.rb | 6 ++++++ lib/rbot/message.rb | 1 + 2 files changed, 7 insertions(+) (limited to 'lib/rbot') 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 -- cgit v1.2.3