feat(menu): sort Telegram command suggestions by name

The command menu was in module load order, which split related commands across modules. Sorting by name keeps /thoitiet next to /thoitiethomnay. The weather module also lists /thoitiet first so /help matches.
This commit is contained in:
tiennm99 committed 2026-10-08 17:10:42 +07:00
1 parent 9801a64e18
commit fe552f43e4
4 files changed
+9 -6

No files matched your search

+5 -2
View File
@@ -3,6 +3,8 @@ package main
import (
"context"
"errors"
"slices"
"strings"
"time"
"github.com/go-telegram/bot"
@@ -14,8 +16,8 @@ import (
const commandMenuTimeout = 8 * time.Second
// botCommandMenu builds the Telegram command menu from the loaded public
// commands. It intentionally follows registry module order so MODULES controls
// both enabled commands and their menu grouping.
// commands, sorted by name so related commands such as /thoitiet and
// /thoitiethomnay sit together whatever their module order.
func botCommandMenu(reg *modules.Registry) []models.BotCommand {
if reg == nil {
return nil
@@ -32,6 +34,7 @@ func botCommandMenu(reg *modules.Registry) []models.BotCommand {
})
}
}
slices.SortFunc(out, func(a, b models.BotCommand) int { return strings.Compare(a.Command, b.Command) })
return out
}