Skip to content

Commit 22263e5

Browse files
committed
fix(telegram): grouped help output, reorder command menu
1 parent 6edfb71 commit 22263e5

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

internal/telegram/approval.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ func (tc *TelegramChannel) Notify(_ context.Context, text string) error {
207207
// registerCommands sets the bot's command menu via Telegram's setMyCommands API.
208208
func (tc *TelegramChannel) registerCommands() {
209209
cmds := []tgbotapi.BotCommand{
210-
{Command: "start", Description: "Show welcome message"},
211-
{Command: "help", Description: "Show available commands"},
212210
{Command: "status", Description: "Show proxy status"},
213211
{Command: "policy", Description: "Manage policy rules"},
214212
{Command: "cred", Description: "Manage credentials"},
215213
{Command: "audit", Description: "Show audit log entries"},
214+
{Command: "start", Description: "Show welcome message"},
215+
{Command: "help", Description: "Show available commands"},
216216
}
217217
cfg := tgbotapi.NewSetMyCommands(cmds...)
218218
if _, err := tc.api.Request(cfg); err != nil {

internal/telegram/approval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func TestStartStop(t *testing.T) {
549549
// Look for the help response (sent after getMe during init).
550550
helpFound := false
551551
for _, m := range msgs {
552-
if strings.Contains(m.Text, "Available commands") {
552+
if strings.Contains(m.Text, "Policy") {
553553
helpFound = true
554554
break
555555
}

internal/telegram/commands.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -665,24 +665,24 @@ func (h *CommandHandler) handleStart() string {
665665
}
666666

667667
func (h *CommandHandler) handleHelp() string {
668-
help := `Available commands:
668+
help := `Policy
669+
/policy show | /policy allow <dest> | /policy deny <dest> | /policy remove <id>
669670
670-
/policy show - List current rules
671-
/policy allow <dest> - Add allow rule
672-
/policy deny <dest> - Add deny rule
673-
/policy remove <id> - Remove rule by ID
674-
/status - Show proxy status
675-
/audit recent [N] - Show last N audit entries
676-
/help - Show this message`
671+
Monitoring
672+
/status - Proxy status
673+
/audit recent [N] - Last N audit entries`
677674

678675
if h.vault != nil {
679676
help += `
680677
681-
/cred list - List stored credentials
682-
/cred add <name> <value> [--env-var VAR] - Add credential
683-
/cred rotate <name> <value> - Rotate credential
684-
/cred remove <name> - Remove credential`
678+
Credentials
679+
/cred list | /cred add <name> <value> [--env-var VAR]
680+
/cred rotate <name> <value> | /cred remove <name>`
685681
}
682+
683+
help += `
684+
685+
More: /start for welcome, /help for this message`
686686
return help
687687
}
688688

0 commit comments

Comments
 (0)