diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-12 22:07:10 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-12 22:23:11 +0200 |
commit | 2d0765c18a7304aa6e113275411f1cff957ed8d9 (patch) | |
tree | 81bc9d0cecc04e87dc1032337518f1c2abf6fd43 | |
parent | e36f3f43138a0201ef0ae63db6e799564725055c (diff) |
plugins: make delegate() aware of ignored and fake messages
By convention, ignored messages will only be delegated to plugins with
negative priority, while fake messages will only be delegated to plugins
with positive priority.
-rw-r--r-- | lib/rbot/plugins.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 9dccf912..8c077bea 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -792,9 +792,27 @@ module Plugins # see if each plugin handles +method+, and if so, call it, passing # +message+ as a parameter. botmodules are called in order of priority - # from lowest to highest. +DEPRECATED+ please use delegate_event. + # from lowest to highest. + # + # If the passed +message+ is marked as +#ignored?+, it will only be + # delegated to plugins with negative priority. Conversely, if it's + # a fake message (see BotModule#fake_message), it will only be + # delegated to plugins with positive priority. + # + # For delegation with more extensive options, see delegate_event + # def delegate(method, *args) - delegate_event(method, :args => args) + opts = {:args => args} + m = args.first + if BasicUserMessage === m + # ignored messages should not be delegated + # to plugins with positive priority + opts[:below] = 0 if m.ignored? + # fake messages should not be delegated + # to plugins with negative priority + opts[:above] = 0 if m.recurse_depth > 0 + end + delegate_event(method, opts) end # see if each plugin handles +method+, and if so, call it, passing |