fonchain-fiee/pkg/service/asChat/robot/rulerList.go

44 lines
1.1 KiB
Go
Raw Normal View History

2025-06-14 06:46:01 +00:00
// Package autoReply -----------------------------
// @file : rulerList.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2025/6/13 16:16
// -------------------------------------------
package robot
2025-06-15 08:01:55 +00:00
import (
2025-06-19 01:15:10 +00:00
"fmt"
2025-06-15 08:01:55 +00:00
"fonchain-fiee/pkg/service/asChat/dto"
"strings"
)
2025-06-15 08:09:25 +00:00
// 自动回复规则结构转换
2025-06-15 08:01:55 +00:00
func ParseReplyRule(data *dto.ChatAutoReplyData) (r Reply) {
r.Response = data.Response
r.Title = data.Title
2025-06-15 08:01:55 +00:00
for ruleName, v := range data.Rules {
if !v.Enable {
continue
}
switch ruleName {
case "keywords": //关键字回复
var keywords []string
if v.Content == "" {
2025-06-15 08:01:55 +00:00
continue
} else {
keywords = strings.Split(v.Content, ",")
}
2025-06-19 01:15:10 +00:00
fmt.Println("ParseReplyRule 解析keywords:", keywords)
2025-06-15 08:01:55 +00:00
r.Rules = append(r.Rules, NewReplyWhenHitKeywords(keywords))
case "joinSession": //加入聊天后回复
r.Rules = append(r.Rules, NewReplyWhenUserJoinSession())
case "noReplyAfter": //指定时间没有回复则自动回复
2025-06-15 08:09:25 +00:00
if v.SecondDuration == 0 {
continue
}
r.Rules = append(r.Rules, NewReplyWhenWaiterNoAction(v.SecondDuration))
2025-06-15 08:01:55 +00:00
}
}
return
}