summaryrefslogtreecommitdiff
path: root/lib/nola_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nola_plugins')
-rw-r--r--lib/nola_plugins/README.md1
-rw-r--r--lib/nola_plugins/account.ex188
-rw-r--r--lib/nola_plugins/admin_handler.ex41
-rw-r--r--lib/nola_plugins/alcoolog.ex (renamed from lib/nola_plugins/alcolog_plugin.ex)24
-rw-r--r--lib/nola_plugins/alcoolog_announcer.ex (renamed from lib/nola_plugins/alcoolog_announcer_plugin.ex)7
-rw-r--r--lib/nola_plugins/base.ex (renamed from lib/nola_plugins/base_plugin.ex)27
-rw-r--r--lib/nola_plugins/boursorama.ex (renamed from lib/nola_plugins/bourosama_plugin.ex)2
-rw-r--r--lib/nola_plugins/buffer.ex (renamed from lib/nola_plugins/buffer_plugin.ex)2
-rw-r--r--lib/nola_plugins/calc.ex (renamed from lib/nola_plugins/calc_plugin.ex)2
-rw-r--r--lib/nola_plugins/coronavirus.ex (renamed from lib/nola_plugins/coronavirus_plugin.ex)2
-rw-r--r--lib/nola_plugins/correction.ex (renamed from lib/nola_plugins/correction_plugin.ex)2
-rw-r--r--lib/nola_plugins/dice.ex (renamed from lib/nola_plugins/dice_plugin.ex)2
-rw-r--r--lib/nola_plugins/finance.ex (renamed from lib/nola_plugins/finance_plugin.ex)2
-rw-r--r--lib/nola_plugins/gpt.ex (renamed from lib/nola_plugins/gpt_plugin.ex)6
-rw-r--r--lib/nola_plugins/helpers/temp_ref.ex95
-rw-r--r--lib/nola_plugins/kick_roulette.ex (renamed from lib/nola_plugins/kick_roulette_plugin.ex)2
-rw-r--r--lib/nola_plugins/last_fm.ex (renamed from lib/nola_plugins/last_fm_plugin.ex)2
-rw-r--r--lib/nola_plugins/link.ex (renamed from lib/nola_plugins/link_plugin.ex)12
-rw-r--r--lib/nola_plugins/link/github.ex (renamed from lib/nola_plugins/link_plugin/github.ex)4
-rw-r--r--lib/nola_plugins/link/html.ex (renamed from lib/nola_plugins/link_plugin/html.ex)4
-rw-r--r--lib/nola_plugins/link/imgur.ex (renamed from lib/nola_plugins/link_plugin/imgur.ex)4
-rw-r--r--lib/nola_plugins/link/pdf.ex (renamed from lib/nola_plugins/link_plugin/pdf.ex)4
-rw-r--r--lib/nola_plugins/link/redacted.ex (renamed from lib/nola_plugins/link_plugin/redacted.ex)4
-rw-r--r--lib/nola_plugins/link/reddit.ex (renamed from lib/nola_plugins/link_plugin/reddit.ex)4
-rw-r--r--lib/nola_plugins/link/twitter.ex (renamed from lib/nola_plugins/link_plugin/twitter.ex)4
-rw-r--r--lib/nola_plugins/link/youtube.ex (renamed from lib/nola_plugins/link_plugin/youtube.ex)4
-rw-r--r--lib/nola_plugins/logger.ex (renamed from lib/nola_plugins/logger_plugin.ex)3
-rw-r--r--lib/nola_plugins/outline.ex (renamed from lib/nola_plugins/outline_plugin.ex)2
-rw-r--r--lib/nola_plugins/preums.ex (renamed from lib/nola_plugins/preums_plugin.ex)4
-rw-r--r--lib/nola_plugins/quatre_cent_vingt.ex (renamed from lib/nola_plugins/quatre_cent_vingt_plugin.ex)2
-rw-r--r--lib/nola_plugins/radio_france.ex (renamed from lib/nola_plugins/radio_france_plugin.ex)2
-rw-r--r--lib/nola_plugins/say.ex (renamed from lib/nola_plugins/say_plugin.ex)2
-rw-r--r--lib/nola_plugins/script.ex (renamed from lib/nola_plugins/script_plugin.ex)2
-rw-r--r--lib/nola_plugins/seen.ex (renamed from lib/nola_plugins/seen_plugin.ex)2
-rw-r--r--lib/nola_plugins/sms.ex (renamed from lib/nola_plugins/sms_plugin.ex)2
-rw-r--r--lib/nola_plugins/tell.ex (renamed from lib/nola_plugins/tell_plugin.ex)2
-rw-r--r--lib/nola_plugins/txt.ex (renamed from lib/nola_plugins/txt_plugin.ex)4
-rw-r--r--lib/nola_plugins/txt/markov.ex (renamed from lib/nola_plugins/txt_plugin/markov.ex)2
-rw-r--r--lib/nola_plugins/txt/markov_native.ex (renamed from lib/nola_plugins/txt_plugin/markov_native.ex)4
-rw-r--r--lib/nola_plugins/txt/markov_py_markovify.ex (renamed from lib/nola_plugins/txt_plugin/markov_py_markovify.ex)6
-rw-r--r--lib/nola_plugins/untappd.ex (renamed from lib/nola_plugins/untappd_plugin.ex)2
-rw-r--r--lib/nola_plugins/user_mention.ex (renamed from lib/nola_plugins/user_mention_plugin.ex)6
-rw-r--r--lib/nola_plugins/wikipedia.ex (renamed from lib/nola_plugins/wikipedia_plugin.ex)2
-rw-r--r--lib/nola_plugins/wolfram_alpha.ex (renamed from lib/nola_plugins/wolfram_alpha_plugin.ex)2
-rw-r--r--lib/nola_plugins/youtube.ex (renamed from lib/nola_plugins/youtube_plugin.ex)2
45 files changed, 373 insertions, 131 deletions
diff --git a/lib/nola_plugins/README.md b/lib/nola_plugins/README.md
new file mode 100644
index 0000000..82adba8
--- /dev/null
+++ b/lib/nola_plugins/README.md
@@ -0,0 +1 @@
+## Nola Plugins directory
diff --git a/lib/nola_plugins/account.ex b/lib/nola_plugins/account.ex
new file mode 100644
index 0000000..c11d077
--- /dev/null
+++ b/lib/nola_plugins/account.ex
@@ -0,0 +1,188 @@
+defmodule Nola.Plugins.Account do
+ @moduledoc """
+ # Account
+
+ * **account** Get current account id and token
+ * **auth `<account-id>` `<token>`** Authenticate and link the current nickname to an account
+ * **auth** list authentications methods
+ * **whoami** list currently authenticated users
+ * **web** get a one-time login link to web
+ * **enable-telegram** Link a Telegram account
+ * **enable-sms** Link a SMS number
+ * **enable-untappd** Link a Untappd account
+ * **set-name** set account name
+ * **setusermeta puppet-nick `<nick>`** Set puppet IRC nickname
+ """
+
+ def irc_doc, do: @moduledoc
+ def start_link(), do: GenServer.start_link(__MODULE__, [], name: __MODULE__)
+ def init(_) do
+ {:ok, _} = Registry.register(IRC.PubSub, "messages:private", [])
+ {:ok, nil}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "help"}}, state) do
+ text = [
+ "account: show current account and auth token",
+ "auth: show authentications methods",
+ "whoami: list authenticated users",
+ "set-name <name>: set account name",
+ "web: login to web",
+ "enable-sms | disable-sms: enable/change or disable sms",
+ "enable-telegram: link/change telegram",
+ "enable-untappd: link untappd account",
+ "getmeta: show meta datas",
+ "setusermeta: set user meta",
+ ]
+ m.replyfun.(text)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "auth"}}, state) do
+ spec = [{{:"$1", :"$2"}, [{:==, :"$2", {:const, account.id}}], [:"$1"]}]
+ predicates = :dets.select(IRC.Account.file("predicates"), spec)
+ text = for {net, {key, value}} <- predicates, do: "#{net}: #{to_string(key)}: #{value}"
+ m.replyfun.(text)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "whoami"}}, state) do
+ users = for user <- IRC.UserTrack.find_by_account(m.account) do
+ chans = Enum.map(user.privileges, fn({chan, _}) -> chan end)
+ |> Enum.join(" ")
+ "#{user.network} - #{user.nick}!#{user.username}@#{user.host} - #{chans}"
+ end
+ m.replyfun.(users)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "account"}}, state) do
+ account = IRC.Account.lookup(m.sender)
+ text = ["Account Id: #{account.id}",
+ "Authenticate to this account from another network: \"auth #{account.id} #{account.token}\" to the other bot!"]
+ m.replyfun.(text)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{sender: sender, text: "auth"<>_}}, state) do
+ #account = IRC.Account.lookup(m.sender)
+ case String.split(m.text, " ") do
+ ["auth", id, token] ->
+ join_account(m, id, token)
+ _ ->
+ m.replyfun.("Invalid parameters")
+ end
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{account: account, text: "set-name "<>name}}, state) do
+ IRC.Account.update_account_name(account, name)
+ m.replyfun.("Name changed: #{name}")
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "disable-sms"}}, state) do
+ if IRC.Account.get_meta(m.account, "sms-number") do
+ IRC.Account.delete_meta(m.account, "sms-number")
+ m.replfyun.("SMS disabled.")
+ else
+ m.replyfun.("SMS already disabled.")
+ end
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "web"}}, state) do
+ auth_url = Untappd.auth_url()
+ login_url = Nola.AuthToken.new_url(m.account.id, nil)
+ m.replyfun.("-> " <> login_url)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "enable-sms"}}, state) do
+ code = String.downcase(EntropyString.small_id())
+ IRC.Account.put_meta(m.account, "sms-validation-code", code)
+ IRC.Account.put_meta(m.account, "sms-validation-target", m.network)
+ number = Nola.IRC.Sms.my_number()
+ text = "To enable or change your number for SMS messaging, please send:"
+ <> " \"enable #{code}\" to #{number}"
+ m.replyfun.(text)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "enable-telegram"}}, state) do
+ code = String.downcase(EntropyString.small_id())
+ IRC.Account.delete_meta(m.account, "telegram-id")
+ IRC.Account.put_meta(m.account, "telegram-validation-code", code)
+ IRC.Account.put_meta(m.account, "telegram-validation-target", m.network)
+ text = "To enable or change your number for telegram messaging, please open #{Nola.Telegram.my_path()} and send:"
+ <> " \"/enable #{code}\""
+ m.replyfun.(text)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "enable-untappd"}}, state) do
+ auth_url = Untappd.auth_url()
+ login_url = Nola.AuthToken.new_url(m.account.id, {:external_redirect, auth_url})
+ m.replyfun.(["To link your Untappd account, open this URL:", login_url])
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "getmeta"<>_}}, state) do
+ result = case String.split(m.text, " ") do
+ ["getmeta"] ->
+ for {k, v} <- IRC.Account.get_all_meta(m.account) do
+ case k do
+ "u:"<>key -> "(user) #{key}: #{v}"
+ key -> "#{key}: #{v}"
+ end
+ end
+ ["getmeta", key] ->
+ value = IRC.Account.get_meta(m.account, key)
+ text = if value do
+ "#{key}: #{value}"
+ else
+ "#{key} is not defined"
+ end
+ _ ->
+ "usage: getmeta [key]"
+ end
+ m.replyfun.(result)
+ {:noreply, state}
+ end
+
+ def handle_info({:irc, :text, m = %IRC.Message{text: "setusermeta"<>_}}, state) do
+ result = case String.split(m.text, " ") do
+ ["setusermeta", key, value] ->
+ IRC.Account.put_user_meta(m.account, key, value)
+ "ok"
+ _ ->
+ "usage: setusermeta <key> <value>"
+ end
+ m.replyfun.(result)
+ {:noreply, state}
+ end
+
+ def handle_info(_, state) do
+ {:noreply, state}
+ end
+
+ defp join_account(m, id, token) do
+ old_account = IRC.Account.lookup(m.sender)
+ new_account = IRC.Account.get(id)
+ if new_account && token == new_account.token do
+ case IRC.Account.merge_account(old_account.id, new_account.id) do
+ :ok ->
+ if old_account.id == new_account.id do
+ m.replyfun.("Already authenticated, but hello")
+ else
+ m.replyfun.("Accounts merged!")
+ end
+ _ -> m.replyfun.("Something failed :(")
+ end
+ else
+ m.replyfun.("Invalid token")
+ end
+ end
+
+ end
+
diff --git a/lib/nola_plugins/admin_handler.ex b/lib/nola_plugins/admin_handler.ex
deleted file mode 100644
index 9a5d557..0000000
--- a/lib/nola_plugins/admin_handler.ex
+++ /dev/null
@@ -1,41 +0,0 @@
-defmodule Nola.IRC.AdminHandler do
- @moduledoc """
- # admin
-
- !op
- op; requiert admin
- """
-
- def irc_doc, do: nil
-
- def start_link(client) do
- GenServer.start_link(__MODULE__, [client])
- end
-
- def init([client]) do
- ExIRC.Client.add_handler client, self
- :ok = IRC.register("op")
- {:ok, client}
- end
-
- def handle_info({:irc, :trigger, "op", m = %IRC.Message{trigger: %IRC.Trigger{type: :bang}, sender: sender}}, client) do
- if IRC.admin?(sender) do
- m.replyfun.({:mode, "+o"})
- else
- m.replyfun.({:kick, "non"})
- end
- {:noreply, client}
- end
-
- def handle_info({:joined, chan, sender}, client) do
- if IRC.admin?(sender) do
- ExIRC.Client.mode(client, chan, "+o", sender.nick)
- end
- {:noreply, client}
- end
-
- def handle_info(msg, client) do
- {:noreply, client}
- end
-
-end
diff --git a/lib/nola_plugins/alcolog_plugin.ex b/lib/nola_plugins/alcoolog.ex
index 145e4fc..7f44ca2 100644
--- a/lib/nola_plugins/alcolog_plugin.ex
+++ b/lib/nola_plugins/alcoolog.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.AlcoologPlugin do
+defmodule Nola.Plugins.Alcoolog do
require Logger
@moduledoc """
@@ -102,7 +102,7 @@ defmodule Nola.IRC.AlcoologPlugin do
@eau ["santo", "santeau"]
def handle_info({:irc, :trigger, santeau, m = %IRC.Message{trigger: %IRC.Trigger{args: _, type: :bang}}}, state) when santeau in @eau do
- Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.santo")
+ Nola.Plugins.Txt.reply_random(m, "alcoolog.santo")
{:noreply, state}
end
@@ -330,9 +330,9 @@ defmodule Nola.IRC.AlcoologPlugin do
cond do
cl == nil -> m.replyfun.(cl_extra)
deg == nil -> m.replyfun.(comment)
- cl >= 500 || deg >= 100 -> Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.drink_toohuge")
- cl == 0 || deg == 0 -> Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.drink_zero")
- cl < 0 || deg < 0 -> Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.drink_negative")
+ cl >= 500 || deg >= 100 -> Nola.Plugins.Txt.reply_random(m, "alcoolog.drink_toohuge")
+ cl == 0 || deg == 0 -> Nola.Plugins.Txt.reply_random(m, "alcoolog.drink_zero")
+ cl < 0 || deg < 0 -> Nola.Plugins.Txt.reply_random(m, "alcoolog.drink_negative")
true ->
points = Alcool.units(cl, deg)
now = m.at || DateTime.utc_now()
@@ -347,7 +347,7 @@ defmodule Nola.IRC.AlcoologPlugin do
:ok = :dets.insert(state.dets, {m.account.id, now, points, if(old_stats, do: old_stats.active, else: 0), cl, deg, name, comment, meta})
true = :ets.insert(state.ets, {{m.account.id, now}, points, if(old_stats, do: old_stats.active, else: 0),cl, deg, name, comment, meta})
#sante = @santai |> Enum.map(fn(s) -> String.trim(String.upcase(s)) end) |> Enum.shuffle() |> Enum.random()
- sante = Nola.IRC.TxtPlugin.random("alcoolog.santai")
+ sante = Nola.Plugins.Txt.random("alcoolog.santai")
k = if user_meta.sex, do: 0.7, else: 0.6
weight = user_meta.weight
peak = Float.round((10*points||0.0)/(k*weight), 4)
@@ -449,7 +449,7 @@ defmodule Nola.IRC.AlcoologPlugin do
end
if miss do
- miss = Nola.IRC.TxtPlugin.random("alcoolog.#{to_string(miss)}")
+ miss = Nola.Plugins.Txt.random("alcoolog.#{to_string(miss)}")
if miss do
for {net, chan} <- IRC.Membership.notify_channels(m.account) do
user = IRC.UserTrack.find_by_account(net, m.account)
@@ -532,7 +532,7 @@ defmodule Nola.IRC.AlcoologPlugin do
rising_file_key = if rising, do: "_rising", else: ""
txt_file = "alcoolog." <> "user_" <> to_string(user_state) <> rising_file_key
- user_status = Nola.IRC.TxtPlugin.random(txt_file)
+ user_status = Nola.Plugins.Txt.random(txt_file)
meta = get_user_meta(state, nick)
minutes_til_sober = h1/((meta.loss_factor/100)/60)
@@ -831,11 +831,11 @@ defmodule Nola.IRC.AlcoologPlugin do
put_user_meta(state, m.account.id, meta)
cond do
old_meta.weight < meta.weight ->
- Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.fatter")
+ Nola.Plugins.Txt.reply_random(m, "alcoolog.fatter")
old_meta.weight == meta.weight ->
m.replyfun.("aucun changement!")
true ->
- Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.thinner")
+ Nola.Plugins.Txt.reply_random(m, "alcoolog.thinner")
end
end
@@ -848,7 +848,7 @@ defmodule Nola.IRC.AlcoologPlugin do
:dets.delete_object(state.dets, obj)
:ets.delete(state.ets, {m.account.id, date})
m.replyfun.("supprimΓ©: #{m.sender.nick} #{points} #{type} #{descr}")
- Nola.IRC.TxtPlugin.reply_random(m, "alcoolog.delete")
+ Nola.Plugins.Txt.reply_random(m, "alcoolog.delete")
notify = IRC.Membership.notify_channels(m.account) -- [{m.network,m.channel}]
for {net, chan} <- notify do
user = IRC.UserTrack.find_by_account(net, m.account)
@@ -995,7 +995,7 @@ defmodule Nola.IRC.AlcoologPlugin do
end
def handle_info(t, state) do
- Logger.debug("AlcoologPlugin: unhandled info #{inspect t}")
+ Logger.debug("#{__MODULE__}: unhandled info #{inspect t}")
{:noreply, state}
end
diff --git a/lib/nola_plugins/alcoolog_announcer_plugin.ex b/lib/nola_plugins/alcoolog_announcer.ex
index f90dc42..674f19b 100644
--- a/lib/nola_plugins/alcoolog_announcer_plugin.ex
+++ b/lib/nola_plugins/alcoolog_announcer.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.AlcoologAnnouncerPlugin do
+defmodule Nola.Plugins.AlcoologAnnouncer do
require Logger
@moduledoc """
@@ -52,9 +52,6 @@ defmodule Nola.IRC.AlcoologAnnouncerPlugin do
dets_filename = (Nola.data_path() <> "/" <> "alcoologlog.dets") |> String.to_charlist
{:ok, dets} = :dets.open_file(dets_filename, [{:type,:bag}])
ets = nil # :ets.new(__MODULE__.ETS, [:ordered_set, :named_table, :protected, {:read_concurrency, true}])
- #:ok = Nola.IRC.SettingPlugin.declare("alcoolog.alerts", __MODULE__, true, :boolean)
- #:ok = Nola.IRC.SettingPlugin.declare("alcoolog.aperoalert", __MODULE__, true, :boolean)
- #
{:ok, {stats, now(), dets, ets}}#, {:continue, :traverse}}
end
@@ -262,7 +259,7 @@ defmodule Nola.IRC.AlcoologAnnouncerPlugin do
end
defp get_stats() do
- Enum.into(Nola.IRC.AlcoologPlugin.get_all_stats(), %{})
+ Enum.into(Nola.Plugins.Alcoolog.get_all_stats(), %{})
end
defp timer() do
diff --git a/lib/nola_plugins/base_plugin.ex b/lib/nola_plugins/base.ex
index a2b9ffb..b7b5e16 100644
--- a/lib/nola_plugins/base_plugin.ex
+++ b/lib/nola_plugins/base.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.BasePlugin do
+defmodule Nola.Plugins.Base do
def irc_doc, do: nil
@@ -17,13 +17,12 @@ defmodule Nola.IRC.BasePlugin do
end
def handle_info({:irc, :trigger, "plugins", msg = %{trigger: %{type: :bang, args: []}}}, _) do
- enabled_string = IRC.Plugin.enabled()
+ enabled_string = Nola.Plugins.enabled()
|> Enum.map(fn(mod) ->
mod
|> Macro.underscore()
|> String.split("/", parts: :infinity)
|> List.last()
- |> String.replace("_plugin", "")
|> Enum.sort()
end)
|> Enum.join(", ")
@@ -32,7 +31,7 @@ defmodule Nola.IRC.BasePlugin do
end
def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :query, args: [plugin]}} = m}, _) do
- module = Module.concat([Nola.IRC, Macro.camelize(plugin<>"_plugin")])
+ module = Module.concat([Nola.Plugins, Macro.camelize(plugin)])
with true <- Code.ensure_loaded?(module),
pid when is_pid(pid) <- GenServer.whereis(module)
do
@@ -40,7 +39,7 @@ defmodule Nola.IRC.BasePlugin do
else
false -> m.replyfun.("not loaded")
nil ->
- msg = case IRC.Plugin.get(module) do
+ msg = case Nola.Plugins.get(module) do
:disabled -> "disabled"
{_, false, _} -> "disabled"
_ -> "not active"
@@ -51,10 +50,10 @@ defmodule Nola.IRC.BasePlugin do
end
def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :plus, args: [plugin]}} = m}, _) do
- module = Module.concat([Nola.IRC, Macro.camelize(plugin<>"_plugin")])
+ module = Module.concat([Nola.Plugins, Macro.camelize(plugin)])
with true <- Code.ensure_loaded?(module),
- IRC.Plugin.switch(module, true),
- {:ok, pid} <- IRC.Plugin.start(module)
+ Nola.Plugins.switch(module, true),
+ {:ok, pid} <- Nola.Plugins.start(module)
do
m.replyfun.("started: #{inspect(pid)}")
else
@@ -66,11 +65,11 @@ defmodule Nola.IRC.BasePlugin do
end
def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :tilde, args: [plugin]}} = m}, _) do
- module = Module.concat([Nola.IRC, Macro.camelize(plugin<>"_plugin")])
+ module = Module.concat([Nola.Plugins, Macro.camelize(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)
+ {:ok, pid} <- Nola.Plugins.start(module)
do
m.replyfun.("restarted: #{inspect(pid)}")
else
@@ -82,7 +81,7 @@ defmodule Nola.IRC.BasePlugin do
def handle_info({:irc, :trigger, "plugin", %{trigger: %{type: :minus, args: [plugin]}} = m}, _) do
- module = Module.concat([Nola.IRC, Macro.camelize(plugin<>"_plugin")])
+ module = Module.concat([Nola.Plugins, Macro.camelize(plugin)])
with true <- Code.ensure_loaded?(module),
pid when is_pid(pid) <- GenServer.whereis(module),
:ok <- GenServer.stop(pid)
@@ -115,10 +114,12 @@ defmodule Nola.IRC.BasePlugin do
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()
+ brand = Nola.brand(:name)
+ owner = "#{Nola.brand(:owner)} <#{Nola.brand(:owner_email)}>"
message.replyfun.([
- <<"πŸ€– I am a robot running", 2, "beautte, version #{ver}", 2, " β€” source: #{Nola.source_url()}">>,
+ <<"πŸ€– I am a robot running", 2, "#{brand}, version #{ver}", 2, " β€” source: #{Nola.source_url()}">>,
"🦾 Elixir #{elixir_ver} #{otp_ver} on #{system}",
- "πŸ‘·β€β™€οΈ Owner: href <href@random.sh>",
+ "πŸ‘·β€β™€οΈ Owner: h#{owner}",
"🌍 Web interface: #{url}"
])
{:noreply, nil}
diff --git a/lib/nola_plugins/bourosama_plugin.ex b/lib/nola_plugins/boursorama.ex
index dd05144..f872584 100644
--- a/lib/nola_plugins/bourosama_plugin.ex
+++ b/lib/nola_plugins/boursorama.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.BoursoramaPlugin do
+defmodule Nola.Plugins.Boursorama do
def irc_doc() do
"""
diff --git a/lib/nola_plugins/buffer_plugin.ex b/lib/nola_plugins/buffer.ex
index eece34e..67aea35 100644
--- a/lib/nola_plugins/buffer_plugin.ex
+++ b/lib/nola_plugins/buffer.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.BufferPlugin do
+defmodule Nola.Plugins.Buffer do
@table __MODULE__.ETS
def irc_doc, do: nil
diff --git a/lib/nola_plugins/calc_plugin.ex b/lib/nola_plugins/calc.ex
index 264370c..91fbbae 100644
--- a/lib/nola_plugins/calc_plugin.ex
+++ b/lib/nola_plugins/calc.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.CalcPlugin do
+defmodule Nola.Plugins.Calc do
@moduledoc """
# calc
diff --git a/lib/nola_plugins/coronavirus_plugin.ex b/lib/nola_plugins/coronavirus.ex
index d04d8f9..624bae7 100644
--- a/lib/nola_plugins/coronavirus_plugin.ex
+++ b/lib/nola_plugins/coronavirus.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.CoronavirusPlugin do
+defmodule Nola.Plugins.Coronavirus do
require Logger
NimbleCSV.define(CovidCsv, separator: ",", escape: "\"")
@moduledoc """
diff --git a/lib/nola_plugins/correction_plugin.ex b/lib/nola_plugins/correction.ex
index 5f9b278..03968c8 100644
--- a/lib/nola_plugins/correction_plugin.ex
+++ b/lib/nola_plugins/correction.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.CorrectionPlugin do
+defmodule Nola.Plugins.Correction do
@moduledoc """
# correction
diff --git a/lib/nola_plugins/dice_plugin.ex b/lib/nola_plugins/dice.ex
index b5e7649..2c1515b 100644
--- a/lib/nola_plugins/dice_plugin.ex
+++ b/lib/nola_plugins/dice.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.DicePlugin do
+defmodule Nola.Plugins.Dice do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/finance_plugin.ex b/lib/nola_plugins/finance.ex
index 16d06ee..d6f890a 100644
--- a/lib/nola_plugins/finance_plugin.ex
+++ b/lib/nola_plugins/finance.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.FinancePlugin do
+defmodule Nola.Plugins.Finance do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/gpt_plugin.ex b/lib/nola_plugins/gpt.ex
index 2c8f182..3d2a66d 100644
--- a/lib/nola_plugins/gpt_plugin.ex
+++ b/lib/nola_plugins/gpt.ex
@@ -1,6 +1,6 @@
-defmodule Nola.IRC.GptPlugin do
+defmodule Nola.Plugins.Gpt do
require Logger
- import Irc.Plugin.TempRef
+ import Nola.Plugins.TempRefHelper
def irc_doc() do
"""
@@ -164,7 +164,7 @@ defmodule Nola.IRC.GptPlugin do
end
defp prompt(msg, prompt = %{"type" => "completions", "prompt" => prompt_template}, content, state) do
- Logger.debug("gpt_plugin:prompt/4 #{inspect prompt}")
+ Logger.debug("gpt:prompt/4 #{inspect prompt}")
prompt_text = case Map.get(prompt, "prompt_format", "liquid") do
"liquid" -> Tmpl.render(prompt_template, msg, Map.merge(Map.get(prompt, "prompt_liquid_variables", %{}), %{"content" => content}))
"norender" -> prompt_template
diff --git a/lib/nola_plugins/helpers/temp_ref.ex b/lib/nola_plugins/helpers/temp_ref.ex
new file mode 100644
index 0000000..160169d
--- /dev/null
+++ b/lib/nola_plugins/helpers/temp_ref.ex
@@ -0,0 +1,95 @@
+defmodule Nola.Plugins.TempRefHelper do
+ @moduledoc """
+ This module allows to easily implement local temporary simple references for easy access from IRC.
+
+ For example, your plugin output could be acted on, and instead of giving the burden for the user to
+ write or copy that uuid, you could give them a small alphanumeric reference to use instead.
+
+ You can configure how many and for how long the references are kept.
+
+ ## Usage
+
+ `import Irc.Plugin.TempRef`
+
+ ```elixir
+ defmodule Irc.MyPlugin do
+ defstruct [:temprefs]
+
+ def init(_) do
+ # …
+ {:ok, %__MODULE__{temprefs: new_temp_refs()}
+ end
+ end
+ ```
+ """
+
+ defstruct [:refs, :max, :expire, :build_fun, :build_increase_fun, :build_options]
+
+ defmodule SimpleAlphaNumericBuilder do
+ def build(options) do
+ length = Keyword.get(options, :length, 3)
+ for _ <- 1..length, into: "", do: <<Enum.random('bcdfghjkmpqtrvwxy2346789')>>
+ end
+
+ def increase(options) do
+ Keyword.put(options, :length, Keyword.get(options, :length, 3) + 1)
+ end
+ end
+
+ def new_temp_refs(options \\ []) do
+ %__MODULE__{
+ refs: Keyword.get(options, :init_refs, []),
+ max: Keyword.get(options, :max, []),
+ expire: Keyword.get(options, :expire, :infinity),
+ build_fun: Keyword.get(options, :build_fun, &__MODULE__.SimpleAlphaNumericBuilder.build/1),
+ build_increase_fun: Keyword.get(options, :build_increase_fun, &__MODULE__.SimpleAlphaNumericBuilder.increase/1),
+ build_options: Keyword.get(options, :build_options, [length: 3])
+ }
+ end
+
+ def janitor_refs(state = %__MODULE__{}) do
+ if length(state.refs) > state.max do
+ %__MODULE__{refs: state.refs |> Enum.reverse() |> tl() |> Enum.reverse()}
+ else
+ state
+ end
+ end
+
+ def put_temp_ref(data, state = %__MODULE__{}) do
+ state = janitor_refs(state)
+ key = new_nonexisting_key(state)
+ if key do
+ ref = {key, DateTime.utc_now(), data}
+ {key, %__MODULE__{state | refs: [ref | state.refs]}}
+ else
+ {nil, state}
+ end
+ end
+
+ def lookup_temp_ref(key, state, default \\ nil) do
+ case List.keyfind(state.refs, key, 0) do
+ {_, _, data} -> data
+ _ -> default
+ end
+ end
+
+ defp new_nonexisting_key(state, i) when i > 50 do
+ nil
+ end
+
+ defp new_nonexisting_key(state = %__MODULE__{refs: refs}, i \\ 1) do
+ build_options = if rem(i, 5) == 0 do
+ state.build_increase_fun.(state.build_options)
+ else
+ state.build_options
+ end
+
+ key = state.build_fun.(state.build_options)
+ if !List.keymember?(refs, key, 0) do
+ key
+ else
+ new_nonexisting_key(state, i + 1)
+ end
+ end
+
+end
diff --git a/lib/nola_plugins/kick_roulette_plugin.ex b/lib/nola_plugins/kick_roulette.ex
index 55b7da4..f6d2ba2 100644
--- a/lib/nola_plugins/kick_roulette_plugin.ex
+++ b/lib/nola_plugins/kick_roulette.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.KickRoulettePlugin do
+defmodule Nola.Plugins.KickRoulette do
@moduledoc """
# kick roulette
diff --git a/lib/nola_plugins/last_fm_plugin.ex b/lib/nola_plugins/last_fm.ex
index 03df675..1a9b7dd 100644
--- a/lib/nola_plugins/last_fm_plugin.ex
+++ b/lib/nola_plugins/last_fm.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.LastFmPlugin do
+defmodule Nola.Plugins.LastFm do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/link_plugin.ex b/lib/nola_plugins/link.ex
index dee78e8..381bdab 100644
--- a/lib/nola_plugins/link_plugin.ex
+++ b/lib/nola_plugins/link.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.LinkPlugin do
+defmodule Nola.Plugins.Link do
@moduledoc """
# Link Previewer
@@ -6,7 +6,7 @@ defmodule Nola.IRC.LinkPlugin do
To extend the supported sites, create a new handler implementing the callbacks.
- See `link_plugin/` directory for examples. The first in list handler that returns true to the `match/2` callback will be used,
+ See `link/` directory. The first in list handler that returns true to the `match/2` callback will be used,
and if the handler returns `:error` or crashes, will fallback to the default preview.
Unsupported websites will use the default link preview method, which is for html document the title, otherwise it'll use
@@ -15,13 +15,13 @@ defmodule Nola.IRC.LinkPlugin do
## Configuration:
```
- config :nola, Nola.IRC.LinkPlugin,
+ config :nola, Nola.Plugins.Link,
handlers: [
- Nola.IRC.LinkPlugin.Youtube: [
+ Nola.Plugins.Link.Youtube: [
invidious: true
],
- Nola.IRC.LinkPlugin.Twitter: [],
- Nola.IRC.LinkPlugin.Imgur: [],
+ Nola.Plugins.Link.Twitter: [],
+ Nola.Plugins.Link.Imgur: [],
]
```
diff --git a/lib/nola_plugins/link_plugin/github.ex b/lib/nola_plugins/link/github.ex
index 93e0892..0069a40 100644
--- a/lib/nola_plugins/link_plugin/github.ex
+++ b/lib/nola_plugins/link/github.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.Github do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.Github do
+ @behaviour Nola.Plugins.Link
@impl true
def match(uri = %URI{host: "github.com", path: path}, _) do
diff --git a/lib/nola_plugins/link_plugin/html.ex b/lib/nola_plugins/link/html.ex
index 56a8ceb..9b44319 100644
--- a/lib/nola_plugins/link_plugin/html.ex
+++ b/lib/nola_plugins/link/html.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.HTML do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.HTML do
+ @behaviour Nola.Plugins.Link
@impl true
def match(_, _), do: false
diff --git a/lib/nola_plugins/link_plugin/imgur.ex b/lib/nola_plugins/link/imgur.ex
index 5d74956..9fe9354 100644
--- a/lib/nola_plugins/link_plugin/imgur.ex
+++ b/lib/nola_plugins/link/imgur.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.Imgur do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.Imgur do
+ @behaviour Nola.Plugins.Link
@moduledoc """
# Imgur link preview
diff --git a/lib/nola_plugins/link_plugin/pdf.ex b/lib/nola_plugins/link/pdf.ex
index 5f72ef5..e91dcc2 100644
--- a/lib/nola_plugins/link_plugin/pdf.ex
+++ b/lib/nola_plugins/link/pdf.ex
@@ -1,6 +1,6 @@
-defmodule Nola.IRC.LinkPlugin.PDF do
+defmodule Nola.Plugins.Link.PDF do
require Logger
- @behaviour Nola.IRC.LinkPlugin
+ @behaviour Nola.Plugins.Link
@impl true
def match(_, _), do: false
diff --git a/lib/nola_plugins/link_plugin/redacted.ex b/lib/nola_plugins/link/redacted.ex
index 7a6229d..a7cfe74 100644
--- a/lib/nola_plugins/link_plugin/redacted.ex
+++ b/lib/nola_plugins/link/redacted.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.Redacted do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.Redacted do
+ @behaviour Nola.Plugins.Link
@impl true
def match(uri = %URI{host: "redacted.ch", path: "/torrent.php", query: query = "id="<>id}, _opts) do
diff --git a/lib/nola_plugins/link_plugin/reddit.ex b/lib/nola_plugins/link/reddit.ex
index 79102e0..016e025 100644
--- a/lib/nola_plugins/link_plugin/reddit.ex
+++ b/lib/nola_plugins/link/reddit.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.Reddit do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.Reddit do
+ @behaviour Nola.Plugins.Link
@impl true
def match(uri = %URI{host: "reddit.com", path: path}, _) do
diff --git a/lib/nola_plugins/link_plugin/twitter.ex b/lib/nola_plugins/link/twitter.ex
index 640b193..e7f3e63 100644
--- a/lib/nola_plugins/link_plugin/twitter.ex
+++ b/lib/nola_plugins/link/twitter.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.Twitter do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.Twitter do
+ @behaviour Nola.Plugins.Link
@moduledoc """
# Twitter Link Preview
diff --git a/lib/nola_plugins/link_plugin/youtube.ex b/lib/nola_plugins/link/youtube.ex
index f7c7541..1b14221 100644
--- a/lib/nola_plugins/link_plugin/youtube.ex
+++ b/lib/nola_plugins/link/youtube.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.LinkPlugin.YouTube do
- @behaviour Nola.IRC.LinkPlugin
+defmodule Nola.Plugins.Link.YouTube do
+ @behaviour Nola.Plugins.Link
@moduledoc """
# YouTube link preview
diff --git a/lib/nola_plugins/logger_plugin.ex b/lib/nola_plugins/logger.ex
index b13f33a..69cac66 100644
--- a/lib/nola_plugins/logger_plugin.ex
+++ b/lib/nola_plugins/logger.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.LoggerPlugin do
+defmodule Nola.Plugins.Logger do
require Logger
@couch_db "bot-logs"
@@ -13,6 +13,7 @@ defmodule Nola.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, "messages:telegram", regopts)
{:ok, _} = Registry.register(IRC.PubSub, "irc:outputs", regopts)
{:ok, _} = Registry.register(IRC.PubSub, "messages:private", regopts)
{:ok, nil}
diff --git a/lib/nola_plugins/outline_plugin.ex b/lib/nola_plugins/outline.ex
index 820500e..f0ccfd2 100644
--- a/lib/nola_plugins/outline_plugin.ex
+++ b/lib/nola_plugins/outline.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.OutlinePlugin do
+defmodule Nola.Plugins.Outline do
@moduledoc """
# outline auto-link
diff --git a/lib/nola_plugins/preums_plugin.ex b/lib/nola_plugins/preums.ex
index f250e85..80c5af0 100644
--- a/lib/nola_plugins/preums_plugin.ex
+++ b/lib/nola_plugins/preums.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.PreumsPlugin do
+defmodule Nola.Plugins.Preums do
@moduledoc """
# preums !!!
@@ -229,7 +229,7 @@ defmodule Nola.IRC.PreumsPlugin do
end
defp timezone(channel) do
- env = Application.get_env(:nola, Nola.IRC.PreumsPlugin, [])
+ env = Application.get_env(:nola, Nola.Plugins.Preums, [])
channels = Keyword.get(env, :channels, %{})
channel_settings = Map.get(channels, channel, [])
default = Keyword.get(env, :default_tz, "Europe/Paris")
diff --git a/lib/nola_plugins/quatre_cent_vingt_plugin.ex b/lib/nola_plugins/quatre_cent_vingt.ex
index 8953ea3..3331625 100644
--- a/lib/nola_plugins/quatre_cent_vingt_plugin.ex
+++ b/lib/nola_plugins/quatre_cent_vingt.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.QuatreCentVingtPlugin do
+defmodule Nola.Plugins.QuatreCentVingt do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/radio_france_plugin.ex b/lib/nola_plugins/radio_france.ex
index c2e966f..2096de8 100644
--- a/lib/nola_plugins/radio_france_plugin.ex
+++ b/lib/nola_plugins/radio_france.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.RadioFrancePlugin do
+defmodule Nola.Plugins.RadioFrance do
require Logger
def irc_doc() do
diff --git a/lib/nola_plugins/say_plugin.ex b/lib/nola_plugins/say.ex
index 915b0f6..91ffacc 100644
--- a/lib/nola_plugins/say_plugin.ex
+++ b/lib/nola_plugins/say.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.SayPlugin do
+defmodule Nola.Plugins.Say do
def irc_doc do
"""
diff --git a/lib/nola_plugins/script_plugin.ex b/lib/nola_plugins/script.ex
index 94d4edf..d383abb 100644
--- a/lib/nola_plugins/script_plugin.ex
+++ b/lib/nola_plugins/script.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.ScriptPlugin do
+defmodule Nola.Plugins.Script do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/seen_plugin.ex b/lib/nola_plugins/seen.ex
index 2a4d0dd..65af0c1 100644
--- a/lib/nola_plugins/seen_plugin.ex
+++ b/lib/nola_plugins/seen.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.SeenPlugin do
+defmodule Nola.Plugins.Seen do
@moduledoc """
# seen
diff --git a/lib/nola_plugins/sms_plugin.ex b/lib/nola_plugins/sms.ex
index d8f7387..ad16f78 100644
--- a/lib/nola_plugins/sms_plugin.ex
+++ b/lib/nola_plugins/sms.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.SmsPlugin do
+defmodule Nola.Plugins.Sms do
@moduledoc """
## sms
diff --git a/lib/nola_plugins/tell_plugin.ex b/lib/nola_plugins/tell.ex
index ecc98df..8978c82 100644
--- a/lib/nola_plugins/tell_plugin.ex
+++ b/lib/nola_plugins/tell.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.TellPlugin do
+defmodule Nola.Plugins.Tell do
use GenServer
@moduledoc """
diff --git a/lib/nola_plugins/txt_plugin.ex b/lib/nola_plugins/txt.ex
index cab912a..f6e71a3 100644
--- a/lib/nola_plugins/txt_plugin.ex
+++ b/lib/nola_plugins/txt.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.TxtPlugin do
+defmodule Nola.Plugins.Txt do
alias IRC.UserTrack
require Logger
@@ -55,7 +55,7 @@ defmodule Nola.IRC.TxtPlugin do
def init([]) do
dets_locks_filename = (Nola.data_path() <> "/" <> "txtlocks.dets") |> String.to_charlist
{:ok, locks} = :dets.open_file(dets_locks_filename, [])
- markov_handler = Keyword.get(Application.get_env(:nola, __MODULE__, []), :markov_handler, Nola.IRC.TxtPlugin.Markov.Native)
+ markov_handler = Keyword.get(Application.get_env(:nola, __MODULE__, []), :markov_handler, Nola.Plugins.Txt.Markov.Native)
{:ok, markov} = markov_handler.start_link()
{:ok, _} = Registry.register(IRC.PubSub, "triggers", [plugin: __MODULE__])
{:ok, %__MODULE__{locks: locks, markov_handler: markov_handler, markov: markov, triggers: load()}}
diff --git a/lib/nola_plugins/txt_plugin/markov.ex b/lib/nola_plugins/txt/markov.ex
index 2e30dfa..b47666c 100644
--- a/lib/nola_plugins/txt_plugin/markov.ex
+++ b/lib/nola_plugins/txt/markov.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.TxtPlugin.Markov do
+defmodule Nola.Plugins.Txt.Markov do
@type state :: any()
@callback start_link() :: {:ok, state()}
diff --git a/lib/nola_plugins/txt_plugin/markov_native.ex b/lib/nola_plugins/txt/markov_native.ex
index 4c403c2..aa6b454 100644
--- a/lib/nola_plugins/txt_plugin/markov_native.ex
+++ b/lib/nola_plugins/txt/markov_native.ex
@@ -1,5 +1,5 @@
-defmodule Nola.IRC.TxtPlugin.MarkovNative do
- @behaviour Nola.IRC.TxtPlugin.Markov
+defmodule Nola.Plugins.Txt.MarkovNative do
+ @behaviour Nola.Plugins.Txt.Markov
def start_link() do
ExChain.MarkovModel.start_link()
diff --git a/lib/nola_plugins/txt_plugin/markov_py_markovify.ex b/lib/nola_plugins/txt/markov_py_markovify.ex
index b610ea8..f79ed47 100644
--- a/lib/nola_plugins/txt_plugin/markov_py_markovify.ex
+++ b/lib/nola_plugins/txt/markov_py_markovify.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.TxtPlugin.MarkovPyMarkovify do
+defmodule Nola.Plugins.Txt.MarkovPyMarkovify do
def start_link() do
{:ok, nil}
@@ -18,7 +18,7 @@ defmodule Nola.IRC.TxtPlugin.MarkovPyMarkovify do
defp run(args \\ []) do
{binary, script} = script()
- args = [script, Path.expand(Nola.IRC.TxtPlugin.directory()) | args]
+ args = [script, Path.expand(Nola.Plugins.Txt.directory()) | args]
IO.puts "Args #{inspect args}"
case MuonTrap.cmd(binary, args) do
{response, 0} -> response
@@ -28,7 +28,7 @@ defmodule Nola.IRC.TxtPlugin.MarkovPyMarkovify do
defp script() do
default_script = to_string(:code.priv_dir(:nola)) <> "/irc/txt/markovify.py"
- env = Application.get_env(:nola, Nola.IRC.TxtPlugin, [])
+ env = Application.get_env(:nola, Nola.Plugins.Txt, [])
|> Keyword.get(:py_markovify, [])
{Keyword.get(env, :python, "python3"), Keyword.get(env, :script, default_script)}
diff --git a/lib/nola_plugins/untappd_plugin.ex b/lib/nola_plugins/untappd.ex
index 50b0c4d..cf5c694 100644
--- a/lib/nola_plugins/untappd_plugin.ex
+++ b/lib/nola_plugins/untappd.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.UntappdPlugin do
+defmodule Nola.Plugins.Untappd do
def irc_doc() do
"""
diff --git a/lib/nola_plugins/user_mention_plugin.ex b/lib/nola_plugins/user_mention.ex
index eb230fd..c4dd719 100644
--- a/lib/nola_plugins/user_mention_plugin.ex
+++ b/lib/nola_plugins/user_mention.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.UserMentionPlugin do
+defmodule Nola.Plugins.UserMention do
@moduledoc """
# mention
@@ -33,11 +33,11 @@ defmodule Nola.IRC.UserMentionPlugin do
telegram ->
Nola.Telegram.send_message(telegram, "`#{channel}` <**#{sender.nick}**> #{Enum.join(content, " ")}")
sms ->
- case Nola.IRC.SmsPlugin.send_sms(sms, text) do
+ case Nola.Plugins.Sms.send_sms(sms, text) do
{:error, code} -> message.replyfun("#{sender.nick}: erreur #{code} (sms)")
end
true ->
- Nola.IRC.TellPlugin.tell(message, nick, content)
+ Nola.Plugins.Tell.tell(message, nick, content)
end
else
message.replyfun.("#{nick} m'est inconnu")
diff --git a/lib/nola_plugins/wikipedia_plugin.ex b/lib/nola_plugins/wikipedia.ex
index 3202e13..dcd1874 100644
--- a/lib/nola_plugins/wikipedia_plugin.ex
+++ b/lib/nola_plugins/wikipedia.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.WikipediaPlugin do
+defmodule Nola.Plugins.Wikipedia do
require Logger
@moduledoc """
diff --git a/lib/nola_plugins/wolfram_alpha_plugin.ex b/lib/nola_plugins/wolfram_alpha.ex
index 6ee06f0..c2f106e 100644
--- a/lib/nola_plugins/wolfram_alpha_plugin.ex
+++ b/lib/nola_plugins/wolfram_alpha.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.WolframAlphaPlugin do
+defmodule Nola.Plugins.WolframAlpha do
use GenServer
require Logger
diff --git a/lib/nola_plugins/youtube_plugin.ex b/lib/nola_plugins/youtube.ex
index fb9bea2..c62f73c 100644
--- a/lib/nola_plugins/youtube_plugin.ex
+++ b/lib/nola_plugins/youtube.ex
@@ -1,4 +1,4 @@
-defmodule Nola.IRC.YouTubePlugin do
+defmodule Nola.Plugins.YouTube do
require Logger
@moduledoc """