diff options
Diffstat (limited to '')
-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), |