defmodule LSG.IRC.KickRouletteHandler do @moduledoc """ # kick roulette * **!kick** """ 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 spawn(fn() -> :timer.sleep(:crypto.rand_uniform(200, 10_000)) ExIRC.Client.kick(client, chan, sender.nick, "perdu") end) end {:noreply, client} end def handle_info(msg, client) do {:noreply, client} end end