Add lib/plugin that was removed in the last commit, whoops

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-02 18:23:55 -07:00
parent 4d7073cfcd
commit f004b0ed01
6 changed files with 304 additions and 0 deletions

37
lib/plugin/meta.ex Normal file
View File

@@ -0,0 +1,37 @@
defmodule Omnibot.Plugin.Meta do
defmodule Hooks do
defmacro __before_compile(_env) do
quote do
def children(_cfg), do: []
end
end
end
defmacro __using__([]) do
quote do
use Omnibot.Plugin.Base
use Supervisor
@behaviour Omnibot.Plugin.Meta
## Client API
def start_link(opts) do
Supervisor.start_link(opts)
end
## Server callbacks
def init(opts) do
cfg = opts[:cfg]
children = children(cfg)
Supervisor.init(children, opts)
end
defoverridable Omnibot.Plugin.Meta
@before_compile Omnibot.Plugin.Meta.Hooks
end
end
@callback children(cfg :: any) :: [{atom(), [{atom(), any}]}]
end