Implementation of Whois feature.#74
Implementation of Whois feature.#74bitwalker merged 3 commits intobitwalker:masterfrom tchoutri:add-whois
Conversation
|
@tchoutri This looks like a good PR, but I have just a few thoughts on it: It would be even better with documentation: in the code itself, the examples directory (i.e, showing how to use the WHOIS function), and in the README perhaps, but the examples directory might cover that.. now I think about it. The code itself looks good, but I'm not sure how to use it. I'll have another play when I get some more time. Good work though, although I'm not the maintainer, I've contributed before, and it certainly looks neater than my contributions 👍 |
| {:noreply, %ClientState{state|whois_buffers: Map.put(state.whois_buffers, nickname, user)}} | ||
| end | ||
|
|
||
| def handle_data(%IrcMessage{cmd: @rpl_whoiscertfp, args: [_sender, nickname, "has client certificate fingerprint "<> fingerprint]}, state) do |
There was a problem hiding this comment.
Are we certain this text is standardized? It seems really fragile to match on it like this (though I'm not sure there is a better approach).
lib/exirc/client.ex
Outdated
| {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nickname, :registered_nick?], true)}} | ||
| end | ||
|
|
||
| def handle_data(%IrcMessage{cmd: @rpl_whoishelpop, args: [_sender, nickname, "is available for help."]}, state) do |
There was a problem hiding this comment.
Same thing about the text matching
lib/exirc/client.ex
Outdated
| end | ||
|
|
||
| def handle_data(%IrcMessage{cmd: @rpl_whoisserver, args: [_sender, nickname, server_addr, server_name]}, state) do | ||
| new_buffer = state.whois_buffers |> put_in([nickname, :server_name], server_name) |> put_in([nickname, :server_address], server_addr) |
There was a problem hiding this comment.
can we change the formatting here to:
new_buffer =
state.whois_buffers
|> put_in(...)
...
bitwalker
left a comment
There was a problem hiding this comment.
My main concern is that we're matching on text messages in handle_data a lot, is that necessary when we have the RPL code to match on?
Otherwise looks good!
|
Yes, in some cases, we will need to have the text to make the distinction between, for instance, However, after some reflexion, I suggest we deal with those on a case-by-case basis. :) |
Summary of the changes
Hi @bitwalker! I have made the following changes in the code base:
handle_datafunctions to catch the messagesIrc.Commands, except for@rpl_whoismodesthat I have not encountered yet.whois_bufferskey in%ClientStateto store the intermediate results.%Irc.Whois{}struct to enforce the authorized keys and ensure data integrity and document the available fields.String.stripandString.to_char_list.