Commit Graph

18 Commits

Author SHA1 Message Date
906a20bda1 Update calls of Enum.member?/1 to be 'x in y' instead
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-11 16:00:09 -07:00
3b7562a1d2 Add base moduledoc to Plugin.Supervisor
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-11 15:55:36 -07:00
2dc7bbd94d Replace all other State.cfg/0 in favor of Irc.cfg/1
State.cfg/0 should be removed from the codebase by this point. Should be
safe to remove.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-08-11 12:52:37 -07:00
ec1dd42ca1 Fix routing bug in IRC and base plugin
Previously, messages were only routed from IRC if they were *not* for
the current user. This should only be happening for privmsg messages,
since a plugin is generally aware of what it's sending out.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-18 14:09:17 -07:00
880f363792 Remove (supervisor) opts from Omnibot.Plugin opts, update Plugin.Supervisor to use :one_for_all strategy by default
Plugin opts no longer contains options for the supervisors that watch
plugins, and said supervisors now adopt the one_for_all strategy. This
is because these servers *generally* need one another to stay alive.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-17 17:37:55 -07:00
c43c075588 Minor changes all around
* Wordbot does not IO.inspect() the winners of the round
* Split Omnibot.Plugin.base_children/1 into base_children_before/1 and
  base_children_after/1 for plugins that come before and after the
  children in the module
* Other minor changes

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-14 19:13:43 -07:00
522c62a55c Finish plugin and routing overhaul, there's a new model in town:
* Plugins all derive from Omnibot.Plugin. There still is a base plugin,
  in case we want to have another plugin backend instead of a GenServer
* All plugins are monitored by a unique Plugin.Supervisor, which is in
  turn started by the PluginSupervisor (yes this is confusing, yes it
  needs to be renamed)
* Any other auxiliary child processes may be started through the
  Plugin.children/1 function.
* By default, plugins have a CfgState process which is an Agent that
  keeps track of the plugin's configuration and state
* Plugin API is now called through the GenServer backend for better
  synchronicity.
* Very few changes to the front-facing Plugin API, which is nice

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-14 15:05:00 -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
9a8c6f2472 Finish up Plugin.Supervisor, replace markov and wordbot implementations with it
Both markov and wordbot have some auxiliary processes that run to keep
track of things. Previously, they both had custom supervisors grafted on
to the Plugin.Base - now, this grafting is automated with
Plugin.Supervisor.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-11 15:43:07 -07:00
369c9824fb Rename Plugin.Supervisor to PluginSupervisor
This is in preparation to make a bonafide Plugin.Supervisor import.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-09 16:39:24 -07:00
010d60f4f9 Actually remove Hooks from Plugin.Base - forgot to add this two commits
ago oopz

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-09 14:50:49 -07:00
1105d6c0e1 Remove Plugin.Agent, replace everywhere with Plugin.GenServer
Being able to handle arbitrary messages from other processes is a
generally useful thing to have for fine-grained control of the plugin.
Agents don't provide that, while GenServers do. I've removed all
instances of the Agent and replaced it with the GenServer and everything
appears fine so far.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-06 17:12:35 -07:00
b12a7d76f8 Fix small bug where plugins that don't override on_msg/2 would report errors
Since route_msg expects msg.prefix to be present, every plugin that
calls route_msg when no prefix is specified in the message (e.g. with
PING messages) would cause a crash of the process.

Now, it just calls a no-op function, since all behavior covered by
route_message requires information in the prefix at some point.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-06 17:02:41 -07:00
a190114a30 Rename module_supervisor.ex -> plugin/supervisor.ex, and PluginSupervisor -> Plugin.Supervisor
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:53:45 -07:00
8f112487c1 Update the instance of "module" with "plugin" and "mod" with "plug" where appropriate
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:30:46 -07:00
62a1064e87 Remove a couple of files that were accidentally introduced in the last commit
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:30:34 -07:00
f004b0ed01 Add lib/plugin that was removed in the last commit, whoops
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-02 18:23:55 -07:00