mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Merge commit 'ea14534efb0dc67c86459c86d327b160111e3f60'
This commit is contained in:
commit
e22248e742
8 changed files with 59 additions and 69 deletions
|
@ -11,5 +11,7 @@ class AvatarHandle:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
|
return
|
||||||
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
||||||
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.avatarId, self.getName(), newText, scrubbed)
|
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.avatarId, self.getName(), newText, scrubbed)
|
|
@ -206,6 +206,8 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
self.sendUpdate('setChat', [chatString, chatFlags, 0])
|
self.sendUpdate('setChat', [chatString, chatFlags, 0])
|
||||||
|
|
||||||
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.verifyMessage(chat):
|
||||||
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(fromAV):
|
||||||
return
|
return
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
newText, scrubbed = self.scrubTalk(chat, mods)
|
||||||
|
@ -218,6 +220,8 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
return
|
return
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.verifyMessage(chat):
|
||||||
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(fromAV):
|
||||||
return
|
return
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
newText, scrubbed = self.scrubTalk(chat, mods)
|
||||||
|
|
|
@ -15,17 +15,32 @@ class ChatAgent(DistributedObjectGlobal):
|
||||||
DistributedObjectGlobal.delete(self)
|
DistributedObjectGlobal.delete(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def verifyMessage(self, message):
|
||||||
|
try:
|
||||||
|
message.decode('ascii')
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def adminChat(self, aboutId, message):
|
def adminChat(self, aboutId, message):
|
||||||
|
if not self.verifyMessage(message):
|
||||||
|
return
|
||||||
self.notify.warning('Admin Chat(%s): %s' % (aboutId, message))
|
self.notify.warning('Admin Chat(%s): %s' % (aboutId, message))
|
||||||
messenger.send('adminChat', [aboutId, message])
|
messenger.send('adminChat', [aboutId, message])
|
||||||
|
|
||||||
def sendChatMessage(self, message):
|
def sendChatMessage(self, message):
|
||||||
|
if not self.verifyMessage(message):
|
||||||
|
return
|
||||||
self.sendUpdate('chatMessage', [message, self.chatMode])
|
self.sendUpdate('chatMessage', [message, self.chatMode])
|
||||||
|
|
||||||
def sendWhisperMessage(self, receiverAvId, message):
|
def sendWhisperMessage(self, receiverAvId, message):
|
||||||
|
if not self.verifyMessage(message):
|
||||||
|
return
|
||||||
self.sendUpdate('whisperMessage', [receiverAvId, message])
|
self.sendUpdate('whisperMessage', [receiverAvId, message])
|
||||||
|
|
||||||
def sendSFWhisperMessage(self, receiverAvId, message):
|
def sendSFWhisperMessage(self, receiverAvId, message):
|
||||||
|
if not self.verifyMessage(message):
|
||||||
|
return
|
||||||
self.sendUpdate('sfWhisperMessage', [receiverAvId, message])
|
self.sendUpdate('sfWhisperMessage', [receiverAvId, message])
|
||||||
|
|
||||||
@magicWord(category=CATEGORY_MODERATOR, types=[int])
|
@magicWord(category=CATEGORY_MODERATOR, types=[int])
|
||||||
|
@ -52,4 +67,3 @@ def chatmode(mode=-1):
|
||||||
return "Chat mode 1 is reserved for moderators."
|
return "Chat mode 1 is reserved for moderators."
|
||||||
base.cr.chatAgent.chatMode = mode
|
base.cr.chatAgent.chatMode = mode
|
||||||
return "You are now talking in the %s chat mode." % mode2name.get(mode, "N/A")
|
return "You are now talking in the %s chat mode." % mode2name.get(mode, "N/A")
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
|
|
||||||
def __init__(self, entryOptions, parent = None, **kw):
|
def __init__(self, entryOptions, parent = None, **kw):
|
||||||
FSM.FSM.__init__(self, 'ChatInputWhiteListFrame')
|
FSM.FSM.__init__(self, 'ChatInputWhiteListFrame')
|
||||||
self.okayToSubmit = True
|
|
||||||
self.receiverId = None
|
self.receiverId = None
|
||||||
DirectFrame.__init__(self, parent=aspect2dp, pos=(0, 0, 0.3), relief=None, image=DGG.getDefaultDialogGeom(), image_scale=(1.6, 1, 1.4), image_pos=(0, 0, -0.05), image_color=OTPGlobals.GlobalDialogColor, borderWidth=(0.01, 0.01))
|
DirectFrame.__init__(self, parent=aspect2dp, pos=(0, 0, 0.3), relief=None, image=DGG.getDefaultDialogGeom(), image_scale=(1.6, 1, 1.4), image_pos=(0, 0, -0.05), image_color=OTPGlobals.GlobalDialogColor, borderWidth=(0.01, 0.01))
|
||||||
optiondefs = {'parent': self,
|
optiondefs = {'parent': self,
|
||||||
|
@ -37,7 +36,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
'suppressKeys': 1,
|
'suppressKeys': 1,
|
||||||
'suppressMouse': 1,
|
'suppressMouse': 1,
|
||||||
'command': self.sendChat,
|
'command': self.sendChat,
|
||||||
'failedCommand': self.sendFailed,
|
|
||||||
'focus': 0,
|
'focus': 0,
|
||||||
'text': '',
|
'text': '',
|
||||||
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
||||||
|
@ -50,7 +48,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
self.historySize = base.config.GetInt('chat-history-size', 10)
|
self.historySize = base.config.GetInt('chat-history-size', 10)
|
||||||
self.historyIndex = 0
|
self.historyIndex = 0
|
||||||
self.promoteWhiteList = 0
|
self.promoteWhiteList = 0
|
||||||
self.checkBeforeSend = base.config.GetBool('white-list-check-before-send', 0)
|
|
||||||
self.whiteList = None
|
self.whiteList = None
|
||||||
self.active = 0
|
self.active = 0
|
||||||
self.autoOff = 0
|
self.autoOff = 0
|
||||||
|
@ -132,7 +129,7 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
self.chatEntry['focus'] = 1
|
self.chatEntry['focus'] = 1
|
||||||
self.show()
|
self.show()
|
||||||
self.active = 1
|
self.active = 1
|
||||||
self.chatEntry.guiItem.setAcceptEnabled(False)
|
self.chatEntry.guiItem.setAcceptEnabled(True)
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
self.chatEntry.set('')
|
self.chatEntry.set('')
|
||||||
|
@ -160,9 +157,15 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
self.chatEntry.set('')
|
self.chatEntry.set('')
|
||||||
|
|
||||||
|
try:
|
||||||
|
text.decode('ascii')
|
||||||
self.sendChatBySwitch(text)
|
self.sendChatBySwitch(text)
|
||||||
|
|
||||||
if self.wantHistory:
|
if self.wantHistory:
|
||||||
self.addToHistory(text)
|
self.addToHistory(text)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
base.localAvatar.setSystemMessage(0, OTPLocalizer.AsciiNotSupported)
|
||||||
|
|
||||||
if not overflow:
|
if not overflow:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
@ -195,22 +198,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
else:
|
else:
|
||||||
base.talkAssistant.sendOpenTalk(text)
|
base.talkAssistant.sendOpenTalk(text)
|
||||||
|
|
||||||
def sendFailed(self, text):
|
|
||||||
if not self.checkBeforeSend:
|
|
||||||
self.sendChat(text)
|
|
||||||
return
|
|
||||||
self.chatEntry['frameColor'] = (0.9, 0.0, 0.0, 0.8)
|
|
||||||
|
|
||||||
def resetFrameColor(task = None):
|
|
||||||
self.chatEntry['frameColor'] = self.origFrameColor
|
|
||||||
return Task.done
|
|
||||||
|
|
||||||
taskMgr.doMethodLater(0.1, resetFrameColor, 'resetFrameColor')
|
|
||||||
self.applyFilter(keyArgs=None, strict=True)
|
|
||||||
self.okayToSubmit = True
|
|
||||||
self.chatEntry.guiItem.setAcceptEnabled(True)
|
|
||||||
return
|
|
||||||
|
|
||||||
def chatOverflow(self, overflowText):
|
def chatOverflow(self, overflowText):
|
||||||
self.notify.debug('chatOverflow')
|
self.notify.debug('chatOverflow')
|
||||||
self.sendChat(self.chatEntry.get(plain=True), overflow=True)
|
self.sendChat(self.chatEntry.get(plain=True), overflow=True)
|
||||||
|
@ -231,21 +218,15 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
|
|
||||||
def applyFilter(self, keyArgs, strict = False):
|
def applyFilter(self, keyArgs, strict = False):
|
||||||
text = self.chatEntry.get(plain=True)
|
text = self.chatEntry.get(plain=True)
|
||||||
if text.startswith('~'):
|
|
||||||
self.okayToSubmit = True
|
if not text.startswith('~'):
|
||||||
else:
|
|
||||||
words = text.split(' ')
|
words = text.split(' ')
|
||||||
newwords = []
|
newwords = []
|
||||||
self.notify.debug('%s' % words)
|
self.notify.debug('%s' % words)
|
||||||
self.okayToSubmit = True
|
|
||||||
for word in words:
|
for word in words:
|
||||||
if word == '' or self.whiteList.isWord(word):
|
if word == '' or self.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
if self.checkBeforeSend:
|
|
||||||
self.okayToSubmit = False
|
|
||||||
else:
|
|
||||||
self.okayToSubmit = True
|
|
||||||
newwords.append('\x01WLEnter\x01' + word + '\x02')
|
newwords.append('\x01WLEnter\x01' + word + '\x02')
|
||||||
|
|
||||||
if not strict:
|
if not strict:
|
||||||
|
@ -256,4 +237,3 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
|
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
|
||||||
newtext = ' '.join(newwords)
|
newtext = ' '.join(newwords)
|
||||||
self.chatEntry.set(newtext)
|
self.chatEntry.set(newtext)
|
||||||
self.chatEntry.guiItem.setAcceptEnabled(self.okayToSubmit)
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ class TalkHandle(AvatarHandle):
|
||||||
self.accountName = message.getReceiverAccountName()
|
self.accountName = message.getReceiverAccountName()
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.verifyMessage(chat):
|
||||||
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(fromAV):
|
||||||
return
|
return
|
||||||
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
||||||
|
|
|
@ -2319,3 +2319,5 @@ def timeElapsedString(timeDelta):
|
||||||
return '1 minute ago'
|
return '1 minute ago'
|
||||||
else:
|
else:
|
||||||
return '%s minutes ago' % (timeDelta.seconds / 60)
|
return '%s minutes ago' % (timeDelta.seconds / 60)
|
||||||
|
|
||||||
|
AsciiNotSupported = 'Sorry, but Toontown United does not support non-ASCII characters.'
|
||||||
|
|
|
@ -28,7 +28,6 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
'suppressKeys': 0,
|
'suppressKeys': 0,
|
||||||
'suppressMouse': 1,
|
'suppressMouse': 1,
|
||||||
'command': self.sendChat,
|
'command': self.sendChat,
|
||||||
'failedCommand': self.sendFailed,
|
|
||||||
'focus': 0,
|
'focus': 0,
|
||||||
'text': '',
|
'text': '',
|
||||||
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
||||||
|
@ -78,17 +77,13 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
self.typeGrabbed = 0
|
self.typeGrabbed = 0
|
||||||
|
|
||||||
def typeCallback(self, extraArgs):
|
def typeCallback(self, extraArgs):
|
||||||
try:
|
|
||||||
if self.typeGrabbed:
|
if self.typeGrabbed:
|
||||||
return
|
return
|
||||||
self.applyFilter(extraArgs)
|
self.applyFilter(extraArgs)
|
||||||
if localAvatar.chatMgr.chatInputWhiteList.isActive():
|
if localAvatar.chatMgr.chatInputWhiteList.isActive():
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
messenger.send('enterNormalChat')
|
messenger.send('enterNormalChat')
|
||||||
except UnicodeDecodeError:
|
|
||||||
return
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.chatEntry.destroy()
|
self.chatEntry.destroy()
|
||||||
|
@ -132,10 +127,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
return
|
return
|
||||||
|
|
||||||
def chatButtonPressed(self):
|
def chatButtonPressed(self):
|
||||||
if self.okayToSubmit:
|
|
||||||
self.sendChat(self.chatEntry.get())
|
self.sendChat(self.chatEntry.get())
|
||||||
else:
|
|
||||||
self.sendFailed(self.chatEntry.get())
|
|
||||||
|
|
||||||
def cancelButtonPressed(self):
|
def cancelButtonPressed(self):
|
||||||
self.requestMode('Off')
|
self.requestMode('Off')
|
||||||
|
@ -166,12 +158,10 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
|
|
||||||
def applyFilter(self, keyArgs, strict = False):
|
def applyFilter(self, keyArgs, strict = False):
|
||||||
text = self.chatEntry.get(plain=True)
|
text = self.chatEntry.get(plain=True)
|
||||||
if text.startswith('~'):
|
|
||||||
self.okayToSubmit = True
|
if not text.startswith('~'):
|
||||||
else:
|
|
||||||
words = text.split(' ')
|
words = text.split(' ')
|
||||||
newwords = []
|
newwords = []
|
||||||
self.okayToSubmit = True
|
|
||||||
flag = 0
|
flag = 0
|
||||||
for friendId, flags in base.localAvatar.friendsList:
|
for friendId, flags in base.localAvatar.friendsList:
|
||||||
if flags & ToontownGlobals.FriendChat:
|
if flags & ToontownGlobals.FriendChat:
|
||||||
|
@ -181,10 +171,6 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
if word == '' or self.whiteList.isWord(word) or not settings['speedchatPlus']:
|
if word == '' or self.whiteList.isWord(word) or not settings['speedchatPlus']:
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
if self.checkBeforeSend:
|
|
||||||
self.okayToSubmit = False
|
|
||||||
else:
|
|
||||||
self.okayToSubmit = True
|
|
||||||
if flag:
|
if flag:
|
||||||
newwords.append('\x01WLDisplay\x01' + word + '\x02')
|
newwords.append('\x01WLDisplay\x01' + word + '\x02')
|
||||||
else:
|
else:
|
||||||
|
@ -192,15 +178,11 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
|
|
||||||
if not strict:
|
if not strict:
|
||||||
lastword = words[-1]
|
lastword = words[-1]
|
||||||
try:
|
|
||||||
if lastword == '' or self.whiteList.isPrefix(lastword) or not settings['speedchatPlus']:
|
if lastword == '' or self.whiteList.isPrefix(lastword) or not settings['speedchatPlus']:
|
||||||
newwords[-1] = lastword
|
newwords[-1] = lastword
|
||||||
elif flag:
|
elif flag:
|
||||||
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'
|
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'
|
||||||
else:
|
else:
|
||||||
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
|
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
|
||||||
except UnicodeDecodeError:
|
|
||||||
self.okayToSubmit = False
|
|
||||||
newtext = ' '.join(newwords)
|
newtext = ' '.join(newwords)
|
||||||
self.chatEntry.set(newtext)
|
self.chatEntry.set(newtext)
|
||||||
self.chatEntry.guiItem.setAcceptEnabled(self.okayToSubmit)
|
|
||||||
|
|
|
@ -462,6 +462,8 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
|
return
|
||||||
if base.localAvatar.isIgnored(self.doId if fromAV == 0 else fromAV):
|
if base.localAvatar.isIgnored(self.doId if fromAV == 0 else fromAV):
|
||||||
return
|
return
|
||||||
timestamp = time.strftime('%m-%d-%Y %H:%M:%S', time.localtime())
|
timestamp = time.strftime('%m-%d-%Y %H:%M:%S', time.localtime())
|
||||||
|
@ -480,6 +482,8 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
return base.cr.isFriend(avId)
|
return base.cr.isFriend(avId)
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
||||||
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
|
return
|
||||||
if not localAvatar.acceptingNonFriendWhispers:
|
if not localAvatar.acceptingNonFriendWhispers:
|
||||||
if not self.isAvFriend(fromAV):
|
if not self.isAvFriend(fromAV):
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue