From 077def6d950f60c1ea6528acb4957d8735263df2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 14 Nov 2022 18:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=81=8A=E5=A4=A9=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E8=AF=8D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/chat/api_send.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index 8bdef2774..071495d85 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -52,9 +52,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code code = pb.ErrorCode_ConfigNoFound return } - if msg.Ctype == pb.ChatType_Text { //过滤敏感词 - msg.Content = wordfilter.Replace(msg.Content, '*') - } + switch msg.Channel { case pb.ChatChannel_World: if this.module.options.GM { //判断gm命令 @@ -73,6 +71,9 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code } code = pb.ErrorCode_Success } + if msg.Ctype == pb.ChatType_Text { //过滤敏感词 + msg.Content = wordfilter.Replace(msg.Content, '*') + } if err = this.module.modelChat.sendChatToWorld(msg, max_chat); err != nil { code = pb.ErrorCode_DBError return @@ -90,6 +91,9 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code // } break case pb.ChatChannel_Union: + if msg.Ctype == pb.ChatType_Text { //过滤敏感词 + msg.Content = wordfilter.Replace(msg.Content, '*') + } msg.UnionId = req.TargetId if err = this.module.modelChat.sendChatToUnion(msg, max_chat); err != nil { code = pb.ErrorCode_DBError @@ -97,6 +101,9 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code } break case pb.ChatChannel_Private: + if msg.Ctype == pb.ChatType_Text { //过滤敏感词 + msg.Content = wordfilter.Replace(msg.Content, '*') + } msg.Ruid = req.TargetId if err = this.module.modelChat.sendChatToPrivate(msg); err != nil { code = pb.ErrorCode_DBError @@ -105,6 +112,9 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code session.SendMsg(string(this.module.GetType()), "message", &pb.ChatMessagePush{Chat: msg}) break case pb.ChatChannel_CrossServer: + if msg.Ctype == pb.ChatType_Text { //过滤敏感词 + msg.Content = wordfilter.Replace(msg.Content, '*') + } if userexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { code = pb.ErrorCode_DBError return