summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaohan Chen <yaohan.chen@gmail.com>2008-06-23 19:30:29 -0400
committerYaohan Chen <yaohan.chen@gmail.com>2008-06-24 11:31:22 -0400
commit5c832c68f93277a8a0bcfa8f30493924b938a360 (patch)
tree6d054f32151269f5b44d931d26cf600ae0498f58
parent06943ba66c9cb1426814f7be199f185605330a25 (diff)
fake messages will use the originating message's reply method
this allows shell plugin to capture replies of a command even if this command is run because of a fake message
-rw-r--r--lib/rbot/core/utils/extends.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb
index de6a7db4..59f5be76 100644
--- a/lib/rbot/core/utils/extends.rb
+++ b/lib/rbot/core/utils/extends.rb
@@ -418,6 +418,14 @@ module ::Irc
raise RecurseTooDeep if o[:depth] > MAX_RECURSE_DEPTH
new_m = o[:class].new(o[:bot], o[:server], o[:source], o[:target], string)
new_m.recurse_depth = o[:depth]
+ # if "from" message is given, the created message will reply to "from"
+ if from
+ class << new_m
+ self
+ end.send(:define_method, :reply) do |*args|
+ from.reply *args
+ end
+ end
return new_m unless o[:delegate]
method = o[:class].to_s.gsub(/^Irc::|Message$/,'').downcase
method = 'privmsg' if method == 'priv'