delegate (Irc::Bot::Plugins::PluginManagerClass)

    # File lib/rbot/plugins.rb, line 837
        def delegate(method, *args)
          # 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

          opts = {}
          opts.merge(args.pop) if args.last.class == Hash

          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

          above = opts[:above]
          below = opts[:below]

          # debug "Delegating #{method.inspect}"
          ret = Array.new
          if method.match(DEFAULT_DELEGATE_PATTERNS)
            debug "fast-delegating #{method}"
            m = method.to_sym
            debug "no-one to delegate to" unless @delegate_list.has_key?(m)
            return [] unless @delegate_list.has_key?(m)
            @delegate_list[m].each { |p|
              begin
                prio = p.priority
                unless (above and above >= prio) or (below and below <= prio)
                  ret.push p.send(method, *args)
                end
              rescue Exception => err
                raise if err.kind_of?(SystemExit)
                error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err)
                raise if err.kind_of?(BDB::Fatal)
              end
            }
          else
            debug "slow-delegating #{method}"
            @sorted_modules.each { |p|
              if(p.respond_to? method)
                begin
                  # debug "#{p.botmodule_class} #{p.name} responds"
                  prio = p.priority
                  unless (above and above >= prio) or (below and below <= prio)
                    ret.push p.send(method, *args)
                  end
                rescue Exception => err
                  raise if err.kind_of?(SystemExit)
                  error report_error("#{p.botmodule_class} #{p.name} #{method}() failed:", err)
                  raise if err.kind_of?(BDB::Fatal)
                end
              end
            }
          end
          return ret
          # debug "Finished delegating #{method.inspect}"
        end