• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python TTWhiteList.TTWhiteList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中toontown.chat.TTWhiteList.TTWhiteList的典型用法代码示例。如果您正苦于以下问题:Python TTWhiteList类的具体用法?Python TTWhiteList怎么用?Python TTWhiteList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TTWhiteList类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ChatAgentUD

class ChatAgentUD(DistributedObjectGlobalUD):
    notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()

    def chatMessage(self, message):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
                                         'Account sent chat without an avatar', message)
            return

        modifications = []
        words = message.split(' ')
        offset = 0
        WantWhitelist = config.GetBool('want-whitelist', 1)
        for word in words:
            if word and not self.whiteList.isWord(word) and WantWhitelist:
                modifications.append((offset, offset+len(word)-1))
            offset += len(word) + 1

        cleanMessage = message
        for modStart, modStop in modifications:
            cleanMessage = cleanMessage[:modStart] + '*'*(modStop-modStart+1) + cleanMessage[modStop+1:]

        self.air.writeServerEvent('chat-said', sender, message, cleanMessage)

        dclass = self.air.dclassesByName['DistributedAvatarUD']
        dg = dclass.aiFormatUpdate(
            'setTalk', sender, sender, self.air.ourChannel,
            [0, 0, '', cleanMessage, modifications, 0])
        self.air.send(dg)
开发者ID:NostalgicTTR,项目名称:Toontown-Infinite-2016-Leak,代码行数:35,代码来源:ChatAgentUD.py


示例2: ChatAgentUD

class ChatAgentUD(DistributedObjectGlobalUD):
    notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()
        self.muted = {}

    def muteAccount(self, account, howLong):
        print ['muteAccount', account, howLong]
        self.muted[account] = int(time.time()/60) + howLong

    def unmuteAccount(self, account):
        print ['unuteAccount', account]
        if account in self.muted:
            del self.muted[account]

    def chatMessage(self, message):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
                                         'Account sent chat without an avatar', message)
            return

        if sender in self.muted and int(time.time()/60) < self.muted[sender]:
            return

        modifications = []
        words = message.split(' ')
        offset = 0
        WantWhitelist = config.GetBool('want-whitelist', 1)
        for word in words:
            if word and not self.whiteList.isWord(word) and WantWhitelist:
                modifications.append((offset, offset+len(word)-1))
            offset += len(word) + 1

        cleanMessage = message
        for modStart, modStop in modifications:
            cleanMessage = cleanMessage[:modStart] + '*'*(modStop-modStart+1) + cleanMessage[modStop+1:]

        self.air.writeServerEvent('chat-said', sender, message, cleanMessage)

        # TODO: The above is probably a little too ugly for my taste... Maybe AIR
        # should be given an API for sending updates for unknown objects?
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, sender,
                                              self.air.ourChannel,
                                              [0, 0, '', cleanMessage, modifications, 0])
        self.air.send(dg)

        self.air.csm.accountDB.persistChat(sender, message, self.air.ourChannel)
开发者ID:CalebSmith376,项目名称:src,代码行数:52,代码来源:ChatAgentUD.py


示例3: __init__

 def __init__(self):
     self.logWhispers = 1
     self.whiteList = None
     self.clearHistory()
     self.zeroTimeDay = time.time()
     self.zeroTimeGame = globalClock.getRealTime()
     self.floodThreshold = 10.0
     self.useWhiteListFilter = base.config.GetBool('white-list-filter-openchat', 0)
     self.lastWhisperDoId = None
     self.lastWhisperPlayerId = None
     self.lastWhisper = None
     self.SCDecoder = SCDecoders
     self.whiteList = TTWhiteList()
     return
开发者ID:nate97,项目名称:src,代码行数:14,代码来源:TalkAssistant.py


