- Using the @default_config attribute in a module will fill out a default
value.
- cfg[:timeout] sets the timeout for the task for this module to finish.
- Update Omnibot.Irc.route_msg/2 to have each task spawn a second task,
while the first task waits for its child to finish, otherwise killing
it.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Previously, if a message was supposed to be handled by 3 modules, they
would all be handled, synchronously, in the same process. If any of them
crashed, it would affect any other modules that needed to be processed
ahead of it.
Now, a new task is spun up for each module, so module handlers are now
indpendent.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Present rooms are tracked by Omnibot.Core now, instead of
Omnibot.State
* Channel synchronization is done through Omnibot.Core instead of
Omnibot.Irc
* Add Omnibot.Module.on_init/1 callback, which returns a "state" value
for the module to keep track of. By default, the state is nil.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Omnibot.Router was useful when it was used for actually routing
messages. However, its responsibilities have spread such that it's just
a single function at this point. So this single function has been moved
to Omnibot.Irc as a private function instead.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
The problem:
When we're going through the list of modules to send messages to based
on the channels they're a part of, it was being done so through the
config. Since the config doesn't (and shouldn't) list all of the core
modules that get included, any core modules that were loaded and running
under the ModuleSupervisor would not get included in the router's
attempt to send messages to a module.
Now, the Config.all_channels and Config.channel_modules functions live
in State, and State has a new "add_loaded_module" function where loaded
modules are registered. The aforementioned moved functions will use this
as the "source of truth" when deciding where to send messages for
modules to handle.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
Modules can easily be defined with `use Omnibot.Module`.
Omnibot.Contrib.Fortune has been updated to use this.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>