diff --git a/lib/lsg/lsg.ex b/lib/lsg/lsg.ex index dc0f641..25f127f 100644 --- a/lib/lsg/lsg.ex +++ b/lib/lsg/lsg.ex @@ -1,15 +1,19 @@ defmodule LSG do + def source_url() do + "https://git.random.sh/ircbot.git" + end + def data_path(suffix) do Path.join(data_path(), suffix) end def data_path do Application.get_env(:lsg, :data_path) end def version do Application.spec(:lsg)[:vsn] end end diff --git a/lib/lsg_irc/base_plugin.ex b/lib/lsg_irc/base_plugin.ex index a95f45c..d5da532 100644 --- a/lib/lsg_irc/base_plugin.ex +++ b/lib/lsg_irc/base_plugin.ex @@ -1,108 +1,115 @@ defmodule LSG.IRC.BasePlugin do def irc_doc, do: nil def start_link() do GenServer.start_link(__MODULE__, [], name: __MODULE__) end def init([]) do regopts = [plugin: __MODULE__] {:ok, _} = Registry.register(IRC.PubSub, "trigger:version", regopts) {: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, 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), pid when is_pid(pid) <- GenServer.whereis(module) do m.replyfun.("loaded, active: #{inspect(pid)}") else false -> m.replyfun.("not loaded") nil -> msg = case IRC.Plugin.get(module) do :disabled -> "disabled" {_, false, _} -> "disabled" _ -> "not active" end m.replyfun.(msg) end {:noreply, nil} end def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :plus, args: [plugin]}} = m}, _) do module = Module.concat([LSG.IRC, Macro.camelize(plugin<>"_plugin")]) with true <- Code.ensure_loaded?(module), IRC.Plugin.switch(module, true), {:ok, pid} <- IRC.Plugin.start(module) do m.replyfun.("started: #{inspect(pid)}") else false -> m.replyfun.("not loaded") :ignore -> m.replyfun.("disabled or throttled") {:error, _} -> m.replyfun.("start error") end {:noreply, nil} end def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :tilde, args: [plugin]}} = m}, _) do module = Module.concat([LSG.IRC, Macro.camelize(plugin<>"_plugin")]) with true <- Code.ensure_loaded?(module), pid when is_pid(pid) <- GenServer.whereis(module), :ok <- GenServer.stop(pid), {:ok, pid} <- IRC.Plugin.start(module) do m.replyfun.("restarted: #{inspect(pid)}") else false -> m.replyfun.("not loaded") nil -> m.replyfun.("not active") end {:noreply, nil} end def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :minus, args: [plugin]}} = m}, _) do module = Module.concat([LSG.IRC, Macro.camelize(plugin<>"_plugin")]) with true <- Code.ensure_loaded?(module), pid when is_pid(pid) <- GenServer.whereis(module), :ok <- GenServer.stop(pid) do IRC.Plugin.switch(module, false) m.replyfun.("stopped: #{inspect(pid)}") else false -> m.replyfun.("not loaded") nil -> m.replyfun.("not active") end {:noreply, nil} end def handle_info({:irc, :trigger, "liquidrender", m = %{trigger: %{args: args}}}, _) do template = Enum.join(args, " ") m.replyfun.(Tmpl.render(template, m)) {:noreply, nil} end def handle_info({:irc, :trigger, "help", m = %{trigger: %{type: :bang}}}, _) do url = LSGWeb.Router.Helpers.irc_url(LSGWeb.Endpoint, :index, m.network, LSGWeb.format_chan(m.channel)) m.replyfun.("-> #{url}") {:noreply, nil} end def handle_info({:irc, :trigger, "version", message = %{trigger: %{type: :bang}}}, _) do {:ok, vsn} = :application.get_key(:lsg, :vsn) ver = List.to_string(vsn) url = LSGWeb.Router.Helpers.irc_url(LSGWeb.Endpoint, :index) - version = "v#{ver} ; #{url} ; source: https://git.yt/115ans/sys" - message.replyfun.(version) + elixir_ver = Application.started_applications() |> List.keyfind(:elixir, 0) |> elem(2) |> to_string() + otp_ver = :erlang.system_info(:system_version) |> to_string() |> String.trim() + system = :erlang.system_info(:system_architecture) |> to_string() + message.replyfun.([ + <<"🤖 I am a robot running", 2, "beautte, version #{ver}", 2, " — source: #{LSG.source_url()}, + "🦾 Elixir #{elixir_ver} #{otp_ver} on #{system}" + "👷‍♀️ Owner: href ", + "🌍 Web interface: #{url}" + ]) {:noreply, nil} end def handle_info(msg, _) do {:noreply, nil} end end diff --git a/lib/lsg_web/templates/irc/index.html.eex b/lib/lsg_web/templates/irc/index.html.eex index 52372b5..6cc3128 100644 --- a/lib/lsg_web/templates/irc/index.html.eex +++ b/lib/lsg_web/templates/irc/index.html.eex @@ -1,44 +1,44 @@ <%= if @members != [] do %> <% end %>
<%= for {identifier, help} <- @commands do %> <%= if help do %>
<%= LSGWeb.LayoutView.liquid_markdown(@conn, help) %>
<% end %> <% end %>



Légende:
entre < >: argument obligatoire,
entre [ ]: argument optionel; [1 | ]: argument optionel avec valeur par défaut.




- source: git.yt/115ans/sys + running beautte version <%= LSG.version() %> — git

diff --git a/mix.exs b/mix.exs index 330bcc0..05dd026 100644 --- a/mix.exs +++ b/mix.exs @@ -1,96 +1,97 @@ defmodule LSG.Mixfile do use Mix.Project def project do [ app: :lsg, version: version("0.2.6"), elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, deps: deps() ] end def application do [ mod: {LSG.Application, []}, extra_applications: [:logger, :runtime_tools] ] end defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] defp aliases do [ "assets.deploy": ["make -C assets", "phx.digest"] ] end defp deps do [ {:phoenix, "~> 1.6.0-rc.0", override: true}, {:phoenix_pubsub, "~> 2.0"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:phoenix_html, "~> 3.0"}, {:phoenix_live_view, "~> 0.16.0"}, {:phoenix_live_dashboard, "~> 0.5"}, {:telemetry, "~> 1.0.0", override: true}, {:telemetry_metrics, "~> 0.6"}, {:telemetry_poller, "~> 0.5"}, {:plug_cowboy, "~> 2.0"}, {:cowlib, "~> 2.9.1", override: true}, {:plug, "~> 1.7"}, {:gettext, "~> 0.11"}, {:httpoison, "~> 1.8", override: true}, {:jason, "~> 1.0"}, {:poison, "~> 4.0", override: true}, {:floki, "~> 0.19.3"}, {:ecto, "~> 3.4"}, {:exirc, git: "https://git.random.sh/ircbot/exirc.git", branch: "fix-who-nick"}, {:distillery, "~> 2.0"}, {:earmark, "~> 1.2"}, {:oauther, "~> 1.1"}, {:extwitter, "~> 0.12.0"}, {:entropy_string, "~> 1.0.0"}, {:abacus, "~> 0.3.3"}, {:ex_chain, github: "eljojo/ex_chain"}, {:timex, "~> 3.6"}, {:muontrap, "~> 0.5.1"}, {:tzdata, "~> 1.0"}, {:nimble_csv, "~> 0.7.0"}, {:backoff, git: "https://github.com/ferd/backoff", branch: "master"}, {:telegram, git: "https://github.com/hrefhref/telegram.git", branch: "master"}, {:ex_aws, "~> 2.0"}, {:ex_aws_s3, "~> 2.0"}, {:gen_magic, git: "https://github.com/hrefhref/gen_magic", branch: "develop"}, {:liquex, "~> 0.3"}, {:html_entities, "0.4.0", override: true}, {:file_size, "~> 3.0"}, {:ex2ms, "~> 1.0"}, {:polyjuice_client, git: "https://git.random.sh/ircbot/polyjuice_client.git", branch: "master", override: true}, {:matrix_app_service, git: "https://git.random.sh/ircbot/matrix_app_service.ex.git", branch: "master"}, {:sentry, "~> 8.0.5"}, {:logger_json, "~> 4.3"}, {:oauth2, "~> 2.0"}, {:powerdnsex, git: "https://git.random.sh/ircbot/powerdnsex.git", branch: "master"}, {:pfx, "~> 0.7.0"}, {:flake_id, "~> 0.1.0"} ] end defp version(v) do {describe, 0} = System.cmd("git", ~w(describe --dirty --broken --all --tags --long)) [_, rest] = String.split(describe, "/") info = String.trim(rest) env = cond do Mix.env() == :prod -> "" true -> "." <> to_string(Mix.env()) end + build_date_tag = Timex.format!(DateTime.utc_now(), ".build%y%m%d@%H%M", :strftime) - v <> "+" <> info <> env + v <> "+" <> info <> env <> <> build_date_tag end end