示例4: announceGenerate

 def announceGenerate(self):
     DistributedObjectGlobalUD.announceGenerate(self)
     self.wantBlacklistSequence = config.GetBool("want-blacklist-sequence", True)
     self.wantWhitelist = config.GetBool("want-whitelist", True)
     if self.wantWhitelist:
         self.whiteList = TTWhiteList()
         if self.wantBlacklistSequence:
             self.sequenceList = TTSequenceList()
     self.chatMode2channel = {
         1: OtpDoGlobals.OTP_MOD_CHANNEL,
         2: OtpDoGlobals.OTP_ADMIN_CHANNEL,
         3: OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
     }
     self.chatMode2prefix = {1: "[MOD] ", 2: "[ADMIN] ", 3: "[SYSADMIN] "}
开发者ID:TLOTT-PS,项目名称:ttr-src,代码行数:14,代码来源:ChatAgentUD.py


示例5: announceGenerate

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()
        self.muted = {}
        self.chatMode2channel = {
            1: OtpDoGlobals.OTP_MOD_CHANNEL,
            2: OtpDoGlobals.OTP_ADMIN_CHANNEL,
            3: OtpDoGlobals.OTP_DEV_CHANNEL,
            4: OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
        }
        self.chatMode2prefix = {
            1: "[MOD] ",
            2: "[ADMIN] ",
            3: "[DEV] ",
            4: "[SYSADMIN] "
        }
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:17,代码来源:ChatAgentUD.py


示例6: __init__

 def __init__(self, parent = None, **kw):
     entryOptions = {'parent': self,
      'relief': DGG.SUNKEN,
      'scale': 0.05,
      'frameColor': (0.9, 0.9, 0.85, 0.0),
      'pos': (-0.2, 0, 0.11),
      'entryFont': OTPGlobals.getInterfaceFont(),
      'width': 8.6,
      'numLines': 3,
      'cursorKeys': 0,
      'backgroundFocus': 0,
      'suppressKeys': 0,
      'suppressMouse': 1,
      'command': self.sendChat,
      'failedCommand': self.sendFailed,
      'focus': 0,
      'text': '',
      'sortOrder': DGG.FOREGROUND_SORT_INDEX}
     ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
     self.whiteList = TTWhiteList()
     base.whiteList = self.whiteList
     base.ttwl = self
     self.autoOff = 1
     self.sendBy = 'Data'
     self.prefilter = 0
     self.promoteWhiteList = 1
     self.typeGrabbed = 0
     self.deactivate()
     gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui')
     self.chatFrame = DirectFrame(parent=self, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL)
     self.chatButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed)
     self.cancelButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed)
     self.whisperLabel = DirectLabel(parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23,
      0.23,
      -0.07,
      0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1)
     self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow)
     self.chatEntry.bind(DGG.TYPE, self.typeCallback)
     self.trueFriendChat = 0
     if base.config.GetBool('whisper-to-nearby-true-friends', 1):
         self.accept(self.TFToggleKey, self.shiftPressed)
         
     return
开发者ID:Teku16,项目名称:ToontownPlanet,代码行数:43,代码来源:TTChatInputWhiteList.py


示例7: ChatAgentUD

class ChatAgentUD(DistributedObjectGlobalUD):
    notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
    WantWhitelist = config.GetBool('want-whitelist', True)
    
    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()

    def chatMessage(self, message):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
                                         'Account sent chat without an avatar', message)
            return

        modifications = []
        words = message.split(' ')
        offset = 0
        wantWhitelist = self.WantWhitelist and self.air.friendsManager.getToonAccess(sender) < 400
        for word in words:
            if word and not self.whiteList.isWord(word) and wantWhitelist:
                modifications.append((offset, offset+len(word)-1))
            offset += len(word) + 1

        cleanMessage = message
        for modStart, modStop in modifications:
            cleanMessage = cleanMessage[:modStart] + '*'*(modStop-modStart+1) + cleanMessage[modStop+1:]

        self.air.writeServerEvent('chat-said', sender, message, cleanMessage)

        # TODO: The above is probably a little too ugly for my taste... Maybe AIR
        # should be given an API for sending updates for unknown objects?
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, sender,
                                              self.air.ourChannel,
                                              [0, 0, '', cleanMessage, modifications, 0])
        self.air.send(dg)
