lrstanley / girc

:bomb: girc is a flexible IRC library for Go :ok_hand:
https://pkg.go.dev/github.com/lrstanley/girc
MIT License
137 stars 13 forks source link

Preliminary support for the MONITOR command #22

Closed nmeum closed 5 years ago

nmeum commented 5 years ago

This commit adds support for the IRCv3.2 MONITOR command [1]. This includes a new function for sending MONITOR commands to the IRC server and constants for creating handlers for the server responses.


Discussion: Currently no fancy abstraction is offered for the MONITOR command. Meaning the caller can:

  1. Send MONITOR commands to the server with invalid modifier, where modifier ∉ {+, -, C, L, S}.
  2. Add a target to the list of targets being monitored which is already in that list. Which the client MUST NOT do according to the specification.

Both 1. and 2. could be addressed by implementing separate functions for the different MONITOR command modifiers (e.g. MonitorAdd(), MonitorDel(), …) and performing more sanity checks in those functions. If 2. is not considered an issue and should be resolved by the caller 1. could alternatively by defining a new type for the modifier.

An entirely different solution would be adding methods for monitoring to the User struct. For example: User.Monitor(), User.Unmonitor(), ….

codecov-io commented 5 years ago

Codecov Report

Merging #22 into master will increase coverage by 0.03%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #22      +/-   ##
=========================================
+ Coverage   56.07%   56.1%   +0.03%     
=========================================
  Files          13      13              
  Lines        2331    2333       +2     
=========================================
+ Hits         1307    1309       +2     
- Misses        917     918       +1     
+ Partials      107     106       -1
Impacted Files Coverage Δ
commands.go 0% <0%> (ø) :arrow_up:
conn.go 59.83% <0%> (+0.81%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 618b325...402df2d. Read the comment docs.

nmeum commented 5 years ago

As for other methods, will have to give it a bit more thought.

I guess we could just merge it as is and improve the API later on?