|
# File rbot/message.rb, line 99
def initialize(bot, source, target, message)
super(bot, source, target, message)
@target = target
@private = false
@plugin = nil
@action = false
if target.downcase == @bot.nick.downcase
@private = true
@address = true
@channel = nil
@replyto = @sourcenick
else
@replyto = @target
@channel = @target
end
# check for option extra addressing prefixes, e.g "|search foo", or
# "!version" - first match wins
bot.addressing_prefixes.each {|mprefix|
if @message.gsub!(/^#{Regexp.escape(mprefix)}\s*/, "")
@address = true
break
end
}
# even if they used above prefixes, we allow for silly people who
# combine all possible types, e.g. "|rbot: hello", or
# "/msg rbot rbot: hello", etc
if @message.gsub!(/^\s*#{bot.nick}\s*([:;,>]|\s)\s*/, "")
@address = true
end
if(@message =~ /^\001ACTION\s(.+)\001/)
@message = $1
@action = true
end
# free splitting for plugins
@params = @message.dup
if @params.gsub!(/^\s*(\S+)[\s$]*/, "")
@plugin = $1.downcase
@params = nil unless @params.length > 0
end
end
|