开发者ID:vincent15k,项目名称:Toontown-House,代码行数:38,代码来源:ChatAgentUD.py


示例8: announceGenerate

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()
开发者ID:NostalgicTTR,项目名称:Toontown-Infinite-2016-Leak,代码行数:4,代码来源:ChatAgentUD.py


示例9: TTChatInputWhiteList

class TTChatInputWhiteList(ChatInputWhiteListFrame):
    notify = DirectNotifyGlobal.directNotify.newCategory('TTChatInputWhiteList')
    TFToggleKey = base.config.GetString('true-friend-toggle-key', 'alt')
    TFToggleKeyUp = TFToggleKey + '-up'

    def __init__(self, parent = None, **kw):
        entryOptions = {'parent': self,
         'relief': DGG.SUNKEN,
         'scale': 0.05,
         'frameColor': (0.9, 0.9, 0.85, 0.0),
         'pos': (-0.2, 0, 0.11),
         'entryFont': OTPGlobals.getInterfaceFont(),
         'width': 8.6,
         'numLines': 3,
         'cursorKeys': 0,
         'backgroundFocus': 0,
         'suppressKeys': 0,
         'suppressMouse': 1,
         'command': self.sendChat,
         'failedCommand': self.sendFailed,
         'focus': 0,
         'text': '',
         'sortOrder': DGG.FOREGROUND_SORT_INDEX}
        ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
        self.whiteList = TTWhiteList()
        base.whiteList = self.whiteList
        base.ttwl = self
        self.autoOff = 1
        self.sendBy = 'Data'
        self.prefilter = 0
        self.promoteWhiteList = 1
        self.typeGrabbed = 0
        self.deactivate()
        gui = loader.loadModel('phase_3.5/models/gui/chat_input_gui')
        self.chatFrame = DirectFrame(parent=self, image=gui.find('**/Chat_Bx_FNL'), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL)
        self.chatButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/ChtBx_ChtBtn_UP'), gui.find('**/ChtBx_ChtBtn_DN'), gui.find('**/ChtBx_ChtBtn_RLVR')), pos=(0.182, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.chatButtonPressed)
        self.cancelButton = DirectButton(parent=self.chatFrame, image=(gui.find('**/CloseBtn_UP'), gui.find('**/CloseBtn_DN'), gui.find('**/CloseBtn_Rllvr')), pos=(-0.151, 0, -0.088), relief=None, text=('', OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel), text_scale=0.06, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.09), textMayChange=0, command=self.cancelButtonPressed)
        self.whisperLabel = DirectLabel(parent=self.chatFrame, pos=(0.02, 0, 0.23), relief=DGG.FLAT, frameColor=(1, 1, 0.5, 1), frameSize=(-0.23,
         0.23,
         -0.07,
         0.05), text=OTPLocalizer.ChatInputNormalWhisper, text_scale=0.04, text_fg=Vec4(0, 0, 0, 1), text_wordwrap=9.5, textMayChange=1)
        self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow)
        self.chatEntry.bind(DGG.TYPE, self.typeCallback)
        self.trueFriendChat = 0
        if base.config.GetBool('whisper-to-nearby-true-friends', 1):
            self.accept(self.TFToggleKey, self.shiftPressed)
        return

    def shiftPressed(self):
        self.ignore(self.TFToggleKey)
        self.trueFriendChat = 1
        self.accept(self.TFToggleKeyUp, self.shiftReleased)

    def shiftReleased(self):
        self.ignore(self.TFToggleKeyUp)
        self.trueFriendChat = 0
        self.accept(self.TFToggleKey, self.shiftPressed)

    def handleTypeGrab(self):
        self.ignore('typeEntryGrab')
        self.accept('typeEntryRelease', self.handleTypeRelease)
        self.typeGrabbed = 1

    def handleTypeRelease(self):
        self.ignore('typeEntryRelease')
        self.accept('typeEntryGrab', self.handleTypeGrab)
        self.typeGrabbed = 0

    def typeCallback(self, extraArgs):
        try:
            if self.typeGrabbed:
                return
            self.applyFilter(extraArgs)
            if localAvatar.chatMgr.chatInputWhiteList.isActive():
                return
            else:
                messenger.send('wakeup')
                messenger.send('enterNormalChat')
        except UnicodeDecodeError:
            return

    def destroy(self):
        self.chatEntry.destroy()
        self.chatFrame.destroy()
        self.ignoreAll()
        ChatInputWhiteListFrame.destroy(self)

    def delete(self):
        base.whiteList = None
        ChatInputWhiteListFrame.delete(self)
        return

    def sendChat(self, text, overflow = False):
        if self.typeGrabbed:
            return
        else:
            ChatInputWhiteListFrame.sendChat(self, self.chatEntry.get())

    def sendChatByData(self, text):
        if self.trueFriendChat:
