+ 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
+ # +opts[:args]+ as a parameter. +opts[:above]+ and +opts[:below]+
+ # are used for a threshold of botmodule priorities that will be called.
+ # If :above is defined, only botmodules with a priority above the value
+ # will be called, for example. botmodules are called in order of
+ # priority from lowest to hightest.
+ def delegate_event(method, o={})
+ # if the priorities order of the delegate list is dirty,
+ # meaning some modules have been added or priorities have been
+ # changed, then the delegate list will need to be sorted before
+ # delegation. This should always be true for the first delegation.
+ sort_modules unless @sorted_modules
+
+ # set defaults
+ opts = {:args => []}.merge(o)
+
+ above = opts[:above]
+ below = opts[:below]
+ args = opts[:args]
+