summaryrefslogtreecommitdiff
path: root/lib/irc/client/command/names.ex
blob: b5a84a6258c551454918cf464dae6dfba3c72cc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
defmodule Irc.Client.Command.Names do
  alias Irc.Parser.Line
  require Irc.Parser.Numeric
  import Irc.Parser.Numeric

  def init() do
    {[rpl_NAMREPLY(), rpl_ENDOFNAMES()], :names, ["userhost-in-names"]}
  end

  def handle_line(%Line{command: rpl_NAMREPLY()}) do
    :buffer
  end

  def handle_line(%Line{command: rpl_ENDOFNAMES(), args: [_, target | _]}) do
    :finish
  end

  def handle_buffer(buffer = [%Line{args: [_, target | _]} | _]) do
    {:event, {:names, target, buffer}}
  end

end