1
0
mirror of https://github.com/fumiama/ReiBot.git synced 2026-06-08 03:55:12 +08:00

add more log

This commit is contained in:
源文雨
2022-07-07 15:18:31 +08:00
parent 1645369ed3
commit 4e50c08da3
4 changed files with 18 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import (
"time"
tgba "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/sirupsen/logrus"
)
// PrefixRule check if the text message has the prefix and trim the prefix
@@ -103,23 +104,30 @@ func RegexRule(regexPattern string) Rule {
switch msg := ctx.Value.(type) {
case *tgba.Message:
if msg.Text == "" { // 确保无空
logrus.Debugln("RegexRule: null message text")
return false
}
if matched := regex.FindStringSubmatch(msg.Text); matched != nil {
ctx.State["regex_matched"] = matched
logrus.Debugln("RegexRule: match message text", matched)
return true
}
logrus.Debugln("RegexRule: no match message")
return false
case *tgba.CallbackQuery:
if msg.Data == "" {
logrus.Debugln("RegexRule: null query data")
return false
}
if matched := regex.FindStringSubmatch(msg.Data); matched != nil {
ctx.State["regex_matched"] = matched
logrus.Debugln("RegexRule: match query data", matched)
return true
}
logrus.Debugln("RegexRule: no match query data")
return false
default:
logrus.Debugln("RegexRule: stub type")
return false
}
}