WIP: Supervisor-based plugin base

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-07-12 12:19:14 -07:00
parent e2a746709d
commit 9679c46e15
10 changed files with 33 additions and 71 deletions

View File

@@ -1,15 +1,13 @@
defmodule Omnibot.Contrib.OnConnect do
use Omnibot.Plugin.GenServer
use Omnibot.Plugin
require Logger
@default_config [channels: :all, commands: []]
@impl true
def on_msg(irc, msg) do
if msg.command == "001" do
Logger.debug("Got welcome message")
cfg()[:commands]
|> Enum.each(fn [cmd | params] -> Irc.send_msg(irc, cmd, params) end)
end
def on_msg(irc, %Irc.Msg {command: "001"}) do
Logger.info("Running OnConnect commands")
cfg()[:commands]
|> Enum.each(fn [cmd | params] -> Irc.send_msg(irc, cmd, params) end)
end
end