diff options
Diffstat (limited to 'lib/lsg_irc.ex')
-rw-r--r-- | lib/lsg_irc.ex | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/lsg_irc.ex b/lib/lsg_irc.ex index b988e04..482cb5d 100644 --- a/lib/lsg_irc.ex +++ b/lib/lsg_irc.ex @@ -4,26 +4,22 @@ defmodule LSG.IRC 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]), + worker(Registry, [[keys: :duplicate, name: IRC.PubSub]], id: :registry_irc), + worker(IRC.UserTrack.Storage, []), + worker(IRC.ConnectionHandler, [irc_client]), + worker(IRC.LoginHandler, [irc_client]), + worker(IRC.UserTrackHandler, [irc_client]), + worker(IRC.PubSubHandler, [irc_client], [name: :irc_pub_sub]), ] ++ for handler <- Application.get_env(:lsg, :irc)[:handlers] do - worker(handler, [irc_client]) + worker(handler, [irc_client], [name: handler]) 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) + ++ + for plugin <- Application.get_env(:lsg, :irc)[:plugins] do + worker(plugin, [], [name: plugin]) 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 |