summaryrefslogtreecommitdiff
path: root/lib/nola_plugins/kick_roulette_plugin.ex
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-20 00:21:54 +0000
committerJordan Bracco <href@random.sh>2022-12-20 19:29:41 +0100
commit2d83df8b32bff7f0028923bb5b64dc0b55f20d03 (patch)
tree1207e67b5b15f540963db05e7be89f3ca950e724 /lib/nola_plugins/kick_roulette_plugin.ex
parentNola rename, the end. pt 6. Refs T77. (diff)
Nola rename: The Big Move, Refs T77
Diffstat (limited to 'lib/nola_plugins/kick_roulette_plugin.ex')
-rw-r--r--lib/nola_plugins/kick_roulette_plugin.ex32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/nola_plugins/kick_roulette_plugin.ex b/lib/nola_plugins/kick_roulette_plugin.ex
new file mode 100644
index 0000000..55b7da4
--- /dev/null
+++ b/lib/nola_plugins/kick_roulette_plugin.ex
@@ -0,0 +1,32 @@
+defmodule Nola.IRC.KickRoulettePlugin do
+ @moduledoc """
+ # kick roulette
+
+ * **!kick**, tentez votre chanceā€¦
+ """
+
+ def irc_doc, do: @moduledoc
+ def start_link() do
+ GenServer.start_link(__MODULE__, [], name: __MODULE__)
+ end
+
+ def init([]) do
+ {:ok, _} = Registry.register(IRC.PubSub, "trigger:kick", [plugin: __MODULE__])
+ {:ok, nil}
+ end
+
+ def handle_info({:irc, :trigger, "kick", message = %{trigger: %{type: :bang, args: []}}}, _) do
+ if 5 == :crypto.rand_uniform(1, 6) do
+ spawn(fn() ->
+ :timer.sleep(:crypto.rand_uniform(200, 10_000))
+ message.replyfun.({:kick, message.sender.nick, "perdu"})
+ end)
+ end
+ {:noreply, nil}
+ end
+
+ def handle_info(msg, _) do
+ {:noreply, nil}
+ end
+
+end