本文整理汇总了Python中toontown.chat.TTWhiteList.TTWhiteList.isPrefix方法的典型用法代码示例。如果您正苦于以下问题:Python TTWhiteList.isPrefix方法的具体用法?Python TTWhiteList.isPrefix怎么用?Python TTWhiteList.isPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toontown.chat.TTWhiteList.TTWhiteList
的用法示例。
在下文中一共展示了TTWhiteList.isPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TTChatInputWhiteList
# 需要导入模块: from toontown.chat.TTWhiteList import TTWhiteList [as 别名]
# 或者: from toontown.chat.TTWhiteList.TTWhiteList import isPrefix [as 别名]
#.........这里部分代码省略.........
elif self.receiverId and not self.toPlayer:
base.talkAssistant.sendWhisperTalk(text, self.receiverId)
elif self.receiverId and self.toPlayer:
base.talkAssistant.sendAccountTalk(text, self.receiverId)
def sendWhisperByFriend(self, avatarId, text):
online = 0
if avatarId in base.cr.doId2do:
online = 1
avatarUnderstandable = 0
av = None
if avatarId:
av = base.cr.identifyAvatar(avatarId)
if av != None:
avatarUnderstandable = av.isUnderstandable()
if avatarUnderstandable and online:
base.talkAssistant.sendWhisperTalk(text, avatarId)
return
def chatButtonPressed(self):
if self.okayToSubmit:
self.sendChat(self.chatEntry.get())
else:
self.sendFailed(self.chatEntry.get())
def cancelButtonPressed(self):
self.requestMode('Off')
localAvatar.chatMgr.fsm.request('mainMenu')
def enterAllChat(self):
ChatInputWhiteListFrame.enterAllChat(self)
self.whisperLabel.hide()
def exitAllChat(self):
ChatInputWhiteListFrame.exitAllChat(self)
def enterPlayerWhisper(self):
ChatInputWhiteListFrame.enterPlayerWhisper(self)
self.labelWhisper()
def exitPlayerWhisper(self):
ChatInputWhiteListFrame.exitPlayerWhisper(self)
self.whisperLabel.hide()
def enterAvatarWhisper(self):
ChatInputWhiteListFrame.enterAvatarWhisper(self)
self.labelWhisper()
def exitAvatarWhisper(self):
ChatInputWhiteListFrame.exitAvatarWhisper(self)
self.whisperLabel.hide()
def labelWhisper(self):
if self.receiverId:
self.whisperName = base.talkAssistant.findName(self.receiverId, self.toPlayer)
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
self.whisperLabel.show()
else:
self.whisperLabel.hide()
def applyFilter(self, keyArgs, strict = False):
text = self.chatEntry.get(plain=True)
if text.startswith('~'):
self.okayToSubmit = True
else:
words = text.split(' ')
newwords = []
self.okayToSubmit = True
flag = 0
for friendId, flags in base.localAvatar.friendsList:
if flags & ToontownGlobals.FriendChat:
flag = 1
for word in words:
if word == '' or self.whiteList.isWord(word) or not base.cr.whiteListChatEnabled:
newwords.append(word)
else:
if self.checkBeforeSend:
self.okayToSubmit = False
else:
self.okayToSubmit = True
if flag:
newwords.append('\x01WLDisplay\x01' + word + '\x02')
else:
newwords.append('\x01WLEnter\x01' + word + '\x02')
if not strict:
lastword = words[-1]
try:
if lastword == '' or self.whiteList.isPrefix(lastword) or not base.cr.whiteListChatEnabled:
newwords[-1] = lastword
elif flag:
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'
else:
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
except UnicodeDecodeError:
self.okayToSubmit = False
newtext = ' '.join(newwords)
self.chatEntry.set(newtext)
self.chatEntry.guiItem.setAcceptEnabled(self.okayToSubmit)
示例2: TTChatInputWhiteList
# 需要导入模块: from toontown.chat.TTWhiteList import TTWhiteList [as 别名]
# 或者: from toontown.chat.TTWhiteList.TTWhiteList import isPrefix [as 别名]
#.........这里部分代码省略.........
elif self.receiverId and self.toPlayer:
base.talkAssistant.sendAccountTalk(text, self.receiverId)
def sendWhisperByFriend(self, avatarId, text):
online = 0
if base.cr.doId2do.has_key(avatarId):
online = 1
avatarUnderstandable = 0
av = None
if avatarId:
av = base.cr.identifyAvatar(avatarId)
if av != None:
avatarUnderstandable = av.isUnderstandable()
if avatarUnderstandable and online:
base.talkAssistant.sendWhisperTalk(text, avatarId)
def chatButtonPressed(self):
print "chatButtonPressed"
if self.okayToSubmit:
self.sendChat(self.chatEntry.get())
else:
self.sendFailed(self.chatEntry.get())
def cancelButtonPressed(self):
self.requestMode("Off")
localAvatar.chatMgr.fsm.request("mainMenu")
def enterAllChat(self):
ChatInputWhiteListFrame.enterAllChat(self)
self.whisperLabel.hide()
def exitAllChat(self):
ChatInputWhiteListFrame.exitAllChat(self)
def enterPlayerWhisper(self):
ChatInputWhiteListFrame.enterPlayerWhisper(self)
self.labelWhisper()
def exitPlayerWhisper(self):
ChatInputWhiteListFrame.exitPlayerWhisper(self)
self.whisperLabel.hide()
def enterAvatarWhisper(self):
ChatInputWhiteListFrame.enterAvatarWhisper(self)
self.labelWhisper()
def exitAvatarWhisper(self):
ChatInputWhiteListFrame.exitAvatarWhisper(self)
self.whisperLabel.hide()
def labelWhisper(self):
if self.receiverId:
self.whisperName = base.talkAssistant.findName(self.receiverId, self.toPlayer)
self.whisperLabel["text"] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
self.whisperLabel.show()
else:
self.whisperLabel.hide()
def applyFilter(self, keyArgs, strict=False):
text = self.chatEntry.get(plain=True)
if len(text) > 0 and text[0] in ["~", ">"]:
self.okayToSubmit = True
else:
words = text.split(" ")
newwords = []
self.okayToSubmit = True
flag = 0
for (friendId, flags) in base.localAvatar.friendsList:
if flags & ToontownGlobals.FriendChat:
flag = 1
continue
for word in words:
if word == "" and self.whiteList.isWord(word) or not (base.cr.whiteListChatEnabled):
newwords.append(word)
continue
if self.checkBeforeSend:
self.okayToSubmit = False
else:
self.okayToSubmit = True
if flag:
newwords.append("\x01WLDisplay\x01" + word + "\x02")
continue
newwords.append("\x01WLEnter\x01" + word + "\x02")
if not strict:
lastword = words[-1]
if lastword == "" and self.whiteList.isPrefix(lastword) or not (base.cr.whiteListChatEnabled):
newwords[-1] = lastword
elif flag:
newwords[-1] = "\x01WLDisplay\x01" + lastword + "\x02"
else:
newwords[-1] = "\x01WLEnter\x01" + lastword + "\x02"
newtext = " ".join(newwords)
self.chatEntry.set(newtext)
self.chatEntry.guiItem.setAcceptEnabled(self.okayToSubmit)