Compare commits

..

No commits in common. "345a93b1498873c0bf2a9dbe704be607bf678d8b" and "b3900e07351d8e6ba2231713fc2a939cfea923cd" have entirely different histories.

3 changed files with 2 additions and 13 deletions

View File

@ -8,7 +8,6 @@ package robot
import ( import (
"context" "context"
"fmt"
"fonchain-fiee/api/accountFiee" "fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/common/ws" "fonchain-fiee/pkg/common/ws"
"fonchain-fiee/pkg/service" "fonchain-fiee/pkg/service"
@ -21,7 +20,6 @@ import (
// 回复规则 // 回复规则
type Reply struct { type Reply struct {
Title string
Response string Response string
Rules []IRule Rules []IRule
} }
@ -207,16 +205,10 @@ func (k *ReplyWhenWaiterNoAction) Hit(event ws.ListenEventData, sender *accountF
if event.ChatUser.Role != 1 { if event.ChatUser.Role != 1 {
return return
} }
hit = true // 立即保存SessionId的值 hit = true
clientSessionId := event.Client.SessionId
fmt.Printf("闭包前: clientSessionId=%s\n", clientSessionId)
task = RobotTask{ task = RobotTask{
RunTime: time.Now().Add(k.DelaySecond * time.Second), RunTime: time.Now().Add(k.DelaySecond * time.Second),
Run: func(content string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error { Run: func(content string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error {
// 记录闭包执行时的Client状态
fmt.Printf("闭包执行: clientSessionId=%s\n", clientSessionId)
//如果客服已经回复则不发送消息 //如果客服已经回复则不发送消息
chatRecordListRes, err := service.AccountFieeProvider.GetChatRecordList(context.Background(), &accountFiee.GetChatRecordListRequest{ chatRecordListRes, err := service.AccountFieeProvider.GetChatRecordList(context.Background(), &accountFiee.GetChatRecordListRequest{
Query: &accountFiee.ChatRecordData{ Query: &accountFiee.ChatRecordData{
@ -247,10 +239,9 @@ func (k *ReplyWhenWaiterNoAction) Hit(event ws.ListenEventData, sender *accountF
//notice.BuildMessage(newRecord) //notice.BuildMessage(newRecord)
//_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice) //_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
//return err //return err
fmt.Println("延时回复 sessionID:", clientSessionId)
err = logic.NewMessage(context.Background(), cache, sender, dto.NewMessageRequest{ err = logic.NewMessage(context.Background(), cache, sender, dto.NewMessageRequest{
Waiter: true, Waiter: true,
SessionId: clientSessionId, SessionId: event.Client.SessionId,
Message: dto.Message{ Message: dto.Message{
MsgType: 1, MsgType: 1,
Text: content, Text: content,

View File

@ -166,7 +166,6 @@ func (r *Robot) Run() {
for _, ruleResponse := range r.Rules { for _, ruleResponse := range r.Rules {
hit, task := ruleResponse.Hit(event, r.Info) hit, task := ruleResponse.Hit(event, r.Info)
if hit { if hit {
fmt.Println("命中规则:", ruleResponse.Title)
if task.RunTime.IsZero() { if task.RunTime.IsZero() {
err := task.Run(ruleResponse.Response, r.cache, r.Info) err := task.Run(ruleResponse.Response, r.cache, r.Info)
if err != nil { if err != nil {

View File

@ -14,7 +14,6 @@ import (
// 自动回复规则结构转换 // 自动回复规则结构转换
func ParseReplyRule(data *dto.ChatAutoReplyData) (r Reply) { func ParseReplyRule(data *dto.ChatAutoReplyData) (r Reply) {
r.Response = data.Response r.Response = data.Response
r.Title = data.Title
for ruleName, v := range data.Rules { for ruleName, v := range data.Rules {
if !v.Enable { if !v.Enable {
continue continue