From 05b67218a96588edd23ee7158d3e2f7733e403c0 Mon Sep 17 00:00:00 2001 From: c0re100 Date: Wed, 12 Mar 2025 00:35:34 +0800 Subject: [PATCH] Check space before @ --- client/extra.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/extra.go b/client/extra.go index 61dd7fc..0a6c60f 100644 --- a/client/extra.go +++ b/client/extra.go @@ -25,18 +25,18 @@ func IsCommand(text string) bool { func CheckCommand(text string, entities []*TextEntity) string { if IsCommand(text) { - // e.g.: ["/hello@world_bot", "/hello@", "/hello@123"] - // Result: "/hello" - if i := strings.Index(text, "@"); i != -1 { - return text[:i] - } - // e.g. ["/hello 123", "/hell o 123"] // Result: "/hello", "/hell" if i := strings.Index(text, " "); i != -1 { return text[:i] } + // e.g.: ["/hello@world_bot", "/hello@", "/hello@123"] + // Result: "/hello" + if i := strings.Index(text, "@"); i != -1 { + return text[:i] + } + return text } return ""