Skip to content
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

Implement NAMES command #25

Open
progval opened this issue Jun 26, 2022 · 0 comments
Open

Implement NAMES command #25

progval opened this issue Jun 26, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@progval
Copy link
Owner

progval commented Jun 26, 2022

It should be a simple matter of re-using this code in lib/irc/handler.ex:

# send RPL_NAMREPLY
overhead = make_numeric.("353", ["=", channel, ""]) |> M51.Irc.Command.format() |> byte_size()
# note for later: if we ever implement prefixes, make sure to add them
# *after* calling nick2nuh; we don't want to have prefixes in the username part.
M51.MatrixClient.State.room_members(state, room_id)
|> Enum.map(fn {user_id, _member} ->
nuh = nick2nuh(user_id)
# M51.Irc.Command does not escape " " in trailing
String.replace(nuh, " ", "\\s") <> " "
end)
|> Enum.sort()
|> M51.Irc.WordWrap.join_tokens(512 - overhead)
|> Enum.map(fn line ->
line = line |> String.trim_trailing()
if line != "" do
# RPL_NAMREPLY
send_numeric.("353", ["=", channel, line])
end
end)
# RPL_ENDOFNAMES
send_numeric.("366", [channel, "End of /NAMES list"])

Suggested by @Thaodan in #14 (comment)

@progval progval added enhancement New feature or request good first issue Good for newcomers labels Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant