mirror of
https://github.com/c0re100/gotdlib.git
synced 2026-02-21 20:20:17 +01:00
Check space before @
This commit is contained in:
parent
8de0893227
commit
05b67218a9
1 changed files with 6 additions and 6 deletions
|
|
@ -25,18 +25,18 @@ func IsCommand(text string) bool {
|
||||||
|
|
||||||
func CheckCommand(text string, entities []*TextEntity) string {
|
func CheckCommand(text string, entities []*TextEntity) string {
|
||||||
if IsCommand(text) {
|
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"]
|
// e.g. ["/hello 123", "/hell o 123"]
|
||||||
// Result: "/hello", "/hell"
|
// Result: "/hello", "/hell"
|
||||||
if i := strings.Index(text, " "); i != -1 {
|
if i := strings.Index(text, " "); i != -1 {
|
||||||
return text[:i]
|
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 text
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue