From 47c4ab1323b8ce7556f865954748cab35d27e757 Mon Sep 17 00:00:00 2001 From: href Date: Thu, 2 Sep 2021 08:27:56 +0200 Subject: web: show help for only enabled plugins --- lib/lsg_web/controllers/irc_controller.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/lsg_web/controllers/irc_controller.ex b/lib/lsg_web/controllers/irc_controller.ex index 9ddeefc..32007c2 100644 --- a/lib/lsg_web/controllers/irc_controller.ex +++ b/lib/lsg_web/controllers/irc_controller.ex @@ -6,11 +6,14 @@ defmodule LSGWeb.IrcController do def index(conn, params) do network = Map.get(params, "network") channel = if c = Map.get(params, "channel"), do: LSGWeb.reformat_chan(c) - commands = for mod <- ([IRC.Account.AccountPlugin] ++ Application.get_env(:lsg, :irc)[:plugins] ++ Application.get_env(:lsg, :irc)[:handlers]) do - identifier = Module.split(mod) |> List.last |> String.replace("Plugin", "") |> Macro.underscore - {identifier, mod.irc_doc()} + commands = for mod <- Enum.uniq([IRC.Account.AccountPlugin] ++ IRC.Plugin.enabled()) do + if is_atom(mod) do + identifier = Module.split(mod) |> List.last |> String.replace("Plugin", "") |> Macro.underscore + {identifier, mod.irc_doc()} + end end - |> Enum.reject(fn({_, i}) -> i == nil end) + |> Enum.filter(& &1) + |> Enum.filter(fn({_, doc}) -> doc end) members = cond do network -> IRC.Membership.expanded_members_or_friends(conn.assigns.account, network, channel) true -> IRC.Membership.of_account(conn.assigns.account) -- cgit v1.2.3