2020-06-12 17:29:35 -04:00
|
|
|
defmodule Omnibot.Router do
|
|
|
|
|
require Logger
|
2020-06-13 17:13:05 -04:00
|
|
|
alias Omnibot.{Irc.Msg, State}
|
2020-06-12 17:29:35 -04:00
|
|
|
|
2020-06-13 17:13:05 -04:00
|
|
|
def route(irc, msg) do
|
2020-06-13 18:01:40 -04:00
|
|
|
channel = Msg.channel(msg)
|
2020-06-13 17:13:05 -04:00
|
|
|
State.channel_modules(channel)
|
|
|
|
|
|> Enum.each(fn {module, _} -> module.on_msg(irc, msg) end)
|
2020-06-12 17:29:35 -04:00
|
|
|
end
|
|
|
|
|
|
2020-06-13 16:04:19 -04:00
|
|
|
#def handle(_irc, :privmsg, msg) do
|
|
|
|
|
# [channel | _params] = msg.params
|
2020-06-12 17:29:35 -04:00
|
|
|
|
2020-06-13 16:04:19 -04:00
|
|
|
# # Find modules that want this message
|
|
|
|
|
# State.cfg()
|
|
|
|
|
# |> Config.channel_modules(channel)
|
|
|
|
|
# |> Enum.each(fn {module, _} -> module.on_msg(msg) end)
|
|
|
|
|
#end
|
2020-06-12 17:29:35 -04:00
|
|
|
|
2020-06-13 16:04:19 -04:00
|
|
|
#def handle(_irc, :join, msg: %Msg {params: [channel | _]}) do
|
|
|
|
|
# State.cfg()
|
|
|
|
|
# |> Config.channel_modules(channel)
|
|
|
|
|
# |> Enum.each(fn {module, _} -> module.on_join(msg) end)
|
|
|
|
|
#end
|
2020-06-12 17:29:35 -04:00
|
|
|
|
2020-06-13 16:04:19 -04:00
|
|
|
#def handle(irc, :kick, msg: %Msg {params: [channel | _]}) do
|
|
|
|
|
# State.cfg()
|
|
|
|
|
# |> Config.channel_modules(channel)
|
|
|
|
|
# |> Enum.each(fn {module, _} -> module.on_kick(msg) end)
|
|
|
|
|
#end
|
2020-06-12 17:29:35 -04:00
|
|
|
|
2020-06-13 16:04:19 -04:00
|
|
|
#def handle(_irc, :part, %Msg {prefix: %Msg.Prefix{nick: nick}, params: [channel | _]}) do
|
|
|
|
|
# cfg = State.cfg()
|
|
|
|
|
# if nick == cfg.nick do
|
|
|
|
|
# State.remove_channel(State, channel)
|
|
|
|
|
# end
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
#def handle(irc, :ping, msg) do
|
|
|
|
|
# cfg = State.cfg()
|
|
|
|
|
# reply = Config.msg(cfg, "PONG", msg.params)
|
|
|
|
|
# Irc.send_msg(irc, reply)
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
#def handle(irc, :welcome, _msg) do
|
|
|
|
|
# Irc.sync_channels(irc)
|
|
|
|
|
#end
|
2020-06-12 17:29:35 -04:00
|
|
|
end
|