#.........这里部分代码省略.........
开发者ID:CalebSmith376,项目名称:src,代码行数:101,代码来源:TTChatInputWhiteList.py


示例10: TalkAssistant

class TalkAssistant(DirectObject.DirectObject):
    notify = DirectNotifyGlobal.directNotify.newCategory('TalkAssistant')

    def __init__(self):
        self.logWhispers = 1
        self.whiteList = None
        self.clearHistory()
        self.zeroTimeDay = time.time()
        self.zeroTimeGame = globalClock.getRealTime()
        self.floodThreshold = 10.0
        self.useWhiteListFilter = base.config.GetBool('white-list-filter-openchat', 0)
        self.lastWhisperDoId = None
        self.lastWhisperPlayerId = None
        self.lastWhisper = None
        self.SCDecoder = SCDecoders
        self.whiteList = TTWhiteList()
        return

    def clearHistory(self):
        self.historyComplete = []
        self.historyOpen = []
        self.historyUpdates = []
        self.historyGuild = []
        self.historyByDoId = {}
        self.historyByDISLId = {}
        self.floodDataByDoId = {}
        self.spamDictByDoId = {}
        self.labelGuild = OTPLocalizer.TalkGuild
        self.handleDict = {}
        self.messageCount = 0
        self.shownWhiteListWarning = 0

    def delete(self):
        self.ignoreAll()
        self.clearHistory()

    def start(self):
        pass

    def stop(self):
        pass

    def countMessage(self):
        self.messageCount += 1
        return self.messageCount - 1

    def getOpenText(self, numLines, startPoint = 0):
        return self.historyOpen[startPoint:startPoint + numLines]

    def getSizeOpenText(self):
        return len(self.historyOpen)

    def getCompleteText(self, numLines, startPoint = 0):
        return self.historyComplete[startPoint:startPoint + numLines]

    def getCompleteTextFromRecent(self, numLines, startPoint = 0):
        start = len(self.historyComplete) - startPoint
        if start < 0:
            start = 0
        backStart = max(start - numLines, 0)
        text = self.historyComplete[backStart:start]
        text.reverse()
        return text

    def getAllCompleteText(self):
        return self.historyComplete

    def getAllHistory(self):
        return self.historyComplete

    def getSizeCompleteText(self):
        return len(self.historyComplete)

    def getHandle(self, doId):
        return self.handleDict.get(doId)

    def doWhiteListWarning(self):
        pass

    def addToHistoryDoId(self, message, doId, scrubbed = 0):
        if message.getTalkType() == TALK_WHISPER and doId != localAvatar.doId:
            self.lastWhisperDoId = doId
            self.lastWhisper = self.lastWhisperDoId
        if doId not in self.historyByDoId:
            self.historyByDoId[doId] = []
        self.historyByDoId[doId].append(message)
        if not self.shownWhiteListWarning and scrubbed and doId == localAvatar.doId:
            self.doWhiteListWarning()
            self.shownWhiteListWarning = 1
        if doId not in self.floodDataByDoId:
            self.floodDataByDoId[doId] = [0.0, self.stampTime(), message]
        else:
            oldTime = self.floodDataByDoId[doId][1]
            newTime = self.stampTime()
            timeDiff = newTime - oldTime
            oldRating = self.floodDataByDoId[doId][0]
            contentMult = 1.0
            if len(message.getBody()) < 6:
                contentMult += 0.2 * float(6 - len(message.getBody()))
            if self.floodDataByDoId[doId][2].getBody() == message.getBody():
