diff options
author | Jordan Bracco <href@random.sh> | 2022-12-11 16:59:02 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-11 16:59:02 +0000 |
commit | 9a3757655ef233ef0352d930f84066b475d19e8c (patch) | |
tree | bd82c3f197ace1e14bb8828e012b0bf2ba94ee31 | |
parent | chore(account-plugin): complete documentation (diff) |
feat(base-plugin): list enabled plugins with `!plugins`
-rw-r--r-- | lib/lsg_irc/base_plugin.ex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/lsg_irc/base_plugin.ex b/lib/lsg_irc/base_plugin.ex index d5da532..ca2e8f3 100644 --- a/lib/lsg_irc/base_plugin.ex +++ b/lib/lsg_irc/base_plugin.ex @@ -12,9 +12,25 @@ defmodule LSG.IRC.BasePlugin do {:ok, _} = Registry.register(IRC.PubSub, "trigger:help", regopts) {:ok, _} = Registry.register(IRC.PubSub, "trigger:liquidrender", regopts) {:ok, _} = Registry.register(IRC.PubSub, "trigger:plugin", regopts) + {:ok, _} = Registry.register(IRC.PubSub, "trigger:plugins", regopts) {:ok, nil} end + def handle_info({:irc, :trigger, "plugins", msg = %{trigger: %{type: :bang, args: []}}}, _) do + enabled_string = IRC.Plugin.enabled() + |> Enum.map(fn(mod) -> + mod + |> Macro.underscore() + |> String.split("/", parts: :infinity) + |> List.last() + |> String.replace("_plugin", "") + |> Enum.sort() + end) + |> Enum.join(", ") + msg.replyfun.("Enabled plugins: #{enabled_string}") + {:noreply, nil} + end + def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :query, args: [plugin]}} = m}, _) do module = Module.concat([LSG.IRC, Macro.camelize(plugin<>"_plugin")]) with true <- Code.ensure_loaded?(module), |