refactor: rename MessageType to IRCMessageType with full API
All checks were successful
check / check (push) Successful in 4s
All checks were successful
check / check (push) Successful in 4s
- Rename MessageType to IRCMessageType (custom int type) - .Name() returns just the name (e.g. "RPL_LUSEROP") - .String() returns name + code (e.g. "RPL_LUSEROP <252>") - .Code() returns zero-padded 3-digit string (e.g. "252") - .Int() returns the bare int value - Add FromInt() package-level function with validation - Update all call sites to use new type and methods
This commit is contained in:
@@ -746,8 +746,8 @@ func scanMessages(
|
||||
code, _ := strconv.Atoi(msg.Command)
|
||||
msg.Code = code
|
||||
|
||||
if name := irc.Name(irc.MessageType(code)); name != "" {
|
||||
msg.Command = name
|
||||
if mt, err := irc.FromInt(code); err == nil {
|
||||
msg.Command = mt.Name()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -398,12 +398,12 @@ func (hdlr *Handlers) serverName() string {
|
||||
func (hdlr *Handlers) enqueueNumeric(
|
||||
ctx context.Context,
|
||||
clientID int64,
|
||||
code irc.MessageType,
|
||||
code irc.IRCMessageType,
|
||||
nick string,
|
||||
params []string,
|
||||
text string,
|
||||
) {
|
||||
command := code.String()
|
||||
command := code.Code()
|
||||
|
||||
body, err := json.Marshal([]string{text})
|
||||
if err != nil {
|
||||
@@ -969,7 +969,7 @@ func (hdlr *Handlers) respondIRCError(
|
||||
writer http.ResponseWriter,
|
||||
request *http.Request,
|
||||
clientID, sessionID int64,
|
||||
code irc.MessageType,
|
||||
code irc.IRCMessageType,
|
||||
nick string,
|
||||
params []string,
|
||||
text string,
|
||||
|
||||
Reference in New Issue
Block a user