mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-11 03:13:46 +00:00
fix(commands): remove examples from command discovery
This commit is contained in:
1 parent
b5c7427520
commit
a211b7f8b7
22 files changed
+47
-154
No files matched your search
@@ -137,12 +137,10 @@ Successful GIF replies include the result behind Telegram spoiler formatting.
|
||||
The bot registers its Telegram command menu from loaded public modules on
|
||||
every startup. The Go module registry is the single source of truth; no separate
|
||||
command-menu file or manual registration step is required. A command's
|
||||
description plus optional `Parameters` and `Example` metadata feed both
|
||||
surfaces. Telegram renders the command name separately and accepts only a
|
||||
single-line plain-text description, so parameterized commands append
|
||||
`Eg: <invocation>` inline. `/help` uses the same inline layout and wraps only
|
||||
the invocation in Telegram HTML `<code>` formatting. Commands without
|
||||
parameters omit examples.
|
||||
description plus optional `Parameters` metadata feed both surfaces. Telegram
|
||||
renders the command name separately and accepts only a single-line plain-text
|
||||
description. Both the native menu and `/help` show syntax plus the summary and
|
||||
omit example invocations.
|
||||
|
||||
## Operations
|
||||
|
||||
|
||||
@@ -3,58 +3,51 @@
|
||||
## Context
|
||||
|
||||
Telegram's native command menu and `/help` exposed only short descriptions,
|
||||
leaving users to discover parameters and examples through failed invocations or
|
||||
source documentation.
|
||||
leaving users to discover parameters through failed invocations or source
|
||||
documentation.
|
||||
|
||||
## What Changed
|
||||
|
||||
- Extended the shared command registration with `Parameters` and `Example`
|
||||
metadata and presentation helpers used by both discovery surfaces.
|
||||
- Extended the shared command registration with `Parameters` metadata and
|
||||
presentation helpers used by both discovery surfaces.
|
||||
- Added metadata for all 40 public commands, including the exact stats grammar:
|
||||
`[users | user <username> | cmd <command_name>]`.
|
||||
- Normalized placeholders to lowercase descriptive names, including meaningful
|
||||
units or currencies; `[...]` marks optional input, `...` remaining free text,
|
||||
and parentheses structured input.
|
||||
- Normalized `/wheelofnames` to `<options(comma-separated)>` across metadata,
|
||||
usage text, and tests; its example remains
|
||||
`/wheelofnames pizza, sushi, pho`.
|
||||
usage text, and tests.
|
||||
- Finalized dividend placeholders as `<vnd_per_share> <ticker>`,
|
||||
`<ratio(owned:new)> <ticker>`, and
|
||||
`<vnd_per_share> <ratio(owned:new)> <ticker>` for cash, share, and combined
|
||||
commands. Examples and parsing remain unchanged.
|
||||
- Native menu descriptions show only the summary for no-parameter commands.
|
||||
Parameterized commands append an explicit example with the short `Eg:` label
|
||||
on the same plain-text line.
|
||||
- `/help` renders each invocation and summary together. Parameterized commands
|
||||
append `Eg: <code>invocation</code>` on the same line, with only the copyable
|
||||
invocation inside Telegram's HTML `<code>` formatting. No-parameter commands
|
||||
omit the label and example. Dynamic command fields are HTML-escaped.
|
||||
- Registration validation rejects multiline metadata, examples for another
|
||||
command, public commands that provide only one of parameters or example, and
|
||||
public descriptions over Telegram's 256-character limit.
|
||||
commands. Parsing remains unchanged.
|
||||
- Native menu descriptions show parameters followed by the summary, while
|
||||
`/help` renders the complete invocation followed by the summary. Neither
|
||||
discovery surface includes example invocations. Dynamic fields are
|
||||
HTML-escaped in `/help`.
|
||||
- Registration validation rejects multiline metadata and public descriptions
|
||||
over Telegram's 256-character limit.
|
||||
- Updated user and deployment documentation for the shared registry behavior.
|
||||
|
||||
## Reflection
|
||||
|
||||
Keeping syntax and examples beside each handler registration prevents the
|
||||
native menu, `/help`, and implementation from drifting independently. The
|
||||
native surface stays compact, while `/help` uses the richer layout Telegram
|
||||
supports without sacrificing safe HTML rendering.
|
||||
Keeping syntax beside each handler registration prevents the native menu,
|
||||
`/help`, and implementation from drifting independently. Both discovery
|
||||
surfaces stay compact without sacrificing safe HTML rendering in `/help`.
|
||||
|
||||
## Decisions
|
||||
|
||||
- Existing command names, handlers, parsers, and persisted data remain
|
||||
unchanged; normalization is presentation-only.
|
||||
- No command was added, renamed, or deleted, so no stats migration is needed.
|
||||
- Public commands with parameters require an explicit example; commands
|
||||
without parameters omit it.
|
||||
- Discovery surfaces intentionally omit example invocations; handler usage
|
||||
errors may still include focused examples.
|
||||
- The complete `/help` output remains within Telegram's 4,096-character limit.
|
||||
|
||||
## Verification
|
||||
|
||||
- Passed: command presentation, validation, menu, and `/help` tests for all 40
|
||||
public commands, including inline `<code>` rendering, no-parameter omission,
|
||||
and both parameter/example validation branches.
|
||||
public commands.
|
||||
- Passed: `go test ./...`, including real MongoDB Testcontainers suites.
|
||||
- Passed: `go vet ./...`
|
||||
- Passed: `go build ./...`
|
||||
@@ -62,5 +55,5 @@ supports without sacrificing safe HTML rendering.
|
||||
|
||||
## Next Steps
|
||||
|
||||
- Require parameter and example metadata updates alongside future public
|
||||
command contract changes.
|
||||
- Require parameter metadata updates alongside future public command contract
|
||||
changes.
|
||||
Reference in new issue
Block a user