Add OnConnect plugin
Use this plugin to run IRC commands upon connecting to the server. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
15
lib/contrib/on_connect.ex
Normal file
15
lib/contrib/on_connect.ex
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user