summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/kick_roulette_handler.ex
diff options
context:
space:
mode:
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