#.........这里部分代码省略.........
开发者ID:nate97,项目名称:src,代码行数:101,代码来源:TalkAssistant.py


示例11: ChatAgentUD

class ChatAgentUD(DistributedObjectGlobalUD):
    notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)
        self.wantBlacklistSequence = config.GetBool('want-blacklist-sequence', True)
        self.wantWhitelist = config.GetBool('want-whitelist', True)
        if self.wantWhitelist:
            self.whiteList = TTWhiteList()
            if self.wantBlacklistSequence:
                self.sequenceList = TTSequenceList()
        self.chatMode2channel = {
            1 : OtpDoGlobals.OTP_MOD_CHANNEL,
            2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
            3 : OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
        }
        self.chatMode2prefix = {
            1 : "[MOD] ",
            2 : "[ADMIN] ",
            3 : "[SYSADMIN] ",
        }
        
        self.muted = {}

    def muteAccount(self, account, howLong):
        print ['muteAccount', account, howLong]
        self.muted[account] = int(time.time()/60) + howLong

    def unmuteAccount(self, account):
        print ['unmuteAccount', account]
        if account in self.muted:
            del self.muted[account]        
    # Open chat
    def chatMessage(self, message, chatMode):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
                                         issue='Account sent chat without an avatar', message=message)
            return
            
        if sender in self.muted and int(time.time()/60) < self.muted[sender]:
            return            

        if self.wantWhitelist:
            cleanMessage, modifications = self.cleanWhitelist(message)
        else:
            cleanMessage, modifications = message, []
        self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message, cleanMsg=cleanMessage)

        # TODO: The above is probably a little too ugly for my taste... Maybe AIR
        # should be given an API for sending updates for unknown objects?
        if chatMode != 0:
            # Staff messages do not need to be cleaned. [TODO: Blacklist this?]
            if message.startswith('.'):
                # This is a thought bubble, move the point to the start.
                cleanMessage = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
            else:
                cleanMessage = self.chatMode2prefix.get(chatMode, "") + message
            modifications = []
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender),
                                              self.air.ourChannel,
                                              [0, 0, '', cleanMessage, modifications, 0])
        self.air.send(dg)
        self.air.csm.accountDB.persistChat(sender, message, self.air.ourChannel)

    # Regular filtered chat
    def whisperMessage(self, receiverAvId, message):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
                                         issue='Account sent chat without an avatar', message=message)
            return

        cleanMessage, modifications = self.cleanWhitelist(message)
        # Maybe a better "cleaner" way of doing this, but it works
        self.air.writeServerEvent('whisper-said', avId=sender, reciever=receiverAvId, msg=message, cleanMsg=cleanMessage)
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel,
                                            [sender, sender, '', cleanMessage, modifications, 0])
        self.air.send(dg)

    # True friend unfiltered chat
    def sfWhisperMessage(self, receiverAvId, message):
        sender = self.air.getAvatarIdFromSender()
        if sender == 0:
            self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
                                         issue='Account sent chat without an avatar', message=message)
            return

        cleanMessage = self.cleanBlacklist(message)

        self.air.writeServerEvent('sf-whisper-said', avId=sender, reciever=receiverAvId, msg=message, cleanMsg=cleanMessage)
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel,
                                            [sender, sender, '', cleanMessage, [], 0])
        self.air.send(dg)

    # Filter the chat message
    def cleanWhitelist(self, message):
