This commit is contained in:
cdle
2021-09-30 17:15:21 +08:00
parent 197d672cba
commit 7123b989b0
+4 -5
View File
@@ -119,22 +119,21 @@ func init() {
data = string(v) data = string(v)
} }
rules := []string{} rules := []string{}
for _, v := range regexp.MustCompile(`\[rule:\s*([^\s\[\]]+)\s*\]`).FindAllStringSubmatch(data, -1) { for _, res := range regexp.MustCompile(`\[rule:([^\[\]]+)\]`).FindAllStringSubmatch(data, -1) {
rules = append(rules, v[1]) rules = append(rules, strings.Trim(res[1], " "))
} }
cron := "" cron := ""
if res := regexp.MustCompile(`\[cron:([^\[\]]+)\]`).FindStringSubmatch(data); len(res) != 0 { if res := regexp.MustCompile(`\[cron:([^\[\]]+)\]`).FindStringSubmatch(data); len(res) != 0 {
cron = strings.Trim(res[1], " ") cron = strings.Trim(res[1], " ")
} }
admin := false admin := false
if regexp.MustCompile(`\[cron:\s*true\]`).FindString(data) != "" { if res := regexp.MustCompile(`\[admin:([^\[\]]+)\]`).FindStringSubmatch(data); len(res) != 0 {
admin = true admin = strings.Trim(res[1], " ") == "true"
} }
if len(rules) == 0 { if len(rules) == 0 {
logs.Warn("回复:%s找不到规则", jr, err) logs.Warn("回复:%s找不到规则", jr, err)
continue continue
} }
var handler = func(s Sender) interface{} { var handler = func(s Sender) interface{} {
template := data template := data
for k, v := range s.GetMatch() { for k, v := range s.GetMatch() {