feat: ignore commands explicitly addressed to other bots in Telegram group chats.

This commit is contained in:
viettranx committed 2026-02-28 13:07:32 +07:00
1 parent eacc481998
commit 4104420d5e
1 file changed
+11 -1
+11 -1
View File
@@ -42,9 +42,19 @@ func (c *Channel) handleBotCommand(ctx context.Context, message *telego.Message,
// Extract command (strip @botname suffix if present)
cmd := strings.SplitN(text, " ", 2)[0]
cmd = strings.SplitN(cmd, "@", 2)[0]
cmd = strings.ToLower(cmd)
// In groups, ignore commands addressed to other bots (e.g. /help@other_bot)
if isGroup {
if parts := strings.SplitN(cmd, "@", 2); len(parts) == 2 {
if !strings.EqualFold(parts[1], c.bot.Username()) {
return false
}
}
}
cmd = strings.SplitN(cmd, "@", 2)[0]
chatIDObj := tu.ID(chatID)
// Helper: set MessageThreadID on outgoing messages for forum topics.