mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-06-08 08:16:03 +00:00
daeaf0c605
The CF→AWS data migration (closed 2026-05-16) is long done and the tooling isn't wired into any production path. Remove the one-shot binary, its support package, and the migration runbook. In live code, replace 'JS-parity' / 'same shape as JS' / 'cross-runtime KV migration' comments with the real, stable reason for each behavior (wire-format invariant, null-vs-zero distinction, CloudWatch alarm field name, etc.). 24 files touched across lolschedule, loldle, wordle, twentyq, trading, misc, util, server, metrics, ai, keylock. - delete cmd/migrate_cf_data/ - delete internal/migration/ - delete docs/cf-to-aws-migration-runbook.md
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package util
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/go-telegram/bot"
|
|
"github.com/go-telegram/bot/models"
|
|
|
|
"github.com/tiennm99/miti99bot/internal/modules"
|
|
"github.com/tiennm99/miti99bot/internal/modules/util/chathelper"
|
|
)
|
|
|
|
// infoCommand returns /info — replies plain text with chat / thread / sender
|
|
// IDs, with "n/a" fallbacks. Used to debug bot routing in groups + topics.
|
|
func infoCommand() modules.Command {
|
|
return modules.Command{
|
|
Name: "info",
|
|
// Protected (not Public) because the response exposes internal
|
|
// routing IDs — chat id, thread id, sender id. Useful for admins
|
|
// debugging group/topic routing; not something every group member
|
|
// should be able to enumerate. Non-admins see no response at all
|
|
// (Visibility denies are silent — see dispatcher.go:31).
|
|
Visibility: modules.VisibilityProtected,
|
|
Description: "Show chat id, thread id, and sender id (debug helper)",
|
|
Handler: func(ctx context.Context, b *bot.Bot, update *models.Update) error {
|
|
msg := update.Message
|
|
if msg == nil {
|
|
// Today the dispatcher only routes message-text commands, but
|
|
// guard so /info can be safely reused from other update paths.
|
|
return nil
|
|
}
|
|
chatID := fmt.Sprintf("%d", msg.Chat.ID)
|
|
// Telegram omits message_thread_id outside forum topics, so a 0
|
|
// here means "no thread" — render as "n/a" instead of "0".
|
|
threadID := "n/a"
|
|
if msg.MessageThreadID != 0 {
|
|
threadID = fmt.Sprintf("%d", msg.MessageThreadID)
|
|
}
|
|
senderID := "n/a"
|
|
if msg.From != nil {
|
|
senderID = fmt.Sprintf("%d", msg.From.ID)
|
|
}
|
|
text := fmt.Sprintf("chat id: %s\nthread id: %s\nsender id: %s", chatID, threadID, senderID)
|
|
return chathelper.Reply(ctx, b, msg, text)
|
|
},
|
|
}
|
|
}
|