diff options
author | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
---|---|---|
committer | href <href@random.sh> | 2018-02-17 21:21:42 +0100 |
commit | 50c6a09ff64cb081b27a0c30790b86873449d172 (patch) | |
tree | ba1bebfc7e367f169276692e0ac02709d62d6516 /lib/lsg_irc/kick_roulette_handler.ex | |
parent | txt: 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.ex | 29 |
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 |