-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of Whois feature. #74
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change the formatting here to:
new_buffer =
state.whois_buffers
|> put_in(...)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_data
functions to catch the messagesIrc.Commands
, except for@rpl_whoismodes
that I have not encountered yet.whois_buffers
key in%ClientState
to store the intermediate results.%Irc.Whois{}
struct to enforce the authorized keys and ensure data integrity and document the available fields.String.strip
andString.to_char_list
.