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