+ def sort_modules
+ @sorted_modules = (core_modules + plugins).sort do |a, b|
+ a.priority <=> b.priority
+ end || []
+
+ @delegate_list.each_value do |list|
+ list.sort! {|a,b| a.priority <=> b.priority}
+ end
+ end
+
+ # call-seq: delegate</span><span class="method-args">(method, m, opts={})</span>
+ # <span class="method-name">delegate</span><span class="method-args">(method, opts={})
+ #
+ # see if each plugin handles _method_, and if so, call it, passing
+ # _m_ as a parameter (if present). BotModules are called in order of
+ # priority from lowest to highest.
+ #
+ # If the passed _m_ is a BasicUserMessage and 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.
+ #
+ # Note that _m_ can also be an exploded Array, but in this case the last
+ # element of it cannot be a Hash, or it will be interpreted as the options
+ # Hash for delegate itself. The last element can be a subclass of a Hash, though.
+ # To be on the safe side, you can add an empty Hash as last parameter for delegate
+ # when calling it with an exploded Array:
+ # @bot.plugins.delegate(method, *(args.push Hash.new))
+ #
+ # Currently supported options are the following:
+ # :above ::
+ # if specified, the delegation will only consider plugins with a priority
+ # higher than the specified value
+ # :below ::
+ # if specified, the delegation will only consider plugins with a priority
+ # lower than the specified value
+ #