Beispiel #1
0
    def onTableChat(self, gameId, msg):
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        table = msg.getParam("table")
        userId = msg.getParam("userId")
        seatIndex = msg.getParam("seatId")
        isFace = msg.getParam("isFace")
        voiceIdx = msg.getParam("voiceIdx")
        chatMsg = msg.getParam("msg")

        player = table.players[seatIndex]
        if player.userId != userId:
            ftlog.warn(table._baseLogStr("onTableChat player.userId != userId!", userId),
                       "|seatIndex, player:", seatIndex, player.userId, caller=self)
            return False

        if isFace == 0:
            # 纯文本内容
            chatMsg = keywords.replace(chatMsg[:80])  # 80个字符长度限制
            if difangConf.isEnableLogChatMsg(gameId):
                hallchatlog.reportChatLog(userId, chatMsg, self.gameId, table.roomId, table.tableId, seatIndex,
                                          userName=player.name, roomName=table.room.roomConf.get('name'))
                ftlog.info('onTableChat |gameId, tableId, userId, name, chatMsg:',
                           gameId, table.tableId, player.userId, player.name, chatMsg, caller=self)

        self.sendTableChatResToAll(table, player, isFace, voiceIdx, chatMsg)
Beispiel #2
0
    def _doTableChat(self, userId, seatId, isFace, voiceIdx, chatMsg):
        """
        聊天的逻辑
        1)文字聊天
        {
            "cmd": "table_chat",
            "params": {
                "roomId": 7108021001,
                "tableId": 71080210010100,
                "seatId": 1,
                "isFace": 0,
                "msg": {
                    "seatId": 1,
                    "type": 0,
                    "content": "abc"
                },
                "gameId": 710,
                "userId": 10856,
                "clientId": "IOS_3.91_tuyoo.appStore,weixinPay,alipay.0-hall6.appStore.huanle"
            }
        }
        
        2)语音聊天
        {
            "cmd": "table_chat",
            "params": {
                "roomId": 7108021001,
                "tableId": 71080210010100,
                "seatId": 1,
                "isFace": 0,
                "msg": {
                    "seatId": 1,
                    "type": 2,
                    "emoId": 1,
                    "targetSeatId": 0
                },
                "gameId": 710,
                "userId": 10856,
                "clientId": "      IOS_3.91_tuyoo.appStore,weixinPay,alipay.0-hall6.appStore.huanle"
            }
        }
        """
        if not chatMsg:
            return

        if isFace == 0 and 'type' in chatMsg and chatMsg['type'] == 0:  # 麻将文字聊天消息
            content = chatMsg['content']
            filterContent = keywords.replace(content)
            chatMsg['content'] = filterContent

        if isFace == 0:
            users = self.logic_table.getBroadCastUIDs()
            self.logic_table.msgProcessor.table_chat_broadcast(userId, self.gameId, voiceIdx, chatMsg, users)
        else:
            for seat in self.maxSeatN:
                player = self.logic_table.getPlayer(seat)
                self.logic_table.msgProcessor.table_chat_to_face(userId, self.gameId, voiceIdx, chatMsg, player)
Beispiel #3
0
def DATA_TYPE_STR_FILTER(field, value, defaultVal, recovers):
    '''
    字符串, 缺省为空串, 如果有值则进行关键字过滤
    '''
    try:
        if value != None:
            return keywords.replace(unicode(value))
    except:
        if ftlog.is_debug():
            ftlog.error()
    if recovers != None:
        recovers.append(field)
        recovers.append(defaultVal)
    assert (isinstance(defaultVal,
                       (str, unicode))), 'DATA_TYPE_STR_FILTER type, defaultVal must be str or unicode, field=' + str(
        field)
    return defaultVal
