2020-07-06 17:01:29 -07:00
|
|
|
defmodule Omnibot.Contrib.OnConnect do
|
2020-07-11 16:01:57 -07:00
|
|
|
use Omnibot.Plugin.GenServer
|
2020-07-06 17:01:29 -07:00
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|
end
|