Commit Graph

10 Commits

Author SHA1 Message Date
fe0fb59977 Fix up logic for Omnibot.Core pinging and auto-reconnect
The core module keeps track of the last message received. If the last
message received was more than X seconds ago (configurable), it will
send a ping. If the last message was received more than Y seconds ago
(again, configurable) then reset the connection.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-12 18:25:24 -07:00
8d42e6ecb3 Add ping watcher to Omnibot.Core
Core module now pings the server and attempts to reconnect if a
respective pong has not been received in a certain amount of time.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-12 15:33:04 -07:00
c1602065ae Update Omnibot.Core state to use a map for flexibility
More things need to be added to Omnibot.Core's state, so it's been
expanded to a map to allow for that.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-11 16:17:42 -07:00
aa6a4bf5fa Move lib/core/core.ex -> lib/core.ex
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-11 16:14:08 -07:00
9679c46e15 WIP: Supervisor-based plugin base
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-12 12:19:14 -07:00
e2a746709d Update Plugin.GenServer to match the same pattern that Plugin.Supervisor does, remove Omnibot.Plugin
* using Plugin.GenServer now uses Plugin.Base so that is not required
* Remove Omnibot.Plugin because all it did was include Plugin.GenServer
  and Plugin.Base

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-11 16:01:57 -07:00
4d7073cfcd Rename Module -> Plugin with basic find/replace
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:23:24 -07:00
4083b5b858 Add default_config, and cfg[:timeout] for tasks
- 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>
2020-06-13 21:47:46 -04:00
4000528d81 Move more stuff from other places into Omnibot.Core
* 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>
2020-06-13 18:45:02 -04:00
4d27e30b88 Finish migration to using a module to control core behavior
Previously, core behavior was handled in the Omnibot.Router module.
However, since the module system is robust enough, this work has been
delegated to the Omnibot.Core module.

Additionally, the Omnibot.State module has been augmented to keep track
of the modules that have been currently loaded, and methods that are
used to get the list of loaded modules and routing information for those
modules are coming from Omnibot.State as well (as opposed to
Omnibot.Config). This is to avoid requiring the Omnibot.Core module be
included in the config, plus avoiding modification of the runtime config
after it has already been loaded.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-06-13 18:01:40 -04:00