summaryrefslogtreecommitdiff
path: root/lib/lsg_irc.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-02-17 21:21:42 +0100
committerhref <href@random.sh>2018-02-17 21:21:42 +0100
commit50c6a09ff64cb081b27a0c30790b86873449d172 (patch)
treeba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc.ex
parenttxt: fix against malicious filenames (aka 'fuck you shiv') (diff)
:)
Diffstat (limited to 'lib/lsg_irc.ex')
-rw-r--r--lib/lsg_irc.ex27
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