diff options
Diffstat (limited to 'lib/rbot/message.rb')
-rw-r--r-- | lib/rbot/message.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index ef2e14fe..8fc96490 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -159,7 +159,11 @@ module Irc ret << ' plainmessage=' << plainmessage.inspect ret << fields if fields ret << ' (identified)' if identified? - ret << ' (addressed to me)' if address? + if address? + ret << ' (addressed to me' + ret << ', with prefix' if prefixed? + ret << ')' + end ret << ' (replied)' if replied? ret << ' (ignored)' if ignored? ret << ' (in thread)' if in_thread? @@ -179,6 +183,7 @@ module Irc @bot = bot @source = source @address = false + @prefixed = false @target = target @message = message || "" @replied = false @@ -237,6 +242,12 @@ module Irc return @address end + # returns true if the messaged was addressed to the bot via the address + # prefix. This can be used to tell appart "!do this" from "botname, do this" + def prefixed? + return @prefixed + end + # strip mIRC colour escapes from a string def BasicUserMessage.stripcolour(string) return "" unless string @@ -342,6 +353,7 @@ module Irc bot.config['core.address_prefix'].each {|mprefix| if @message.gsub!(/^#{Regexp.escape(mprefix)}\s*/, "") @address = true + @prefixed = true break end } |