feat: implement Tier 3 utility IRC commands (USERHOST, VERSION, ADMIN, INFO, TIME, KILL, WALLOPS) #96

Open
clawbot wants to merge 1 commits from feature/87-tier3-utility-commands into main
Collaborator

Summary

Implement all 7 Tier 3 utility IRC commands from sneak/chat#87.

User Commands

Command Numeric Description
USERHOST nick [nick...] 302 RPL_USERHOST Quick lookup of user@host for up to 5 nicks
VERSION 351 RPL_VERSION Server version string (uses globals.Version)
ADMIN 256-259 Server admin contact info
INFO 371/374 Server software info text
TIME 391 RPL_TIME Server local time in RFC format

Oper Commands

Command Description
KILL nick :reason Forcibly disconnect a user (oper only). Broadcasts QUIT to shared channels, cleans up session.
WALLOPS :message Broadcast to all users with +w usermode (oper only)

Supporting Changes

  • Added is_wallops column to sessions table in 001_initial.sql
  • User mode +w tracking via MODE nick +w/-w
  • User mode queries (MODE nick) now return actual modes (+o, +w)
  • MODE -o de-opers yourself; MODE +o rejected (must use OPER command)
  • MODE for other users returns ERR_USERSDONTMATCH (502)
  • Extracted dispatch helpers (dispatchBodyOnlyCommand, dispatchOperCommand) to reduce dispatchCommand complexity

New Files

  • internal/handlers/utility.go — All 7 command handlers + user mode management
  • internal/handlers/utility_test.go — 24 tests covering all commands, error cases, oper checks, broadcasts, and edge cases

DB Changes

  • internal/db/queries.goSetSessionWallops, IsSessionWallops, GetWallopsSessionIDs, GetUserhostInfo

docker build --no-cache . passes clean (0 lint issues, all tests pass with race detector).

closes #87

## Summary Implement all 7 Tier 3 utility IRC commands from https://git.eeqj.de/sneak/chat/issues/87. ### User Commands | Command | Numeric | Description | |---------|---------|-------------| | `USERHOST nick [nick...]` | 302 RPL_USERHOST | Quick lookup of user@host for up to 5 nicks | | `VERSION` | 351 RPL_VERSION | Server version string (uses `globals.Version`) | | `ADMIN` | 256-259 | Server admin contact info | | `INFO` | 371/374 | Server software info text | | `TIME` | 391 RPL_TIME | Server local time in RFC format | ### Oper Commands | Command | Description | |---------|-------------| | `KILL nick :reason` | Forcibly disconnect a user (oper only). Broadcasts QUIT to shared channels, cleans up session. | | `WALLOPS :message` | Broadcast to all users with +w usermode (oper only) | ### Supporting Changes - Added `is_wallops` column to sessions table in `001_initial.sql` - User mode `+w` tracking via `MODE nick +w/-w` - User mode queries (`MODE nick`) now return actual modes (`+o`, `+w`) - `MODE -o` de-opers yourself; `MODE +o` rejected (must use OPER command) - `MODE` for other users returns `ERR_USERSDONTMATCH` (502) - Extracted dispatch helpers (`dispatchBodyOnlyCommand`, `dispatchOperCommand`) to reduce `dispatchCommand` complexity ### New Files - `internal/handlers/utility.go` — All 7 command handlers + user mode management - `internal/handlers/utility_test.go` — 24 tests covering all commands, error cases, oper checks, broadcasts, and edge cases ### DB Changes - `internal/db/queries.go` — `SetSessionWallops`, `IsSessionWallops`, `GetWallopsSessionIDs`, `GetUserhostInfo` `docker build --no-cache .` passes clean (0 lint issues, all tests pass with race detector). closes #87
clawbot added 1 commit 2026-03-27 05:56:57 +01:00
feat: implement Tier 3 utility IRC commands
All checks were successful
check / check (push) Successful in 59s
142d0f5919
Implement all 7 utility IRC commands from issue #87:

User commands:
- USERHOST: quick lookup of user@host for up to 5 nicks (RPL 302)
- VERSION: server version string using globals.Version (RPL 351)
- ADMIN: server admin contact info (RPL 256-259)
- INFO: server software info text (RPL 371/374)
- TIME: server local time in RFC format (RPL 391)

Oper commands:
- KILL: forcibly disconnect a user (requires is_oper), broadcasts
  QUIT to all shared channels, cleans up sessions
- WALLOPS: broadcast message to all users with +w usermode
  (requires is_oper)

Supporting changes:
- Add is_wallops column to sessions table in 001_initial.sql
- Add user mode +w tracking via MODE nick +w/-w
- User mode queries now return actual modes (+o, +w)
- MODE -o allows de-opering yourself; MODE +o rejected
- MODE for other users returns ERR_USERSDONTMATCH (502)
- Extract dispatch helpers to reduce dispatchCommand complexity

