Answer the question
In order to leave comments, you need to log in
How to enter arbitrary text before executing a command?
Hello.
I am writing a bot on go, for telegram.
It is necessary that you can enter arbitrary text before the command, and only then that the command is executed.
case "/w":
sendMessage(chatid, " — ачивка анлокед")
Answer the question
In order to leave comments, you need to log in
It seems to work.
Just correct the regular season for the characters you need (numbers, letters, etc.)
package main
import (
"fmt"
"regexp"
)
func main() {
var regex = regexp.MustCompile(`^([a-z]*)\/w`)
s := "lol/w"
switch {
case regex.MatchString(s):
fmt.Println("OK")
default:
fmt.Println("NOT OK")
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question