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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user