defmodule LSG.IRC do
def application_childs do
{:ok, irc_client} = ExIRC.start_link!
import Supervisor.Spec
[
worker(LSG.IRC.UserTrack.Storage, []),
worker(LSG.IRC.ConnectionHandler, [irc_client]),
worker(LSG.IRC.LoginHandler, [irc_client]),
worker(LSG.IRC.UserTrackHandler, [irc_client]),
]
++
for handler <- Application.get_env(:lsg, :irc)[:handlers] do
worker(handler, [irc_client])
end
end
def admin?(%{nick: nick, user: user, host: host}) do
for {n, u, h} <- Application.get_env(:lsg, :irc, [])[:admins]||[] do
admin_part_match?(n, nick) && admin_part_match?(u, user) && admin_part_match?(h, host)
end
|> Enum.any?
end
defp admin_part_match?(:_, _), do: true
defp admin_part_match?(a, a), do: true
defp admin_part_match?(_, _), do: false
end