feat: 添加关键词回复
This commit is contained in:
7
util/random_fail.go
Normal file
7
util/random_fail.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package util
|
||||
|
||||
import "math/rand/v2"
|
||||
|
||||
func Fail(chance float64) bool {
|
||||
return rand.Float64() < chance
|
||||
}
|
||||
@@ -4,12 +4,8 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func SplitN(text string, n int) ([]string, int) {
|
||||
if n == 0 {
|
||||
return []string{text}, 1
|
||||
}
|
||||
|
||||
func SplitN(text string, n int) []string {
|
||||
re := regexp.MustCompile(`\s+`)
|
||||
tokens := re.Split(text, n)
|
||||
return tokens, len(tokens)
|
||||
return tokens
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user