diff options
Diffstat (limited to '')
-rw-r--r-- | lib/lsg_irc/alcolog_plugin.ex | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/lsg_irc/alcolog_plugin.ex b/lib/lsg_irc/alcolog_plugin.ex index 35aa206..290be50 100644 --- a/lib/lsg_irc/alcolog_plugin.ex +++ b/lib/lsg_irc/alcolog_plugin.ex @@ -32,6 +32,7 @@ defmodule LSG.IRC.AlcoologPlugin do * mauvaises boissons: `alcoolog.drink_(negative|zero|negative)` * santo: `alcoolog.santo` * santai: `alcoolog.santai` + * plus gros, moins gros: `alcoolog.(fatter|thinner)` """ @@ -43,6 +44,8 @@ defmodule LSG.IRC.AlcoologPlugin do # tuple ets: {{nick, date}, volumes, current, nom, commentaire} # tuple meta dets: {nick, map} # %{:weight => float, :sex => true(h),false(f)} + @pubsub ~w(account) + @pubsub_triggers ~w(santai moar again bis santo santeau alcoolog sobre sobrepour soif alcoolisme alcool) @default_user_meta %{weight: 77.4, sex: true, loss_factor: 15} def data_state() do @@ -52,20 +55,10 @@ defmodule LSG.IRC.AlcoologPlugin do end def init(_) do - regopts = [plugin: __MODULE__] - {:ok, _} = Registry.register(IRC.PubSub, "account", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:santai", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:moar", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:again", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:bis", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:santo", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:santeau", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:alcoolog", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:sobre", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:sobrepour", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:soif", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:alcoolisme", regopts) - {:ok, _} = Registry.register(IRC.PubSub, "trigger:alcool", regopts) + triggers = for(t <- @pubsub_triggers, do: "trigger:"<>t) + for sub <- @pubsub ++ triggers do + {:ok, _} = Registry.register(IRC.PubSub, "account", plugin: __MODULE__) + end dets_filename = (LSG.data_path() <> "/" <> "alcoolisme.dets") |> String.to_charlist {:ok, dets} = :dets.open_file(dets_filename, [{:type,:bag}]) ets = :ets.new(__MODULE__.ETS, [:ordered_set, :named_table, :protected, {:read_concurrency, true}]) |