defmodule Irc.Client.Command.Names do alias Irc.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