Skip to content

Commit

Permalink
encapsulate the results in a list of structs
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Jan 19, 2018
1 parent 7802cd8 commit 2b2de8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/exirc/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,11 @@ defmodule ExIRC.Client do
end

def handle_data(%ExIRC.Message{:cmd => "315", :args => [_, channel, _]}, state) do
buffer = Map.get(state.who_buffers, channel, [])
buffer = state
|> Map.get(:who_buffers)
|> Map.get(channel)
|> Enum.map(fn user -> struct(ExIRC.Who, user) end)

send_event {:who, channel, buffer}, state
{:noreply, %ClientState{state | who_buffers: Map.delete(state.who_buffers, channel)}}
end
Expand Down
12 changes: 10 additions & 2 deletions lib/exirc/who.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
defmodule ExIRC.Who do

defstruct [name: nil,
defstruct [
admin?: nil,
away?: nil,
founder?: nil,
half_operator?: nil,
hops: nil,
name: nil,
nickname: nil,
operator?: nil,
server: nil,
user: nil
server_operator?: nil,
user: nil,
voiced?: nil
]
end

0 comments on commit 2b2de8b

Please sign in to comment.