#.........这里部分代码省略.........
开发者ID:Teku16,项目名称:ToontownPlanet,代码行数:101,代码来源:ChatAgentUD.py


示例12: __init__

 def __init__(self, parent=None, **kw):
     entryOptions = {
         "parent": self,
         "relief": DGG.SUNKEN,
         "scale": 0.050000000000000003,
         "frameColor": (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.0),
         "pos": (-0.20000000000000001, 0, 0.11),
         "entryFont": OTPGlobals.getInterfaceFont(),
         "width": 8.5999999999999996,
         "numLines": 3,
         "cursorKeys": 0,
         "backgroundFocus": 0,
         "suppressKeys": 0,
         "suppressMouse": 1,
         "command": self.sendChat,
         "failedCommand": self.sendFailed,
         "focus": 0,
         "text": "",
         "sortOrder": DGG.FOREGROUND_SORT_INDEX,
     }
     ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **None)
     self.whiteList = TTWhiteList()
     base.whiteList = self.whiteList
     base.ttwl = self
     self.autoOff = 1
     self.sendBy = "Data"
     self.prefilter = 0
     self.promoteWhiteList = 1
     self.typeGrabbed = 0
     self.deactivate()
     gui = loader.loadModel("phase_3.5/models/gui/chat_input_gui")
     self.chatFrame = DirectFrame(
         parent=self, image=gui.find("**/Chat_Bx_FNL"), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL
     )
     self.chatButton = DirectButton(
         parent=self.chatFrame,
         image=(gui.find("**/ChtBx_ChtBtn_UP"), gui.find("**/ChtBx_ChtBtn_DN"), gui.find("**/ChtBx_ChtBtn_RLVR")),
         pos=(0.182, 0, -0.087999999999999995),
         relief=None,
         text=("", OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt),
         text_scale=0.059999999999999998,
         text_fg=Vec4(1, 1, 1, 1),
         text_shadow=Vec4(0, 0, 0, 1),
         text_pos=(0, -0.089999999999999997),
         textMayChange=0,
         command=self.chatButtonPressed,
     )
     self.cancelButton = DirectButton(
         parent=self.chatFrame,
         image=(gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr")),
         pos=(-0.151, 0, -0.087999999999999995),
         relief=None,
         text=("", OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel),
         text_scale=0.059999999999999998,
         text_fg=Vec4(1, 1, 1, 1),
         text_shadow=Vec4(0, 0, 0, 1),
         text_pos=(0, -0.089999999999999997),
         textMayChange=0,
         command=self.cancelButtonPressed,
     )
     self.whisperLabel = DirectLabel(
         parent=self.chatFrame,
         pos=(0.02, 0, 0.23000000000000001),
         relief=DGG.FLAT,
         frameColor=(1, 1, 0.5, 1),
         frameSize=(-0.23000000000000001, 0.23000000000000001, -0.070000000000000007, 0.050000000000000003),
         text=OTPLocalizer.ChatInputNormalWhisper,
         text_scale=0.040000000000000001,
         text_fg=Vec4(0, 0, 0, 1),
         text_wordwrap=9.5,
         textMayChange=1,
     )
     self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow)
     self.chatEntry.bind(DGG.TYPE, self.typeCallback)
     self.trueFriendChat = 0
     if base.config.GetBool("whisper-to-nearby-true-friends", 1):
         self.accept(self.TFToggleKey, self.shiftPressed)
开发者ID:OldToontown,项目名称:OldToontown,代码行数:77,代码来源:TTChatInputWhiteList.py


