summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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'