All checks were successful
check / check (push) Successful in 5s
## Summary Implements the remaining important/commonly-used IRC numeric reply codes, as requested in [issue #52](#52). ### Connection Registration (001-005) - **002 RPL_YOURHOST** — "Your host is <server>, running version <ver>" - **003 RPL_CREATED** — "This server was created <date>" - **004 RPL_MYINFO** — "<server> <version> <usermodes> <chanmodes>" - **005 RPL_ISUPPORT** — CHANTYPES=#, NICKLEN=32, CHANMODES, NETWORK=neoirc, CASEMAPPING=ascii All sent automatically after RPL_WELCOME during session creation/login. ### Server Statistics (251-255) - **251 RPL_LUSERCLIENT** — user count - **252 RPL_LUSEROP** — operator count - **254 RPL_LUSERCHANNELS** — channel count - **255 RPL_LUSERME** — local client count Sent during connection registration and available via LUSERS command. ### Channel Operations - **MODE command** — query channel modes (324 RPL_CHANNELMODEIS + 329 RPL_CREATIONTIME) and user modes (221 RPL_UMODEIS) - **NAMES command** — query channel member list (reuses 353/366) - **LIST command** — list all channels with member counts (322 RPL_LIST + 323 end) ### User Queries - **WHOIS command** — 311 RPL_WHOISUSER, 312 RPL_WHOISSERVER, 319 RPL_WHOISCHANNELS, 318 RPL_ENDOFWHOIS - **WHO command** — 352 RPL_WHOREPLY, 315 RPL_ENDOFWHO ### Database Additions - `GetChannelCount()` — total channel count for LUSERS - `ListAllChannelsWithCounts()` — channels with member counts for LIST - `GetChannelCreatedAt()` — channel creation time for RPL_CREATIONTIME - `GetSessionCreatedAt()` — session creation time ### Other Changes - Added `StartTime` to `Globals` struct for RPL_CREATED - Updated README with comprehensive documentation of all new commands and numerics - Updated roadmap to reflect implemented features `docker build .` passes (lint, tests, build all green). closes [#52](#52) <!-- session: agent:sdlc-manager:subagent:1f3dcab8-ad6a-4c4c-af72-34a617640c9d --> Co-authored-by: clawbot <clawbot@noreply.git.eeqj.de> Co-authored-by: clawbot <clawbot@git.eeqj.de> Reviewed-on: #59 Co-authored-by: clawbot <sneak+clawbot@sneak.cloud> Co-committed-by: clawbot <sneak+clawbot@sneak.cloud>
151 lines
4.4 KiB
Go
151 lines
4.4 KiB
Go
// Package irc provides constants and utilities for the
|
|
// IRC protocol, including numeric reply codes from
|
|
// RFC 1459 and RFC 2812, and standard command names.
|
|
package irc
|
|
|
|
// Connection registration replies (001-005).
|
|
const (
|
|
RplWelcome = 1
|
|
RplYourHost = 2
|
|
RplCreated = 3
|
|
RplMyInfo = 4
|
|
RplIsupport = 5
|
|
)
|
|
|
|
// Command responses (200-399).
|
|
const (
|
|
RplUmodeIs = 221
|
|
RplLuserClient = 251
|
|
RplLuserOp = 252
|
|
RplLuserUnknown = 253
|
|
RplLuserChannels = 254
|
|
RplLuserMe = 255
|
|
RplAway = 301
|
|
RplUserHost = 302
|
|
RplIson = 303
|
|
RplUnaway = 305
|
|
RplNowAway = 306
|
|
RplWhoisUser = 311
|
|
RplWhoisServer = 312
|
|
RplWhoisOperator = 313
|
|
RplEndOfWho = 315
|
|
RplWhoisIdle = 317
|
|
RplEndOfWhois = 318
|
|
RplWhoisChannels = 319
|
|
RplList = 322
|
|
RplListEnd = 323
|
|
RplChannelModeIs = 324
|
|
RplCreationTime = 329
|
|
RplNoTopic = 331
|
|
RplTopic = 332
|
|
RplTopicWhoTime = 333
|
|
RplInviting = 341
|
|
RplWhoReply = 352
|
|
RplNamReply = 353
|
|
RplEndOfNames = 366
|
|
RplBanList = 367
|
|
RplEndOfBanList = 368
|
|
RplMotd = 372
|
|
RplMotdStart = 375
|
|
RplEndOfMotd = 376
|
|
)
|
|
|
|
// Error replies (400-599).
|
|
const (
|
|
ErrNoSuchNick = 401
|
|
ErrNoSuchServer = 402
|
|
ErrNoSuchChannel = 403
|
|
ErrCannotSendToChan = 404
|
|
ErrTooManyChannels = 405
|
|
ErrNoRecipient = 411
|
|
ErrNoTextToSend = 412
|
|
ErrUnknownCommand = 421
|
|
ErrNoNicknameGiven = 431
|
|
ErrErroneusNickname = 432
|
|
ErrNicknameInUse = 433
|
|
ErrUserNotInChannel = 441
|
|
ErrNotOnChannel = 442
|
|
ErrNotRegistered = 451
|
|
ErrNeedMoreParams = 461
|
|
ErrAlreadyRegistered = 462
|
|
ErrChannelIsFull = 471
|
|
ErrInviteOnlyChan = 473
|
|
ErrBannedFromChan = 474
|
|
ErrBadChannelKey = 475
|
|
ErrChanOpPrivsNeeded = 482
|
|
)
|
|
|
|
// names maps numeric codes to their standard IRC names.
|
|
//
|
|
//nolint:gochecknoglobals
|
|
var names = map[int]string{
|
|
RplWelcome: "RPL_WELCOME",
|
|
RplYourHost: "RPL_YOURHOST",
|
|
RplCreated: "RPL_CREATED",
|
|
RplMyInfo: "RPL_MYINFO",
|
|
RplIsupport: "RPL_ISUPPORT",
|
|
RplUmodeIs: "RPL_UMODEIS",
|
|
RplLuserClient: "RPL_LUSERCLIENT",
|
|
RplLuserOp: "RPL_LUSEROP",
|
|
RplLuserUnknown: "RPL_LUSERUNKNOWN",
|
|
RplLuserChannels: "RPL_LUSERCHANNELS",
|
|
RplLuserMe: "RPL_LUSERME",
|
|
RplAway: "RPL_AWAY",
|
|
RplUserHost: "RPL_USERHOST",
|
|
RplIson: "RPL_ISON",
|
|
RplUnaway: "RPL_UNAWAY",
|
|
RplNowAway: "RPL_NOWAWAY",
|
|
RplWhoisUser: "RPL_WHOISUSER",
|
|
RplWhoisServer: "RPL_WHOISSERVER",
|
|
RplWhoisOperator: "RPL_WHOISOPERATOR",
|
|
RplEndOfWho: "RPL_ENDOFWHO",
|
|
RplWhoisIdle: "RPL_WHOISIDLE",
|
|
RplEndOfWhois: "RPL_ENDOFWHOIS",
|
|
RplWhoisChannels: "RPL_WHOISCHANNELS",
|
|
RplList: "RPL_LIST",
|
|
RplListEnd: "RPL_LISTEND", //nolint:misspell
|
|
RplChannelModeIs: "RPL_CHANNELMODEIS",
|
|
RplCreationTime: "RPL_CREATIONTIME",
|
|
RplNoTopic: "RPL_NOTOPIC",
|
|
RplTopic: "RPL_TOPIC",
|
|
RplTopicWhoTime: "RPL_TOPICWHOTIME",
|
|
RplInviting: "RPL_INVITING",
|
|
RplWhoReply: "RPL_WHOREPLY",
|
|
RplNamReply: "RPL_NAMREPLY",
|
|
RplEndOfNames: "RPL_ENDOFNAMES",
|
|
RplBanList: "RPL_BANLIST",
|
|
RplEndOfBanList: "RPL_ENDOFBANLIST",
|
|
RplMotd: "RPL_MOTD",
|
|
RplMotdStart: "RPL_MOTDSTART",
|
|
RplEndOfMotd: "RPL_ENDOFMOTD",
|
|
|
|
ErrNoSuchNick: "ERR_NOSUCHNICK",
|
|
ErrNoSuchServer: "ERR_NOSUCHSERVER",
|
|
ErrNoSuchChannel: "ERR_NOSUCHCHANNEL",
|
|
ErrCannotSendToChan: "ERR_CANNOTSENDTOCHAN",
|
|
ErrTooManyChannels: "ERR_TOOMANYCHANNELS",
|
|
ErrNoRecipient: "ERR_NORECIPIENT",
|
|
ErrNoTextToSend: "ERR_NOTEXTTOSEND",
|
|
ErrUnknownCommand: "ERR_UNKNOWNCOMMAND",
|
|
ErrNoNicknameGiven: "ERR_NONICKNAMEGIVEN",
|
|
ErrErroneusNickname: "ERR_ERRONEUSNICKNAME",
|
|
ErrNicknameInUse: "ERR_NICKNAMEINUSE",
|
|
ErrUserNotInChannel: "ERR_USERNOTINCHANNEL",
|
|
ErrNotOnChannel: "ERR_NOTONCHANNEL",
|
|
ErrNotRegistered: "ERR_NOTREGISTERED",
|
|
ErrNeedMoreParams: "ERR_NEEDMOREPARAMS",
|
|
ErrAlreadyRegistered: "ERR_ALREADYREGISTERED",
|
|
ErrChannelIsFull: "ERR_CHANNELISFULL",
|
|
ErrInviteOnlyChan: "ERR_INVITEONLYCHAN",
|
|
ErrBannedFromChan: "ERR_BANNEDFROMCHAN",
|
|
ErrBadChannelKey: "ERR_BADCHANNELKEY",
|
|
ErrChanOpPrivsNeeded: "ERR_CHANOPRIVSNEEDED",
|
|
}
|
|
|
|
// Name returns the standard IRC name for a numeric code
|
|
// (e.g., Name(2) returns "RPL_YOURHOST"). Returns an
|
|
// empty string if the code is unknown.
|
|
func Name(code int) string {
|
|
return names[code]
|
|
}
|