diff options
Diffstat (limited to '')
-rw-r--r-- | lib/irc/irc.ex | 2 | ||||
-rw-r--r-- | lib/lsg/lsg.ex | 17 | ||||
-rw-r--r-- | lib/lsg_irc/logger_plugin.ex | 1 | ||||
-rw-r--r-- | lib/lsg_irc/lsg_irc.ex | 13 | ||||
-rw-r--r-- | lib/lsg_web/controllers/page_controller.ex | 2 | ||||
-rw-r--r-- | lib/lsg_web/views/layout_view.ex | 2 |
6 files changed, 23 insertions, 14 deletions
diff --git a/lib/irc/irc.ex b/lib/irc/irc.ex index fbad6e1..d9fdfb5 100644 --- a/lib/irc/irc.ex +++ b/lib/irc/irc.ex @@ -41,7 +41,7 @@ defmodule IRC do def admin?(%Message{sender: sender}), do: admin?(sender) def admin?(%{nick: nick, user: user, host: host}) do - for {n, u, h} <- Application.get_env(:lsg, :irc, [])[:admins]||[] do + for {n, u, h} <- LSG.IRC.env(:admins, []) do admin_part_match?(n, nick) && admin_part_match?(u, user) && admin_part_match?(h, host) end |> Enum.any? diff --git a/lib/lsg/lsg.ex b/lib/lsg/lsg.ex index 25f127f..b5da5e0 100644 --- a/lib/lsg/lsg.ex +++ b/lib/lsg/lsg.ex @@ -1,8 +1,19 @@ defmodule LSG do - def source_url() do - "https://git.random.sh/ircbot.git" - end + @default_brand [ + name: "Nola, + source_url: "https://phab.random.sh/source/Bot/", + owner: "Ashamed owner", + owner_email: "contact@my.nola.bot" + ] + + def env(), do: Application.get_env(:lsg) + def env(key, default \\ nil), do: Application.get_env(:lsg, key, default) + + def brand(), do: env(:brand, @default_brand) + def brand(key), do: Keyword.get(brand(), key) + def name(), do: brand(:name) + def source_url(), do: brand(:source_url) def data_path(suffix) do Path.join(data_path(), suffix) diff --git a/lib/lsg_irc/logger_plugin.ex b/lib/lsg_irc/logger_plugin.ex index e5307bc..de601a6 100644 --- a/lib/lsg_irc/logger_plugin.ex +++ b/lib/lsg_irc/logger_plugin.ex @@ -13,6 +13,7 @@ defmodule LSG.IRC.LoggerPlugin do regopts = [plugin: __MODULE__] {:ok, _} = Registry.register(IRC.PubSub, "triggers", regopts) {:ok, _} = Registry.register(IRC.PubSub, "messages", regopts) + {:ok, _} = Registry.register(IRC.PubSub, "irc:outputs", regopts) {:ok, _} = Registry.register(IRC.PubSub, "messages:private", regopts) {:ok, nil} end diff --git a/lib/lsg_irc/lsg_irc.ex b/lib/lsg_irc/lsg_irc.ex index c2782ad..a50abed 100644 --- a/lib/lsg_irc/lsg_irc.ex +++ b/lib/lsg_irc/lsg_irc.ex @@ -1,17 +1,15 @@ defmodule LSG.IRC do require Logger + def env(), do: LSG.env(:irc) + def env(key, default \\ nil), do: Keyword.get(env(), key, default) def application_childs do - env = Application.get_env(:lsg, :irc) import Supervisor.Spec IRC.Connection.setup() IRC.Plugin.setup() - # Probably just needed for migration - #for plugin <- Application.get_env(:lsg, :irc)[:plugins], do: IRC.Plugin.declare(plugin) - [ worker(Registry, [[keys: :duplicate, name: IRC.ConnectionPubSub]], id: :registr_irc_conn), worker(Registry, [[keys: :duplicate, name: IRC.PubSub]], id: :registry_irc), @@ -25,13 +23,12 @@ defmodule LSG.IRC do ] end + # Start plugins first to let them get on connection events. def after_start() do - # Start plugins first to let them get on connection events. - Logger.debug("IRC.after_start - initializing plugins") + Logger.info("Starting plugins") IRC.Plugin.start_all() - Logger.debug("IRC.after_start - initializing connections") + Logger.info("Starting connections") IRC.Connection.start_all() - Logger.debug("IRC.after_start - ok") end end diff --git a/lib/lsg_web/controllers/page_controller.ex b/lib/lsg_web/controllers/page_controller.ex index a87cf1d..94c9c70 100644 --- a/lib/lsg_web/controllers/page_controller.ex +++ b/lib/lsg_web/controllers/page_controller.ex @@ -33,7 +33,7 @@ defmodule LSGWeb.PageController do end def irc(conn, _) do - bot_helps = for mod <- Application.get_env(:lsg, :irc)[:handlers] do + bot_helps = for mod <- LSG.IRC.env(:handlers) do mod.irc_doc() end render conn, "irc.html", bot_helps: bot_helps diff --git a/lib/lsg_web/views/layout_view.ex b/lib/lsg_web/views/layout_view.ex index 41c5341..720281d 100644 --- a/lib/lsg_web/views/layout_view.ex +++ b/lib/lsg_web/views/layout_view.ex @@ -24,7 +24,7 @@ defmodule LSGWeb.LayoutView do conn.assigns[:chan] -> "#{conn.assigns.chan} @ #{conn.assigns.network}" conn.assigns[:network] -> conn.assigns.network - true -> Keyword.get(Application.get_env(:lsg, :irc), :name, "ircbot") + true -> Keyword.get(LSG.name()) end breadcrumb_title = Enum.map(Map.get(conn.assigns, :breadcrumbs)||[], fn({title, _href}) -> title end) |