diff --git a/README.md b/README.md index 44f0447..d319420 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,9 @@ Ctrl+C - Exit chat :nick - Change nickname :msg - Whisper to user :w - Short alias for :msg +:last [N] - Show last N messages from history (max 50, default 10) +:search - Search full message history (case-insensitive) +:mute-joins - Toggle join/leave system notifications :help - Show available commands :clear - Clear command output :q, :quit, :exit - Disconnect @@ -276,9 +279,24 @@ See [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) for details. ``` messages.log - Chat history (RFC3339 format) host_key - SSH host key (auto-generated, 4096-bit RSA) +motd.txt - Message of the Day (optional, shown to users on connect) tnt.service - systemd service unit ``` +### MOTD (Message of the Day) + +Place a `motd.txt` file in the state directory to show a welcome message to every user on connect. Users see the MOTD before entering the chat and press any key to continue. + +```sh +# Example (assuming default state dir) +cat > motd.txt <<'EOF' +Welcome to the chat server! +Be respectful. No spam. +EOF +``` + +Delete `motd.txt` to disable the MOTD. + ## Documentation - [Development Guide](https://github.com/m1ngsama/TNT/wiki/Development-Guide) - Complete development manual @@ -300,7 +318,7 @@ tnt.service - systemd service unit ## Known Limitations - Single chat room (no multi-room support yet) -- Keeps only last 100 messages in memory +- TUI displays at most 100 messages at once; use `:last N` or `:search` to access older history from disk - Ctrl+W only recognizes ASCII space as word boundary ## Contributing diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 47b002d..5689bdb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 2026-04-23 - Chat UX Commands and MOTD + +### Added +- **`:last [N]`** — show last N messages retrieved directly from the log file (1–50, default 10), bypassing the 100-message in-memory ring buffer limit +- **`:search `** — case-insensitive full-text search across the entire message history on disk; returns the most recent 15 matches +- **`:mute-joins`** — per-client toggle to silence join/leave system notifications; title bar shows `[静音]` when active +- **MOTD support** — place `motd.txt` in the state directory; users see it on connect and press any key to enter chat +- **`message_search()`** — new function in `message.c` / `message.h` for log file keyword search with rolling result collection +- Updated in-TUI help screens (English and Chinese) with new commands + ## 2026-03-10 - SSH Runtime & Unix Interface Update ### Fixed diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index ce64473..b3c2a20 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -89,6 +89,24 @@ Recommended interpretation: - `TNT_MAX_CONN_RATE_PER_IP`: new connection attempts allowed per IP per 60 seconds - `TNT_RATE_LIMIT=0`: disables rate-based blocking and auth-failure IP blocking, but not the explicit capacity limits +## MOTD (Message of the Day) + +Place a `motd.txt` file in the state directory. TNT displays it to each user on connect; they press any key to enter the chat. + +```bash +# Systemd deployment (state dir is /var/lib/tnt) +sudo tee /var/lib/tnt/motd.txt <<'EOF' +Welcome! Be respectful. No spam. +Type :help for available commands. +EOF +sudo chown tnt:tnt /var/lib/tnt/motd.txt + +# Remove to disable +sudo rm /var/lib/tnt/motd.txt +``` + +No restart required — TNT reads the file on each new connection. + ## Firewall ```bash diff --git a/docs/QUICKREF.md b/docs/QUICKREF.md index bc9170f..fef3ba4 100644 --- a/docs/QUICKREF.md +++ b/docs/QUICKREF.md @@ -17,21 +17,37 @@ DEBUG valgrind --leak-check=full ./tnt make check +COMMANDS (COMMAND mode, prefix with :) + list, users, who show online users + nick change nickname + msg whisper to user + w alias for msg + last [N] last N messages from log (default 10, max 50) + search search full history (case-insensitive, 15 results) + mute-joins toggle join/leave notifications + help show all commands + clear clear output + q / quit / exit disconnect + +INSERT MODE + /me action message + @username mention (bell + highlight) + STRUCTURE src/main.c entry, signals - src/ssh_server.c SSH, threads + src/ssh_server.c SSH, threads, commands src/chat_room.c broadcast - src/message.c persistence - src/tui.c rendering + src/message.c persistence, search + src/tui.c rendering, help src/utf8.c unicode LIMITS - 64 clients max - 100 messages in RAM + 64 clients max (configurable) + 100 messages in RAM; unlimited on disk 1024 bytes/message FILES - HACKING dev guide - CHANGELOG.md changes - messages.log chat log - host_key SSH key + messages.log chat log (RFC3339) + host_key SSH key (auto-generated) + motd.txt message of the day (optional) + CHANGELOG.md version history diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index a28a81f..1866534 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -59,11 +59,11 @@ Goal: keep the interface efficient for terminal users without sacrificing simpli - keep the current modal editing model, but make its behavior precise and documented - support resize, cursor movement, command history, and predictable paste behavior - add useful chat commands with clear semantics: - - `/nick` - - `/me` - - `/last N` - - `/search` - - `/mute-joins` + - ✅ `:nick` / `:name` — nickname change with broadcast + - ✅ `/me` — action messages + - ✅ `:last N` — show last N messages from disk history + - ✅ `:search ` — case-insensitive full-text search + - ✅ `:mute-joins` — per-client join/leave notification toggle - improve discoverability of NORMAL and COMMAND mode actions - make status lines and help output concise enough for small terminals diff --git a/tnt.1 b/tnt.1 index f4c53f2..b77da27 100644 --- a/tnt.1 +++ b/tnt.1 @@ -107,6 +107,9 @@ l l. :name \fIname\fR Alias for :nick :msg \fIuser text\fR Send private whisper :w \fIuser text\fR Short alias for :msg +:last [\fIN\fR] Show last N messages from history (1\-50, default 10) +:search \fIkeyword\fR Case\-insensitive search across full message history +:mute\-joins Toggle join/leave system notifications on/off :help Show available commands :clear Clear command output :q, :quit, :exit Disconnect @@ -167,6 +170,12 @@ Stored in the state directory. .I host_key RSA 4096\-bit host key, auto\-generated on first run. Stored in the state directory with mode 0600. +.TP +.I motd.txt +Optional Message of the Day. +When present in the state directory, its contents are shown to each user +immediately on connect before the chat screen appears. +Delete the file to disable the MOTD. .SH SYSTEMD A unit file .I tnt.service