fix: fix bug

修复了当答题未能获取到答案会进入死循环的bug
This commit is contained in:
johlanse 2021-12-06 13:49:03 +08:00
parent df0d744297
commit f35d9916a0
1 changed files with 20 additions and 18 deletions

View File

@ -258,10 +258,7 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
log.Infoln("获取到选项答案:", options)
log.Infoln("[多选题选项]", options)
var answer []string
if len(tips) == 0 {
log.Warnln("检测到未成功获取提示信息将选择ABCD")
answer = append(answer, options...)
} else {
for _, option := range options {
for _, tip := range tips {
if strings.Contains(option, tip) {
@ -269,6 +266,10 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
}
}
}
if len(answer) < 1 {
answer = append(answer, options...)
log.Infoln("无法判断答案自动选择ABCD")
}
log.Infoln("根据提示分别选择了", RemoveRepByLoop(answer))
err = radioCheck(page, answer)
@ -285,10 +286,7 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
log.Infoln("获取到选项答案:", options)
var answer []string
if len(tips) == 0 {
log.Warnln("未能获取到提示信息将自动选择A")
answer = append(answer, options[0])
} else {
for _, option := range options {
for _, tip := range tips {
if strings.Contains(option, tip) {
@ -296,7 +294,11 @@ func (c *Core) RespondDaily(cookies []Cookie, model string) {
}
}
}
if len(answer) < 1 {
answer = append(answer, options[0])
log.Infoln("无法判断答案自动选择A")
}
log.Infoln("根据提示分别选择了", answer)
err = radioCheck(page, answer)
if err != nil {