diff options
author | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
commit | 50c6a09ff64cb081b27a0c30790b86873449d172 (patch) | |
tree | ba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc.ex | |
parent | txt: fix against malicious filenames (aka 'fuck you shiv') (diff) |
:)
Diffstat (limited to '')
-rw-r--r-- | lib/lsg_irc.ex | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/lsg_irc.ex b/lib/lsg_irc.ex index 751c9c9..b988e04 100644 --- a/lib/lsg_irc.ex +++ b/lib/lsg_irc.ex @@ -1,2 +1,29 @@ 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 |