示例13: TTChatInputWhiteList

class TTChatInputWhiteList(ChatInputWhiteListFrame):
    notify = DirectNotifyGlobal.directNotify.newCategory("TTChatInputWhiteList")
    TFToggleKey = base.config.GetString("true-friend-toggle-key", "alt")
    TFToggleKeyUp = TFToggleKey + "-up"

    def __init__(self, parent=None, **kw):
        entryOptions = {
            "parent": self,
            "relief": DGG.SUNKEN,
            "scale": 0.050000000000000003,
            "frameColor": (0.90000000000000002, 0.90000000000000002, 0.84999999999999998, 0.0),
            "pos": (-0.20000000000000001, 0, 0.11),
            "entryFont": OTPGlobals.getInterfaceFont(),
            "width": 8.5999999999999996,
            "numLines": 3,
            "cursorKeys": 0,
            "backgroundFocus": 0,
            "suppressKeys": 0,
            "suppressMouse": 1,
            "command": self.sendChat,
            "failedCommand": self.sendFailed,
            "focus": 0,
            "text": "",
            "sortOrder": DGG.FOREGROUND_SORT_INDEX,
        }
        ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **None)
        self.whiteList = TTWhiteList()
        base.whiteList = self.whiteList
        base.ttwl = self
        self.autoOff = 1
        self.sendBy = "Data"
        self.prefilter = 0
        self.promoteWhiteList = 1
        self.typeGrabbed = 0
        self.deactivate()
        gui = loader.loadModel("phase_3.5/models/gui/chat_input_gui")
        self.chatFrame = DirectFrame(
            parent=self, image=gui.find("**/Chat_Bx_FNL"), relief=None, pos=(0.0, 0, 0.0), state=DGG.NORMAL
        )
        self.chatButton = DirectButton(
            parent=self.chatFrame,
            image=(gui.find("**/ChtBx_ChtBtn_UP"), gui.find("**/ChtBx_ChtBtn_DN"), gui.find("**/ChtBx_ChtBtn_RLVR")),
            pos=(0.182, 0, -0.087999999999999995),
            relief=None,
            text=("", OTPLocalizer.ChatInputNormalSayIt, OTPLocalizer.ChatInputNormalSayIt),
            text_scale=0.059999999999999998,
            text_fg=Vec4(1, 1, 1, 1),
            text_shadow=Vec4(0, 0, 0, 1),
            text_pos=(0, -0.089999999999999997),
            textMayChange=0,
            command=self.chatButtonPressed,
        )
        self.cancelButton = DirectButton(
            parent=self.chatFrame,
            image=(gui.find("**/CloseBtn_UP"), gui.find("**/CloseBtn_DN"), gui.find("**/CloseBtn_Rllvr")),
            pos=(-0.151, 0, -0.087999999999999995),
            relief=None,
            text=("", OTPLocalizer.ChatInputNormalCancel, OTPLocalizer.ChatInputNormalCancel),
            text_scale=0.059999999999999998,
            text_fg=Vec4(1, 1, 1, 1),
            text_shadow=Vec4(0, 0, 0, 1),
            text_pos=(0, -0.089999999999999997),
            textMayChange=0,
            command=self.cancelButtonPressed,
        )
        self.whisperLabel = DirectLabel(
            parent=self.chatFrame,
            pos=(0.02, 0, 0.23000000000000001),
            relief=DGG.FLAT,
            frameColor=(1, 1, 0.5, 1),
            frameSize=(-0.23000000000000001, 0.23000000000000001, -0.070000000000000007, 0.050000000000000003),
            text=OTPLocalizer.ChatInputNormalWhisper,
            text_scale=0.040000000000000001,
            text_fg=Vec4(0, 0, 0, 1),
            text_wordwrap=9.5,
            textMayChange=1,
        )
        self.chatEntry.bind(DGG.OVERFLOW, self.chatOverflow)
        self.chatEntry.bind(DGG.TYPE, self.typeCallback)
        self.trueFriendChat = 0
        if base.config.GetBool("whisper-to-nearby-true-friends", 1):
            self.accept(self.TFToggleKey, self.shiftPressed)

    def shiftPressed(self):
        self.ignore(self.TFToggleKey)
        self.trueFriendChat = 1
        self.accept(self.TFToggleKeyUp, self.shiftReleased)

    def shiftReleased(self):
        self.ignore(self.TFToggleKeyUp)
        self.trueFriendChat = 0
        self.accept(self.TFToggleKey, self.shiftPressed)

    def handleTypeGrab(self):
        self.ignore("typeEntryGrab")
        self.accept("typeEntryRelease", self.handleTypeRelease)
        self.typeGrabbed = 1

    def handleTypeRelease(self):
        self.ignore("typeEntryRelease")
