mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 02:15:57 +00:00
feat: ignore commands explicitly addressed to other bots in Telegram group chats.
This commit is contained in:
1 parent
eacc481998
commit
4104420d5e
1 file changed
+11
-1
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user