From d1428623a675952d18f730d051daf203db8b612e Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Mon, 6 Jul 2020 17:01:29 -0700 Subject: [PATCH] Add OnConnect plugin Use this plugin to run IRC commands upon connecting to the server. Signed-off-by: Alek Ratzloff --- lib/contrib/on_connect.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/contrib/on_connect.ex diff --git a/lib/contrib/on_connect.ex b/lib/contrib/on_connect.ex new file mode 100644 index 0000000..4122159 --- /dev/null +++ b/lib/contrib/on_connect.ex @@ -0,0 +1,15 @@ +defmodule Omnibot.Contrib.OnConnect do + 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 + end +end