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 #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
All checks were successful
check / check (push) Successful in 59s
Required
Details
This pull request can be merged automatically.
You are not authorized to merge this pull request.
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.