Add Omnibot.Plugin.Base.on_connect/1 callback

This new callback gets called immediately upon connecting to the server.
It is automatically implemented as a no-op by default.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-08-12 15:31:40 -07:00
parent 0f3edb52bc
commit a3e4a088b3
2 changed files with 14 additions and 1 deletions

View File

@@ -19,6 +19,9 @@ defmodule Omnibot.Plugin.Base do
@impl true
def on_init(_cfg), do: nil
@impl true
def on_connect(_irc), do: nil
@impl true
def on_msg(irc, msg) do
route_msg(irc, msg)
@@ -38,6 +41,8 @@ defmodule Omnibot.Plugin.Base do
@behaviour Plugin.Base
defp route_msg(irc, :connect), do: on_connect(irc)
defp route_msg(irc, %Irc.Msg {prefix: nil}), do: nil
defp route_msg(irc, msg) do
@@ -95,6 +100,7 @@ defmodule Omnibot.Plugin.Base do
@callback on_part(irc :: pid(), channel :: String.t(), nick :: String.t()) :: any
@callback on_kick(irc :: pid(), channel :: String.t(), nick :: String.t(), target :: String.t()) :: any
@callback on_init(cfg :: any) :: any
@callback on_connect(irc :: pid()) :: any
@callback default_config() :: any
defmacro command(cmd, opts) do