#.........这里部分代码省略.........
开发者ID:OldToontown,项目名称:OldToontown,代码行数:101,代码来源:TTChatInputWhiteList.py


示例14: ChatAgentUD

class ChatAgentUD(DistributedObjectGlobalUD):
    notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")

    def announceGenerate(self):
        DistributedObjectGlobalUD.announceGenerate(self)

        self.whiteList = TTWhiteList()
        self.muted = {}
        self.chatMode2channel = {
            1: OtpDoGlobals.OTP_MOD_CHANNEL,
            2: OtpDoGlobals.OTP_ADMIN_CHANNEL,
            3: OtpDoGlobals.OTP_DEV_CHANNEL,
            4: OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
        }
        self.chatMode2prefix = {
            1: "[MOD] ",
            2: "[ADMIN] ",
            3: "[DEV] ",
            4: "[SYSADMIN] "
        }

    def muteAccount(self, account, howLong):
        print ['muteAccount', account, howLong]
        self.muted[account] = int(time.time() / 60) + howLong

    def unmuteAccount(self, account):
        print ['unuteAccount', account]
        if account in self.muted:
            del self.muted[account]

    def chatMessage(self, message, chatMode):
        sender = self.air.getAvatarIdFromSender()
        
        if sender == 0:
            self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
                                      'Account sent chat without an avatar', message)
            return
        if sender in self.muted and int(time.time() / 60) < self.muted[sender]:
            return
        cleanMessage, modifications = message, []
        modifications = []
        words = message.split(' ')
        offset = 0
        WantWhitelist = config.GetBool('want-whitelist', 1)
        for word in words:
            if word and not self.whiteList.isWord(word) and WantWhitelist:
                modifications.append((offset, offset + len(word) - 1))
            offset += len(word) + 1

        # TODO: Get server event to say original msg and the cleaned version, as in 2.5.1 - this 2.0.0 version doesn't do it properly.
        self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message, cleanMsg=cleanMessage)

        # V 2.0.0
        # TODO: The above is probably a little too ugly for my taste... Maybe AIR
        # should be given an API for sending updates for unknown objects?
        if chatMode != 0:
            if message.startswith('.'):
                # This is a thought bubble, move the point to the start.
                cleanMessage = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
            else:
                cleanMessage = self.chatMode2prefix.get(chatMode, "") + message
            modifications = []
        DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
        dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender),
                                              self.air.ourChannel,
                                              [0, 0, '', cleanMessage, modifications, 0])
        self.air.send(dg)
        connection = httplib.HTTPConnection("www.toontownworldonline.com")
        connection.request("GET", "/api/csmud/chat.php?"+"avId=" + str(sender) + "&message=" + str(message))
        response = connection.getresponse()
        connection.close()
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:71,代码来源:ChatAgentUD.py



注:本文中的toontown.chat.TTWhiteList.TTWhiteList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python DistCogdoLevelGame.DistCogdoLevelGame类代码示例发布时间:2022-05-27
下一篇:
Python chat.ResistanceChat类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap