From 9bb4bec9f8b0dd58f3739328f7d37f1ce31c5b00 Mon Sep 17 00:00:00 2001 From: jjxu <428192774@qq.com> Date: Thu, 19 Jun 2025 13:23:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A6=86=E7=9B=96=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/common/ws/chatRoom.go | 4 ++-- pkg/service/asChat/chatAutoReplyRulerHandler.go | 2 -- pkg/service/asChat/handler.go | 5 ++++- pkg/service/asChat/logic/chat.go | 2 +- pkg/service/asChat/robot/ruler_keywords.go | 6 ------ 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pkg/common/ws/chatRoom.go b/pkg/common/ws/chatRoom.go index c2b0afc..35f37bb 100644 --- a/pkg/common/ws/chatRoom.go +++ b/pkg/common/ws/chatRoom.go @@ -194,8 +194,8 @@ func (o *ChatRoom) Register(c *Client) (sessionId string) { // message: 消息内容 func (o *ChatRoom) SendSessionMessage(sender *accountFiee.ChatUserData, sessionId string, msgType WsType, message any) (userIdInSession []int64, err error) { fmt.Println("ChatRoom.SendSessionMessage ------------------1") - //o.clientsRwLocker.Lock() - //defer o.clientsRwLocker.Unlock() + o.clientsRwLocker.Lock() + defer o.clientsRwLocker.Unlock() var msg = WsSessionInfo{ Type: msgType, Content: message, diff --git a/pkg/service/asChat/chatAutoReplyRulerHandler.go b/pkg/service/asChat/chatAutoReplyRulerHandler.go index 0d3e260..4bdaffc 100644 --- a/pkg/service/asChat/chatAutoReplyRulerHandler.go +++ b/pkg/service/asChat/chatAutoReplyRulerHandler.go @@ -70,9 +70,7 @@ func (a *ChatAutoReplyRulerHandler) UpdateChatAutoReplyRuler(c *gin.Context) { service.Error(c, err) return } - fmt.Printf("response 1 : %s\n", req.Response) protoReq := req.ToProtoData() - fmt.Printf("response 2 : %s\n", protoReq.Response) _, err := service.AccountFieeProvider.UpdateChatAutoReplyRuler(c, protoReq) if err != nil { service.Error(c, err) diff --git a/pkg/service/asChat/handler.go b/pkg/service/asChat/handler.go index 5e6eb9c..391788b 100644 --- a/pkg/service/asChat/handler.go +++ b/pkg/service/asChat/handler.go @@ -135,6 +135,9 @@ func (cr ChatHandler) NewMessage(c *gin.Context) { service.ErrWithCode(c, code) return } + if request.LocalStamp == 0 { + request.LocalStamp = time.Now().Unix() + } err := logic.NewMessage(c, &cr.cache, chatUser, request) if err != nil { service.Error(c, err) @@ -333,7 +336,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) { return messages[i].ID > messages[j].ID } }) - //fmt.Printf("data is %+v\n", messages) + fmt.Printf("data is %+v\n", messages) total := 0 for i, message := range messages { switch request.Direction { diff --git a/pkg/service/asChat/logic/chat.go b/pkg/service/asChat/logic/chat.go index f3dd803..6fdd54e 100644 --- a/pkg/service/asChat/logic/chat.go +++ b/pkg/service/asChat/logic/chat.go @@ -40,7 +40,7 @@ func NewMessage(ctx context.Context, cache *chatCache.ChatCache, sender *account cacheMap[request.AtUserId] = request } else { fmt.Println(request.LocalStamp - msgRecord.LocalStamp) - if msgRecord.Message.Text == request.Message.Text && request.LocalStamp-msgRecord.LocalStamp < 20 { + if msgRecord.Message.Text == request.Message.Text && request.LocalStamp-msgRecord.LocalStamp < 10 { cacheMap[request.AtUserId] = request return nil } else { diff --git a/pkg/service/asChat/robot/ruler_keywords.go b/pkg/service/asChat/robot/ruler_keywords.go index 2aebdb0..cccc3d8 100644 --- a/pkg/service/asChat/robot/ruler_keywords.go +++ b/pkg/service/asChat/robot/ruler_keywords.go @@ -27,12 +27,6 @@ func NewReplyWhenHitKeywords(title string, keywords []string) IRobotTask { return &RobotTaskWithKeyworkds{title: title, keywords: keywords} } func (r *RobotTaskWithKeyworkds) Hit(event ws.ListenEventData, sender *accountFiee.ChatUserData) (hit bool) { - fmt.Printf("event.EventType != ws.EventChatMessage:%v\n", event.EventType != ws.EventChatMessage) - fmt.Printf("event.Msg == \"\":%v\n", event.Msg == "") - fmt.Printf("event.Client == nil:%v\n", event.Client == nil) - fmt.Printf("event.ChatUser == nil :%v\n", event.ChatUser == nil) - fmt.Printf("event.ChatUser.Role :%v\n", event.ChatUser.Role) - fmt.Printf("r.keywords :%v\n", r.keywords) if event.EventType != ws.EventChatMessage || event.Msg == "" || event.Client == nil || event.ChatUser == nil { return }