diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-24 20:08:13 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-24 20:08:13 +0000 |
commit | 8da0229d2d0a4c15286d44062002d721af6dbf63 (patch) | |
tree | bb7e48aac89b6d1d579165c43dfd032da4c21fa7 /lib | |
parent | b276236fed7673ec427b64dd57f6cb05d0784ebf (diff) |
message.rb: logmessage method to retrieve the message for logging purposes
When logging messages, it is appropriate to remove color and identification prefixes (in networks that support it), but not the address prefix.
Solve this by saving a copy of the message without the address prefix(es) removed, and use it in irclog*() methods.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/ircbot.rb | 16 | ||||
-rw-r--r-- | lib/rbot/message.rb | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 1e12ddcc..05e58de2 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -1203,15 +1203,15 @@ class Bot def irclogprivmsg(m) if(m.action?) if(m.private?) - irclog "* [#{m.source}(#{m.sourceaddress})] #{m.message}", m.source + irclog "* [#{m.source}(#{m.sourceaddress})] #{m.logmessage}", m.source else - irclog "* #{m.source} #{m.message}", m.target + irclog "* #{m.source} #{m.logmessage}", m.target end else if(m.public?) - irclog "<#{m.source}> #{m.message}", m.target + irclog "<#{m.source}> #{m.logmessage}", m.target else - irclog "[#{m.source}(#{m.sourceaddress})] #{m.message}", m.source + irclog "[#{m.source}(#{m.sourceaddress})] #{m.logmessage}", m.source end end end @@ -1248,18 +1248,18 @@ class Bot def irclogpart(m) if(m.address?) debug "left channel #{m.channel}" - irclog "@ Left channel #{m.channel} (#{m.message})", m.channel + irclog "@ Left channel #{m.channel} (#{m.logmessage})", m.channel else - irclog "@ #{m.source} left channel #{m.channel} (#{m.message})", m.channel + irclog "@ #{m.source} left channel #{m.channel} (#{m.logmessage})", m.channel end end def irclogkick(m) if(m.address?) debug "kicked from channel #{m.channel}" - irclog "@ You have been kicked from #{m.channel} by #{m.source} (#{m.message})", m.channel + irclog "@ You have been kicked from #{m.channel} by #{m.source} (#{m.logmessage})", m.channel else - irclog "@ #{m.target} has been kicked from #{m.channel} by #{m.source} (#{m.message})", m.channel + irclog "@ #{m.target} has been kicked from #{m.channel} by #{m.source} (#{m.logmessage})", m.channel end end diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index 9881503c..47994c10 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -122,6 +122,9 @@ module Irc # contents of the message attr_accessor :message + # contents of the message (for logging purposes) + attr_accessor :logmessage + # has the message been replied to/handled by a plugin? attr_accessor :replied @@ -152,6 +155,7 @@ module Irc warning "Message does not have identification" end end + @logmessage = @message.dup if target && target == @bot.myself @address = true |