summaryrefslogtreecommitdiff
path: root/lib/lsg_irc/kick_roulette_handler.ex
blob: 7bfa90b7ed35a9927ae9cd1b331c5acc7869be8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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