Merge branch 'chat' into dev

This commit is contained in:
徐俊杰 2025-06-19 11:12:27 +08:00
commit 4afa15ee3f
3 changed files with 18 additions and 12 deletions

View File

@ -168,8 +168,8 @@ func (r *Robot) Run() {
hit := false
for _, rule := range r.joinSessionRules {
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {
err := rule.Run(r.cache)
if err != nil {
@ -183,6 +183,7 @@ func (r *Robot) Run() {
if !hit {
for _, rule := range r.keywordsRules {
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {
@ -198,7 +199,8 @@ func (r *Robot) Run() {
}
if !hit {
for _, rule := range r.noReplyAfterRules {
hit := rule.Hit(event, r.Info)
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {

View File

@ -8,10 +8,24 @@ package robot
import (
"fmt"
"fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/common/ws"
"fonchain-fiee/pkg/service/asChat/chatCache"
"fonchain-fiee/pkg/service/asChat/dto"
"strings"
"time"
)
type IRobotTask interface {
Hit(event ws.ListenEventData, sender *accountFiee.ChatUserData) (hit bool)
Run(cache *chatCache.ChatCache) error
RunTime() time.Time
SetResponse(response string)
GetResponse() string
SetTitle(title string)
GetTitle() string
}
// 自动回复规则结构转换
func ParseReplyRule(data []*dto.ChatAutoReplyData) (joinSessionRules, keywordsRules, noReplyAfterRules []IRobotTask) {
for _, responseRules := range data {

View File

@ -18,16 +18,6 @@ import (
"time"
)
type IRobotTask interface {
Hit(event ws.ListenEventData, sender *accountFiee.ChatUserData) (hit bool)
Run(cache *chatCache.ChatCache) error
RunTime() time.Time
SetResponse(response string)
GetResponse() string
SetTitle(title string)
GetTitle() string
}
// 客服指定时间不回复则自动回复
func NewReplyWhenWaiterNoAction(title string, delaySecond time.Duration) IRobotTask {
return &RobotTaskReplyWhenWaiterNoAction{