From 2d0765c18a7304aa6e113275411f1cff957ed8d9 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 12 Apr 2008 22:07:10 +0200 Subject: 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. --- lib/rbot/plugins.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'lib/rbot') 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 -- cgit v1.2.3