Beispiel #4
0
    def onTableChat(self, gameId, msg):
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        table = msg.getParam("table")
        userId = msg.getParam("userId")
        seatIndex = msg.getParam("seatId")
        isFace = msg.getParam("isFace")
        voiceIdx = msg.getParam("voiceIdx")
        chatMsg = msg.getParam("msg")

        player = table.players[seatIndex]
        if player.userId != userId:
            ftlog.warn(table._baseLogStr(
                "onTableChat player.userId != userId!", userId),
                       "|seatIndex, player:",
                       seatIndex,
                       player.userId,
                       caller=self)
            return False

        if isFace == 0:
            # 纯文本内容
            chatMsg = keywords.replace(chatMsg[:80])  # 80个字符长度限制
            if difangConf.isEnableLogChatMsg(gameId):
                hallchatlog.reportChatLog(
                    userId,
                    chatMsg,
                    self.gameId,
                    table.roomId,
                    table.tableId,
                    seatIndex,
                    userName=player.name,
                    roomName=table.room.roomConf.get('name'))
                ftlog.info(
                    'onTableChat |gameId, tableId, userId, name, chatMsg:',
                    gameId,
                    table.tableId,
                    player.userId,
                    player.name,
                    chatMsg,
                    caller=self)

        self.sendTableChatResToAll(table, player, isFace, voiceIdx, chatMsg)
Beispiel #5
0
    def doTableChat(self, userId, seatId, isFace, voiceIdx, chatMsg):
        player = None
        if seatId > 0 and seatId <= self.maxSeatN:
            player = self.players[seatId - 1]
            if (userId != player.userId):
                ftlog.warn('doTableChat, the userId is wrong !', userId,
                           seatId, 'player.userId=', player.userId)
                return
        else:
            ftlog.warn('doTableChat, the seatId is wrong !', userId, seatId)
            return

        if isFace == 2 and self.isFriendTable():
            for p in self.players:
                if p.userId > 0 and p.datas:
                    self.gamePlay.sender.sendTableChat(player, isFace,
                                                       voiceIdx, chatMsg,
                                                       p.userId,
                                                       p.datas['name'])
            return

        chatMsg = chatMsg[:80]  # 80个字符长度限制
        if isFace == 0:
            # 纯文本内容
            chatMsg = keywords.replace(chatMsg)
            if dizhuconf.isEnableLogChatMsg():
                username = player.datas.get('name', '')
                hallchatlog.reportChatLog(userId,
                                          chatMsg,
                                          self.gameId,
                                          self.roomId,
                                          self.tableId,
                                          seatId,
                                          userName=username,
                                          roomName=self.room.roomConf['name'])
                ftlog.info(
                    'tableChatLog gameId=%s; room="%s"; table=%s; userId=%s; name="%s"; msg="%s"'
                    % (DIZHU_GAMEID, self.room.roomConf['name'], self.tableId,
                       player.userId, username, chatMsg))
            if self.gameRound:
                self.gameRound.chat(seatId - 1, isFace, voiceIdx, chatMsg)
            for p in self.players:
                toUserId = p.userId
                if toUserId > 0 and p.datas:
                    self.gamePlay.sender.sendTableChat(player, isFace,
                                                       voiceIdx, chatMsg,
                                                       toUserId,
                                                       p.datas['name'])
            return

        if isFace == 1:
            # 表情图片
            chatMsg = bug_fix._bugFixFilterChatMsgForVer27(chatMsg)
            if self.gameRound:
                self.gameRound.chat(seatId - 1, isFace, voiceIdx, chatMsg)
            for p in self.players:
                toUserId = p.userId
                if toUserId > 0:
                    msgToUser = chatMsg
                    if toUserId != player.userId:
                        msgToUser = bug_fix._bugFixFilterChatMsgForPNG(
                            toUserId, chatMsg)
                    if msgToUser and p.datas:
                        self.gamePlay.sender.sendTableChat(
                            player, isFace, voiceIdx, msgToUser, toUserId,
                            p.datas['name'])
            return
Beispiel #6
0
def filterValue(attr, value):
    """过滤的值"""
    if attr in daoconst.FILTER_KEYWORD_FIELDS:
        value = unicode(value)
        return keywords.replace(value)
    return value
Beispiel #7
0
def filterValue(attr, value):
    if attr in daoconst.FILTER_KEYWORD_FIELDS:
        value = unicode(value)
        return keywords.replace(value)
    return value