fix #44 当单选题出现多个提示信息时对提示信息进行合并

This commit is contained in:
johlanse 2022-08-04 14:04:46 +08:00
parent 645d994e2e
commit 006cab0c1f
2 changed files with 10 additions and 1 deletions

BIN
docs/img/wx_temp.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -400,6 +400,12 @@ func (c *Core) RespondDaily(user *model.User, model string) {
var answer []string var answer []string
if len(tips) > 1 {
log.Warningln("检测到单选题出现多个提示信息,即将对提示信息进行合并")
tip := strings.Join(tips, "")
tips = []string{tip}
}
for _, option := range options { for _, option := range options {
for _, tip := range tips { for _, tip := range tips {
if strings.Contains(option, tip) { if strings.Contains(option, tip) {
@ -556,8 +562,11 @@ func getTips(data string) []string {
match := compile.FindAllStringSubmatch(data, -1) match := compile.FindAllStringSubmatch(data, -1)
var tips []string var tips []string
for _, i := range match { for _, i := range match {
// 新增判断提示信息为空的逻辑
if i[1] != "" {
tips = append(tips, i[1]) tips = append(tips, i[1])
} }
}
return tips return tips
} }