Remove router.ex and move behavior to Omnibot.Irc
Omnibot.Router was useful when it was used for actually routing messages. However, its responsibilities have spread such that it's just a single function at this point. So this single function has been moved to Omnibot.Irc as a private function instead. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -30,6 +30,12 @@ defmodule Omnibot.Irc do
|
||||
|
||||
def sync_channels(irc), do: GenServer.cast(irc, :sync_channels)
|
||||
|
||||
defp route_msg(irc, msg) do
|
||||
channel = Msg.channel(msg)
|
||||
State.channel_modules(channel)
|
||||
|> Enum.each(fn {module, _} -> module.on_msg(irc, msg) end)
|
||||
end
|
||||
|
||||
## Server callbacks
|
||||
|
||||
@impl true
|
||||
@@ -91,7 +97,7 @@ defmodule Omnibot.Irc do
|
||||
irc = self()
|
||||
{:ok, _task} = Task.Supervisor.start_child(
|
||||
Omnibot.RouterSupervisor,
|
||||
fn -> Omnibot.Router.route(irc, msg) end
|
||||
fn -> route_msg(irc, msg) end
|
||||
)
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user