# 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,''))
+ multi_line.replace BasicUserMessage.strip_formatting(multi_line)
end
messages = Array.new
Color = "\003"
ColorRx = /#{Color}\d?\d?(?:,\d\d?)?/
+ FormattingRx = /#{AttributeRx}|#{ColorRx}/
+
# Standard color codes
ColorCode = {
:black => 1,
# User/Channel message was sent to
attr_reader :target
- # contents of the message
+ # contents of the message (stripped of initial/final format codes)
attr_accessor :message
# contents of the message (for logging purposes)
attr_accessor :logmessage
+ # contents of the message (stripped of all formatting)
+ attr_accessor :plainmessage
+
# has the message been replied to/handled by a plugin?
attr_accessor :replied
@source = source
@address = false
@target = target
- @message = BasicUserMessage.stripcolour message
+ @message = message || ""
@replied = false
@server = server
@ignored = false
end
end
@logmessage = @message.dup
+ @plainmessage = BasicUserMessage.strip_formatting(@message)
+ @message = BasicUserMessage.strip_initial_formatting(@message)
if target && target == @bot.myself
@address = true
ret
end
+ def BasicUserMessage.strip_initial_formatting(string)
+ return "" unless string
+ ret = string.gsub(/^#{FormattingRx}|#{FormattingRx}$/,"")
+ end
+
+ def BasicUserMessage.strip_formatting(string)
+ string.gsub(FormattingRx,"")
+ end
+
end
# class for handling welcome messages from the server