diff --git a/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java index 7bc348fea..1ee56134d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java @@ -19,6 +19,7 @@ import com.ljsd.jieling.protocols.ChatProto; import com.ljsd.jieling.protocols.MessageTypeProto; import com.ljsd.jieling.util.CBean2Proto; import com.ljsd.jieling.util.MessageUtil; +import com.ljsd.jieling.util.SensitivewordFilter; import com.ljsd.jieling.util.ShieldedWordUtils; import java.util.ArrayList; @@ -99,18 +100,20 @@ public class ChatLogic { } FriendManager friendManager = user.getFriendManager(); boolean result = true; + long nowTime = System.currentTimeMillis(); + switch (chatType){ case 1: //0|content需要解字符串 String s = message; - String[] strs = message.split("|",3); + String[] strs = message.split("\\|",3); if(strs.length==3){ - s = strs[2]; + message = strs[2]; } - result = ShieldedWordUtils.checkName(user,s,false,ChatContentType.WORLD_CHAT); + result = ShieldedWordUtils.checkName(user,message,false,ChatContentType.WORLD_CHAT); break; case 2: - result= ShieldedWordUtils.checkName(user,message,false,ChatContentType.FAMILY); + result = ShieldedWordUtils.checkName(user,message,false,ChatContentType.FAMILY); break; case 3: result = ShieldedWordUtils.checkName(user,message,false,ChatContentType.PRIVATE_CHAT,UserManager.getUser(friendId)); @@ -119,10 +122,14 @@ public class ChatLogic { break; } if (!result) { - MessageUtil.sendErrorResponse(iSession, 0, msgId, "包含敏感字"); + String s = SensitivewordFilter.replaceSensitiveWord(message, 1, "*"); +// MessageUtil.sendErrorResponse(iSession, 0, msgId, "包含敏感字"); + ChatProto.ChatInfo chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,-1); + ChatProto.SendChatInfoResponse response = ChatProto.SendChatInfoResponse.newBuilder().setChatInfo(chatInfo).build(); + MessageUtil.sendMessage(iSession,1,msgId,response,true); return ; } - long nowTime = System.currentTimeMillis(); + switch (chatType){ case 1: //世界 long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_WORD_MSG_ID + GameApplication.serverId);