mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-03 17:07:15 +00:00
fix(tgbot): ignore commands for other bots (#4894)
Telegram group chats can contain multiple bots. Commands addressed to another bot, such as /status@other_bot, should not be handled by the 3x-ui bot. Closes #4893
This commit is contained in:
@@ -99,3 +99,27 @@ func TestTgbotProxyDialerNoneWhenEmpty(t *testing.T) {
|
||||
t.Fatal("Dial must be nil when no proxy is configured")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsCommandForBotAllowsUntargetedCommand(t *testing.T) {
|
||||
if !isCommandForBot("/status", "panel_bot") {
|
||||
t.Fatal("untargeted commands must remain accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsCommandForBotAllowsMatchingUsername(t *testing.T) {
|
||||
if !isCommandForBot("/status@panel_bot", "Panel_Bot") {
|
||||
t.Fatal("commands targeted to this bot must be accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsCommandForBotRejectsOtherUsername(t *testing.T) {
|
||||
if isCommandForBot("/status@other_bot", "panel_bot") {
|
||||
t.Fatal("commands targeted to another bot must be ignored")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsCommandForBotKeepsLegacyBehaviorWhenUsernameUnavailable(t *testing.T) {
|
||||
if !isCommandForBot("/status@panel_bot", "") {
|
||||
t.Fatal("commands must remain accepted when the current bot username is unavailable")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user