feat(stats): add command usage statistics module with persistence

Implement a new stats module for the Telegram bot that tracks per-command usage with persistent KV storage. The module provides a /stats command displaying usage sorted by popularity with a 4096-byte Telegram message cap. Includes CommandHook integration for post-dispatch tracking via background goroutine (2s bounded context), proper test coverage, and registry initialization. Updated server config with stats factory and reserved concurrent execution control to prevent TOCTOU issues.
This commit is contained in:
tiennm99 committed 2026-05-22 15:06:46 +07:00
1 parent ddb9d61bde
commit 2abc138bb1
7 files changed
+303 -11

No files matched your search

+2
View File
@@ -23,6 +23,7 @@ import (
"github.com/tiennm99/miti99bot/internal/modules/loldle"
"github.com/tiennm99/miti99bot/internal/modules/lolschedule"
"github.com/tiennm99/miti99bot/internal/modules/misc"
"github.com/tiennm99/miti99bot/internal/modules/stats"
"github.com/tiennm99/miti99bot/internal/modules/trading"
"github.com/tiennm99/miti99bot/internal/modules/twentyq"
"github.com/tiennm99/miti99bot/internal/modules/util"
@@ -49,6 +50,7 @@ func factories() map[string]modules.Factory {
"lolschedule": lolschedule.New,
"twentyq": twentyq.New,
"trading": trading.New,
"stats": stats.New,
}
}