Bot::Backbone::Dispatcher - Simple dispatching tool
my $dispatcher = Bot::Backbone::Dispatcher->new( predicates => \@predicates, also_predicates => \@also_predicates, ); my $message = Bot::Backbone::Message->new(...); $dispatcher->dispatch_message($message);
A dispatcher is an array of predicates that are each executed in turn. Each predicate is a subroutine that is run against the message that may or may not take an action against it and is expected to return a boolean value declaring whether any action was taken.
Predicates in this list are executed sequentially and in order. The first predicate to return a true value causes execution to cease so that any further predicates are ignored.
This list of predicates are not guaranteed to execute sequentially or in any particular order. The return value of these predicates will be ignored and all will be executed on every message, even those that have already been handled by a predicate in the "predicates" list.
Chances are that you probably don't need this method. However, if you are creating a new kind of predicate, you will probably want this method.
This will do the right thing to either add a root level predicate to the dispatcher or return the predicate for chaining within another predicate. You probably want to read the code in Bot::Backbone::DispatchSugar for examples.
Andrew Sterling Hanenkamp <firstname.lastname@example.org>
This software is copyright (c) 2011 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.