Explorar o código

wip:历史记录截取

wangkaiyue %!s(int64=2) %!d(string=hai) anos
pai
achega
c4bc0152c9
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      internal/model/question.go

+ 4 - 1
internal/model/question.go

@@ -39,8 +39,11 @@ type QuestionReq struct {
 
 // ParseHistoryFsw 过滤历史记录敏感词
 func (r *BaseQuestion) ParseHistoryFsw() {
+	if len(r.History) == 0 {
+		return
+	}
 	var newHistory [][]string
-	for i := len(r.History) - 1; i >= 0; i++ {
+	for i := len(r.History) - 1; i >= 0; i-- {
 		var pass bool = true
 		for _, v := range r.History[i] {
 			if fsw.Match(v) {