上传聊天敏感词调整

This commit is contained in:
liwei1dao 2022-11-14 18:11:26 +08:00
parent d84a7262b8
commit 077def6d95

View File

@ -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