本文整理汇总了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)
示例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)
示例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
示例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] "}
示例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] "
}
示例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
示例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)
示例8: announceGenerate
def announceGenerate(self):
DistributedObjectGlobalUD.announceGenerate(self)
self.whiteList = TTWhiteList()
示例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:
#.........这里部分代码省略.........
示例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():
#.........这里部分代码省略.........
示例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):
#.........这里部分代码省略.........
示例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)
示例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")
#.........这里部分代码省略.........
示例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()