refactor: add irc.MessageType custom type with Name() and String() methods
All checks were successful
check / check (push) Successful in 2m28s

- Create 'type MessageType int' in pkg/irc/numerics.go
- Type all Rpl*/Err* numeric constants as MessageType
- Add Name() method returning the standard IRC name (e.g. RPL_WELCOME)
- Add String() method returning zero-padded numeric (e.g. 001)
- Update enqueueNumeric/respondIRCError to accept MessageType
- Update internal/db to use MessageType conversion for Name() calls
- Change names map key type from int to MessageType

Refs #52
This commit is contained in:
clawbot
2026-03-10 10:17:57 -07:00
parent fa347772f2
commit 164fec3fc8
3 changed files with 171 additions and 153 deletions

View File

@@ -398,12 +398,12 @@ func (hdlr *Handlers) serverName() string {
func (hdlr *Handlers) enqueueNumeric(
ctx context.Context,
clientID int64,
code int,
code irc.MessageType,
nick string,
params []string,
text string,
) {
command := fmt.Sprintf("%03d", code)
command := code.String()
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 int,
code irc.MessageType,
nick string,
params []string,
text string,