Wubot::Reactor - runs reactive rules on a message
Wubot::Reactor is the 'reactive' part of the wubot project. Given a message that was generated by a monitor, the reactor walks through a rule tree, and executes any rules whose conditions evaluate to true for the message.
- react( $message, $rules, $depth )
Given a rule tree, check the condition at the root of the tree against the message. If no condition is set in the rule, or if there is a condition that evaluates as true, the plugin and/or rules defined on the rule will be evaluated.
This method is recursive. When a rule fires, if that rule contains a child 'rules' section, then the react() method will be called to process the child rules, and the 'depth' will be incremented.
If the rule fires, and the 'last_rule' param is set on the rule, then the 'last_rule' field will be set on the message to prevent any further rules from being processed.
For more information, see Wubot::Guide::Rules.
- condition( $condition, $message )
Process conditions defined on a rule.
For more information, see Wubot::Guide::Conditions.
- initialize_plugin( $plugin )
Given the name of a reactor plugin, load the plugin's class and create an instance of the plugin.
- run_plugin( $rulename, $message, $plugin, $config )
Given a rule name, a message, the plugin class configured on the rule, and any plugin configuration defined in the rule, call the 'react' method on the plugin and return the results.
- find_plugins( $rules )
Recurse through the rule tree to find a list of all unique plugin classes that are referenced. This makes it possible to initialize each plugin without having to wait for a rule that references the plugin to fire.
This was created for reactor plugins that contain a 'monitor' method that should be run at regular intervals. Without initializing the reactor class on startup, the 'monitor' method would not get called until a message came through that caused the a rule referencing the plugin to fire.
Calls the monitor() method on every reactor plugin referenced in the rule tree that has a 'monitor' method.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 58:
=over without closing =back