Tests cover all commands including error cases, oper checks,
user mode set/unset, KILL broadcast, WALLOPS delivery, and
edge cases (self-kill, nonexistent users, missing params).

closes #87
clawbot added the needs-review label 2026-03-27 05:57:32 +01:00
clawbot self-assigned this 2026-03-27 05:57:32 +01:00
clawbot reviewed 2026-03-27 21:43:13 +01:00
clawbot left a comment
Author
Collaborator

Review: PASS

All 7 Tier 3 utility IRC commands are correctly implemented.

Commands Verified

Command Numerics Status
USERHOST 302 RPL_USERHOST Correct RFC 2812 format (nick*=±user@host), 5-nick limit, oper star, away prefix
VERSION 351 RPL_VERSION Uses globals.Version
ADMIN 256–259 All four numerics (ADMINME, ADMINLOC1, ADMINLOC2, ADMINEMAIL)
INFO 371/374 Multiple RPL_INFO lines + RPL_ENDOFINFO
TIME 391 RPL_TIME RFC1123 format
KILL Oper check (481), target lookup (401), self-kill prevention (483), QUIT broadcast, session cleanup
WALLOPS Oper check (481), +w usermode gating, fanOut delivery

Supporting Changes Verified

  • is_wallops added to 001_initial.sql (not a new migration) — correct for pre-1.0
  • User mode +w/-w via MODE with RPL_UMODEIS (221)
  • MODE +o rejected (must use OPER), MODE -o de-opers correctly
  • MODE othernick returns ERR_USERSDONTMATCH (502)
  • Dispatch refactoring (dispatchBodyOnlyCommand, dispatchOperCommand) is clean

Policy Compliance

  • No changes to .golangci.yml, Dockerfile, Makefile, or CI workflows
  • Docker images remain pinned by sha256
  • All new DB functions (SetSessionWallops, IsSessionWallops, GetWallopsSessionIDs, GetUserhostInfo) follow existing patterns
  • 24 tests covering all commands, error paths, oper checks, and edge cases

Build

docker build --no-cache .passes clean: 0 lint issues, all tests pass with -race.

## Review: PASS ✅ All 7 Tier 3 utility IRC commands are correctly implemented. ### Commands Verified | Command | Numerics | Status | |---------|----------|--------| | USERHOST | 302 RPL_USERHOST | ✅ Correct RFC 2812 format (nick*=±user@host), 5-nick limit, oper star, away prefix | | VERSION | 351 RPL_VERSION | ✅ Uses `globals.Version` | | ADMIN | 256–259 | ✅ All four numerics (ADMINME, ADMINLOC1, ADMINLOC2, ADMINEMAIL) | | INFO | 371/374 | ✅ Multiple RPL_INFO lines + RPL_ENDOFINFO | | TIME | 391 RPL_TIME | ✅ RFC1123 format | | KILL | — | ✅ Oper check (481), target lookup (401), self-kill prevention (483), QUIT broadcast, session cleanup | | WALLOPS | — | ✅ Oper check (481), +w usermode gating, fanOut delivery | ### Supporting Changes Verified - `is_wallops` added to `001_initial.sql` (not a new migration) — correct for pre-1.0 - User mode `+w`/`-w` via MODE with RPL_UMODEIS (221) - `MODE +o` rejected (must use OPER), `MODE -o` de-opers correctly - `MODE othernick` returns ERR_USERSDONTMATCH (502) - Dispatch refactoring (`dispatchBodyOnlyCommand`, `dispatchOperCommand`) is clean ### Policy Compliance - No changes to `.golangci.yml`, `Dockerfile`, `Makefile`, or CI workflows - Docker images remain pinned by sha256 - All new DB functions (`SetSessionWallops`, `IsSessionWallops`, `GetWallopsSessionIDs`, `GetUserhostInfo`) follow existing patterns - 24 tests covering all commands, error paths, oper checks, and edge cases ### Build `docker build --no-cache .` — **passes clean**: 0 lint issues, all tests pass with `-race`.
clawbot added merge-ready and removed needs-review labels 2026-03-27 21:43:47 +01:00
clawbot removed their assignment 2026-03-27 21:43:47 +01:00
sneak was assigned by clawbot 2026-03-27 21:43:47 +01:00
All checks were successful
check / check (push) Successful in 59s
Required
Details
This pull request has changes conflicting with the target branch.
  • pkg/irc/commands.go
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/87-tier3-utility-commands:feature/87-tier3-utility-commands
git checkout feature/87-tier3-utility-commands
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/neoirc#96