summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/kick_roulette_handler.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-02-17 21:21:42 +0100
committerhref <href@random.sh>2018-02-17 21:21:42 +0100
commit50c6a09ff64cb081b27a0c30790b86873449d172 (patch)
treeba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc/kick_roulette_handler.ex
parenttxt: fix against malicious filenames (aka 'fuck you shiv') (diff)
:)
Diffstat (limited to 'lib/lsg_irc/kick_roulette_handler.ex')
-rw-r--r--lib/lsg_irc/kick_roulette_handler.ex29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/lsg_irc/kick_roulette_handler.ex b/lib/lsg_irc/kick_roulette_handler.ex
new file mode 100644
index 0000000..7bfa90b
--- /dev/null
+++ b/lib/lsg_irc/kick_roulette_handler.ex
@@ -0,0 +1,29 @@
+defmodule LSG.IRC.KickRouletteHandler do
+ @moduledoc """
+ # kick roulette
+
+ * **!kick** (à peu près une chance sur 5)
+ """
+
+ def irc_doc, do: @moduledoc
+ def start_link(client) do
+ GenServer.start_link(__MODULE__, [client])
+ end
+
+ def init([client]) do
+ ExIRC.Client.add_handler client, self
+ {:ok, client}
+ end
+
+ def handle_info({:received, "!kick", sender, chan}, client) do
+ if 5 == :crypto.rand_uniform(1, 6) do
+ ExIRC.Client.kick(client, chan, sender.nick, "perdu")
+ end
+ {:noreply, client}
+ end
+
+ def handle_info(msg, client) do
+ {:noreply, client}
+ end
+
+end