mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
DANIEL: Work on whitelist
This commit is contained in:
parent
33f99305df
commit
b48fb01fb0
15 changed files with 58 additions and 302 deletions
|
@ -182,30 +182,27 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setTalk(self, chat):
|
def setTalk(self, chat):
|
||||||
if not base.cr.verifyMessage(chat):
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
return
|
return
|
||||||
if base.localAvatar.isIgnored(self.doId):
|
if base.localAvatar.isIgnored(self.doId):
|
||||||
return
|
return
|
||||||
#newText, scrubbed = self.scrubTalk(chat, mods)
|
if base.whiteList:
|
||||||
|
chat = base.whiteList.processThroughAll(chat, self, self.chatGarbler)
|
||||||
self.displayTalk(chat)
|
self.displayTalk(chat)
|
||||||
|
|
||||||
def setTalkWhisper(self, avId, chat):
|
def setTalkWhisper(self, avId, chat):
|
||||||
if not base.cr.verifyMessage(chat):
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
return
|
return
|
||||||
if base.localAvatar.isIgnored(avId):
|
if base.localAvatar.isIgnored(avId):
|
||||||
return
|
return
|
||||||
self.displayTalkWhisper(avId, chat)
|
self.displayTalkWhisper(avId, chat)
|
||||||
|
|
||||||
def displayTalk(self, chat):
|
def displayTalk(self, chat):
|
||||||
print 'displaytalk AV'
|
|
||||||
print 'Talk: %s' % chat
|
print 'Talk: %s' % chat
|
||||||
|
|
||||||
def displayTalkWhisper(self, avId, chat):
|
def displayTalkWhisper(self, avId, chat):
|
||||||
print 'TalkWhisper from %s: %s' % (avId, chat)
|
print 'TalkWhisper from %s: %s' % (avId, chat)
|
||||||
|
|
||||||
def scrubTalk(self, chat, mods):
|
|
||||||
return chat
|
|
||||||
|
|
||||||
def b_setSC(self, msgIndex):
|
def b_setSC(self, msgIndex):
|
||||||
self.setSC(msgIndex)
|
self.setSC(msgIndex)
|
||||||
self.d_setSC(msgIndex)
|
self.d_setSC(msgIndex)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
# TODO: OTP should not depend on Toontown... Hrrm.
|
|
||||||
from toontown.chat.TTWhiteList import TTWhiteList
|
|
||||||
|
|
||||||
class ChatAgentAI:
|
class ChatAgentAI:
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentAI")
|
||||||
|
@ -9,7 +7,4 @@ class ChatAgentAI:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def chatMessage(self, todo0):
|
def chatMessage(self, todo0):
|
||||||
pass
|
|
||||||
|
|
||||||
def setWhiteList(self, todo0):
|
|
||||||
pass
|
pass
|
|
@ -5,14 +5,19 @@ class ChatGarbler:
|
||||||
def __init__(self, messages):
|
def __init__(self, messages):
|
||||||
self.messages = messages
|
self.messages = messages
|
||||||
|
|
||||||
def garble(self, avatar, message, isRandom=False):
|
def garble(self, avatar, message, type=0):
|
||||||
newMessage = ''
|
newMessage = ''
|
||||||
|
|
||||||
if avatar.style:
|
if avatar.style:
|
||||||
avatarType = avatar.style.getType()
|
avatarType = avatar.style.getType()
|
||||||
wordList = self.messages[avatarType if avatarType in self.messages else 'default']
|
wordList = self.messages[avatarType if avatarType in self.messages else 'default']
|
||||||
|
|
||||||
numWords = random.randint(1, 7) if isRandom else 1
|
if type == 0:
|
||||||
|
numWords = 1
|
||||||
|
elif type == 1:
|
||||||
|
numWords = random.randint(1, 7)
|
||||||
|
elif type == 2:
|
||||||
|
numWords = len(message.split(' '))
|
||||||
|
|
||||||
for i in xrange(1, numWords + 1):
|
for i in xrange(1, numWords + 1):
|
||||||
wordIndex = random.randint(0, len(wordList) - 1)
|
wordIndex = random.randint(0, len(wordList) - 1)
|
||||||
|
|
|
@ -47,12 +47,9 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
self.history = ['']
|
self.history = ['']
|
||||||
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.whiteList = None
|
|
||||||
self.active = 0
|
self.active = 0
|
||||||
self.autoOff = 0
|
self.autoOff = 0
|
||||||
self.sendBy = 'Mode'
|
self.sendBy = 'Mode'
|
||||||
self.prefilter = 1
|
|
||||||
from direct.gui import DirectGuiGlobals
|
from direct.gui import DirectGuiGlobals
|
||||||
self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter)
|
self.chatEntry.bind(DirectGuiGlobals.TYPE, self.applyFilter)
|
||||||
self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter)
|
self.chatEntry.bind(DirectGuiGlobals.ERASE, self.applyFilter)
|
||||||
|
@ -129,30 +126,15 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
|
|
||||||
def sendChat(self, text, overflow = False):
|
def sendChat(self, text, overflow = False):
|
||||||
if not (len(text) > 0 and text[0] in ['~', '>']):
|
if not (len(text) > 0 and text[0] in ['~', '>']):
|
||||||
if self.prefilter:
|
text = self.chatEntry.get(plain=True)
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '' or self.whiteList.isWord(word) or self.promoteWhiteList:
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append(base.whiteList.defaultWord)
|
|
||||||
|
|
||||||
text = ' '.join(newwords)
|
|
||||||
else:
|
|
||||||
text = self.chatEntry.get(plain=True)
|
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
self.chatEntry.set('')
|
self.chatEntry.set('')
|
||||||
|
|
||||||
try:
|
if not base.cr.chatAgent.verifyMessage(text):
|
||||||
text.decode('ascii')
|
return
|
||||||
self.sendChatBySwitch(text)
|
|
||||||
|
self.sendChatBySwitch(text)
|
||||||
if self.wantHistory:
|
|
||||||
self.addToHistory(text)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
base.localAvatar.setSystemMessage(0, OTPLocalizer.AsciiNotSupported)
|
|
||||||
|
|
||||||
if not overflow:
|
if not overflow:
|
||||||
self.hide()
|
self.hide()
|
||||||
|
@ -203,24 +185,6 @@ class ChatInputWhiteListFrame(FSM.FSM, DirectFrame):
|
||||||
self.historyIndex -= 1
|
self.historyIndex -= 1
|
||||||
self.historyIndex %= len(self.history)
|
self.historyIndex %= len(self.history)
|
||||||
|
|
||||||
def applyFilter(self, keyArgs, strict = False):
|
def applyFilter(self, keyArgs):
|
||||||
text = self.chatEntry.get(plain=True)
|
if base.whiteList:
|
||||||
|
self.chatEntry.set(base.whiteList.processThroughAll(self.chatEntry.get(plain=True)))
|
||||||
if not text.startswith('~'):
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
self.notify.debug('%s' % words)
|
|
||||||
for word in words:
|
|
||||||
if word == '' or self.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLEnter\x01' + word + '\x02')
|
|
||||||
|
|
||||||
if not strict:
|
|
||||||
lastword = words[-1]
|
|
||||||
if lastword == '' or self.whiteList.isPrefix(lastword):
|
|
||||||
newwords[-1] = lastword
|
|
||||||
else:
|
|
||||||
newwords[-1] = '\x01WLEnter\x01' + lastword + '\x02'
|
|
||||||
newtext = ' '.join(newwords)
|
|
||||||
self.chatEntry.set(newtext)
|
|
|
@ -12,7 +12,6 @@ from otp.otpbase import OTPGlobals
|
||||||
from otp.otpbase import OTPLocalizer
|
from otp.otpbase import OTPLocalizer
|
||||||
from otp.speedchat import SCDecoders
|
from otp.speedchat import SCDecoders
|
||||||
from toontown.chat.ChatGlobals import *
|
from toontown.chat.ChatGlobals import *
|
||||||
from toontown.chat.TTWhiteList import TTWhiteList
|
|
||||||
|
|
||||||
|
|
||||||
ThoughtPrefix = '.'
|
ThoughtPrefix = '.'
|
||||||
|
@ -23,16 +22,13 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.logWhispers = 1
|
self.logWhispers = 1
|
||||||
self.whiteList = None
|
|
||||||
self.clearHistory()
|
self.clearHistory()
|
||||||
self.zeroTimeDay = time.time()
|
self.zeroTimeDay = time.time()
|
||||||
self.zeroTimeGame = globalClock.getRealTime()
|
self.zeroTimeGame = globalClock.getRealTime()
|
||||||
self.floodThreshold = 10.0
|
self.floodThreshold = 10.0
|
||||||
self.useWhiteListFilter = base.config.GetBool('white-list-filter-openchat', 0)
|
|
||||||
self.lastWhisperDoId = None
|
self.lastWhisperDoId = None
|
||||||
self.lastWhisper = None
|
self.lastWhisper = None
|
||||||
self.SCDecoder = SCDecoders
|
self.SCDecoder = SCDecoders
|
||||||
self.whiteList = TTWhiteList()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def clearHistory(self):
|
def clearHistory(self):
|
||||||
|
@ -45,7 +41,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
self.spamDictByDoId = {}
|
self.spamDictByDoId = {}
|
||||||
self.handleDict = {}
|
self.handleDict = {}
|
||||||
self.messageCount = 0
|
self.messageCount = 0
|
||||||
self.shownWhiteListWarning = 0
|
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
|
@ -91,42 +86,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
def getHandle(self, doId):
|
def getHandle(self, doId):
|
||||||
return self.handleDict.get(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():
|
|
||||||
contentMult += 1.0
|
|
||||||
floodRating = max(0, 3.0 * contentMult + oldRating - timeDiff)
|
|
||||||
self.floodDataByDoId[doId] = [floodRating, self.stampTime(), message]
|
|
||||||
if floodRating > self.floodThreshold:
|
|
||||||
if oldRating < self.floodThreshold:
|
|
||||||
self.floodDataByDoId[doId] = [floodRating + 3.0, self.stampTime(), message]
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
self.floodDataByDoId[doId] = [oldRating - timeDiff, self.stampTime(), message]
|
|
||||||
return 2
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def addToHistoryDISLId(self, message, dISLId, scrubbed = 0):
|
def addToHistoryDISLId(self, message, dISLId, scrubbed = 0):
|
||||||
if dISLId not in self.historyByDISLId:
|
if dISLId not in self.historyByDISLId:
|
||||||
self.historyByDISLId[dISLId] = []
|
self.historyByDISLId[dISLId] = []
|
||||||
|
@ -150,36 +109,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
|
|
||||||
return info.getName() if info else ''
|
return info.getName() if info else ''
|
||||||
|
|
||||||
def whiteListFilterMessage(self, text):
|
|
||||||
if not self.useWhiteListFilter:
|
|
||||||
return text
|
|
||||||
elif not base.whiteList:
|
|
||||||
return 'no list'
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '' or base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append(base.whiteList.defaultWord)
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return newText
|
|
||||||
|
|
||||||
def colorMessageByWhiteListFilter(self, text):
|
|
||||||
if not base.whiteList:
|
|
||||||
return text
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '' or base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLRed\x01' + word + '\x02')
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return newText
|
|
||||||
|
|
||||||
def isThought(self, message):
|
def isThought(self, message):
|
||||||
if not message:
|
if not message:
|
||||||
return 0
|
return 0
|
||||||
|
@ -260,6 +189,5 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
avatarName = avatar.getName()
|
avatarName = avatar.getName()
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, receiverId, avatarName, None, None, TALK_WHISPER, None)
|
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, receiverId, avatarName, None, None, TALK_WHISPER, None)
|
||||||
self.historyComplete.append(newMessage)
|
self.historyComplete.append(newMessage)
|
||||||
self.addToHistoryDoId(newMessage, localAvatar.doId)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
messenger.send('NewOpenMessage', [newMessage])
|
||||||
return error
|
return error
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
from bisect import bisect_left
|
from bisect import bisect_left
|
||||||
|
|
||||||
class WhiteList:
|
class WhiteList:
|
||||||
def __init__(self, words):
|
|
||||||
|
def setWords(self, words):
|
||||||
self.words = words
|
self.words = words
|
||||||
self.numWords = len(self.words)
|
self.numWords = len(self.words)
|
||||||
|
|
||||||
def cleanText(self, text):
|
def cleanText(self, text):
|
||||||
text = text.strip('.,?!')
|
return text.strip('.,?!').lower()
|
||||||
return text.lower()
|
|
||||||
|
|
||||||
def isWord(self, text):
|
def isWord(self, text):
|
||||||
return self.cleanText(text) in self.words
|
return self.cleanText(text) in self.words
|
||||||
|
@ -16,25 +16,32 @@ class WhiteList:
|
||||||
text = self.cleanText(text)
|
text = self.cleanText(text)
|
||||||
i = bisect_left(self.words, text)
|
i = bisect_left(self.words, text)
|
||||||
|
|
||||||
if i == self.numWords:
|
return i != self.numWords and self.words[i].startswith(text)
|
||||||
return False
|
|
||||||
|
def getReplacement(self, text, av=None, garbler=None):
|
||||||
|
return '\x01%s\x01%s\x02' % ('WLDisplay' if garbler else 'WLRed', text if not garbler else garbler.garble(av, text, 2))
|
||||||
|
|
||||||
return self.words[i].startswith(text)
|
def processText(self, text, av=None, garbler=None):
|
||||||
|
if (not self.words) or text.startswith('~'):
|
||||||
|
return text
|
||||||
|
|
||||||
def prefixCount(self, text):
|
words = text.split(' ')
|
||||||
text = self.cleanText(text)
|
newWords = []
|
||||||
i = bisect_left(self.words, text)
|
|
||||||
j = i
|
|
||||||
while j < self.numWords and self.words[j].startswith(text):
|
|
||||||
j += 1
|
|
||||||
|
|
||||||
return j - i
|
for word in words:
|
||||||
|
if (not word) or self.isWord(word):
|
||||||
|
newWords.append(word)
|
||||||
|
else:
|
||||||
|
newWords.append(self.getReplacement(word, av, garbler))
|
||||||
|
|
||||||
def prefixList(self, text):
|
lastWord = words[-1]
|
||||||
text = self.cleanText(text)
|
|
||||||
i = bisect_left(self.words, text)
|
|
||||||
j = i
|
|
||||||
while j < self.numWords and self.words[j].startswith(text):
|
|
||||||
j += 1
|
|
||||||
|
|
||||||
return self.words[i:j]
|
if (not lastWord) or self.isPrefix(lastWord):
|
||||||
|
newWords[-1] = lastWord
|
||||||
|
else:
|
||||||
|
newWords[-1] = self.getReplacement(lastWord, av, garbler)
|
||||||
|
|
||||||
|
return ' '.join(newWords)
|
||||||
|
|
||||||
|
def processThroughAll(self, text, av=None, garbler=None):
|
||||||
|
return self.processText(text, av, garbler)
|
|
@ -1,5 +1,6 @@
|
||||||
from direct.showbase.ShowBase import ShowBase
|
from direct.showbase.ShowBase import ShowBase
|
||||||
from otp.ai.MagicWordGlobal import *
|
from otp.ai.MagicWordGlobal import *
|
||||||
|
from otp.chat import WhiteList, WhiteListData
|
||||||
from pandac.PandaModules import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath, Vec4
|
from pandac.PandaModules import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath, Vec4
|
||||||
import OTPGlobals, OTPRender, math
|
import OTPGlobals, OTPRender, math
|
||||||
|
|
||||||
|
@ -19,6 +20,12 @@ class OTPBase(ShowBase):
|
||||||
self.enviroCam = None
|
self.enviroCam = None
|
||||||
self.pixelZoomSetup = False
|
self.pixelZoomSetup = False
|
||||||
self.gameOptionsCode = ''
|
self.gameOptionsCode = ''
|
||||||
|
self.whiteList = None
|
||||||
|
|
||||||
|
if config.GetBool('want-whitelist', True):
|
||||||
|
self.whiteList = WhiteList.WhiteList()
|
||||||
|
self.whiteList.setWords(WhiteListData.WHITELIST)
|
||||||
|
|
||||||
if base.cam:
|
if base.cam:
|
||||||
if self.wantEnviroDR:
|
if self.wantEnviroDR:
|
||||||
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask)
|
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from otp.ai.AIMsgTypes import *
|
from otp.ai.AIMsgTypes import *
|
||||||
TTAIMsgName2Id = {'DBSERVER_GET_ESTATE': 1040,
|
TTAIMsgName2Id = {'DBSERVER_GET_ESTATE': 1040,
|
||||||
'DBSERVER_GET_ESTATE_RESP': 1041,
|
'DBSERVER_GET_ESTATE_RESP': 1041,
|
||||||
'PARTY_MANAGER_UD_TO_ALL_AI': 1042,
|
'PARTY_MANAGER_UD_TO_ALL_AI': 1042}
|
||||||
'WHITELIST_MANAGER_UD_TO_ALL_AI': 1044}
|
|
||||||
TTAIMsgId2Names = invertDictLossless(TTAIMsgName2Id)
|
TTAIMsgId2Names = invertDictLossless(TTAIMsgName2Id)
|
||||||
globals().update(TTAIMsgName2Id)
|
globals().update(TTAIMsgName2Id)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from otp.chat.ChatInputWhiteListFrame import ChatInputWhiteListFrame
|
from otp.chat.ChatInputWhiteListFrame import ChatInputWhiteListFrame
|
||||||
from toontown.chat.TTWhiteList import TTWhiteList
|
|
||||||
from direct.showbase import DirectObject
|
from direct.showbase import DirectObject
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals
|
||||||
import sys
|
import sys
|
||||||
|
@ -32,8 +31,6 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
'text': '',
|
'text': '',
|
||||||
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
'sortOrder': DGG.FOREGROUND_SORT_INDEX}
|
||||||
ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
|
ChatInputWhiteListFrame.__init__(self, entryOptions, parent, **kw)
|
||||||
self.whiteList = TTWhiteList()
|
|
||||||
base.whiteList = self.whiteList
|
|
||||||
base.ttwl = self
|
base.ttwl = self
|
||||||
self.autoOff = 1
|
self.autoOff = 1
|
||||||
self.sendBy = 'Data'
|
self.sendBy = 'Data'
|
||||||
|
@ -92,7 +89,6 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
ChatInputWhiteListFrame.destroy(self)
|
ChatInputWhiteListFrame.destroy(self)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
base.whiteList = None
|
|
||||||
ChatInputWhiteListFrame.delete(self)
|
ChatInputWhiteListFrame.delete(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -154,35 +150,4 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
|
self.whisperLabel['text'] = OTPLocalizer.ChatInputWhisperLabel % self.whisperName
|
||||||
self.whisperLabel.show()
|
self.whisperLabel.show()
|
||||||
else:
|
else:
|
||||||
self.whisperLabel.hide()
|
self.whisperLabel.hide()
|
||||||
|
|
||||||
def applyFilter(self, keyArgs, strict = False):
|
|
||||||
text = self.chatEntry.get(plain=True)
|
|
||||||
|
|
||||||
if not text.startswith('~'):
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
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 settings['speedchatPlus']:
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
if flag:
|
|
||||||
newwords.append('\x01WLDisplay\x01' + word + '\x02')
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLEnter\x01' + word + '\x02')
|
|
||||||
|
|
||||||
if not strict:
|
|
||||||
lastword = words[-1]
|
|
||||||
if lastword == '' or self.whiteList.isPrefix(lastword) or not settings['speedchatPlus']:
|
|
||||||
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)
|
|
|
@ -1,11 +0,0 @@
|
||||||
from otp.chat.WhiteList import WhiteList
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
from toontown.chat import WhiteListData
|
|
||||||
|
|
||||||
class TTWhiteList(WhiteList):
|
|
||||||
notify = directNotify.newCategory('TTWhiteList')
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
WhiteList.__init__(self, WhiteListData.WHITELIST)
|
|
||||||
|
|
||||||
self.defaultWord = TTLocalizer.ChatGarblerDefault[0]
|
|
|
@ -65,45 +65,3 @@ class FriendHandle:
|
||||||
elif settings['trueFriends'] and base.cr.getFriendFlags(self.doId) & ToontownGlobals.FriendChat:
|
elif settings['trueFriends'] and base.cr.getFriendFlags(self.doId) & ToontownGlobals.FriendChat:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def scrubTalk(self, message, mods):
|
|
||||||
scrubbed = 0
|
|
||||||
text = copy.copy(message)
|
|
||||||
for mod in mods:
|
|
||||||
index = mod[0]
|
|
||||||
length = mod[1] - mod[0] + 1
|
|
||||||
newText = text[0:index] + length * '\x07' + text[index + length:]
|
|
||||||
text = newText
|
|
||||||
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '':
|
|
||||||
newwords.append(word)
|
|
||||||
elif word[0] == '\x07':
|
|
||||||
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
|
||||||
scrubbed = 1
|
|
||||||
elif base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLDisplay\x01' + word + '\x02')
|
|
||||||
scrubbed = 1
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return (newText, scrubbed)
|
|
||||||
|
|
||||||
def replaceBadWords(self, text):
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '':
|
|
||||||
newwords.append(word)
|
|
||||||
elif word[0] == '\x07':
|
|
||||||
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
|
||||||
elif base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLRed\x01' + word + '\x02')
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return newText
|
|
||||||
|
|
|
@ -457,13 +457,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
|
|
||||||
def isAvFriend(self, avId):
|
def isAvFriend(self, avId):
|
||||||
return base.cr.isFriend(avId)
|
return base.cr.isFriend(avId)
|
||||||
|
|
||||||
def setTalk(self, chat):
|
|
||||||
if not base.cr.chatAgent.verifyMessage(chat):
|
|
||||||
return
|
|
||||||
if base.localAvatar.isIgnored(self.doId):
|
|
||||||
return
|
|
||||||
self.displayTalk(chat)
|
|
||||||
|
|
||||||
def setTalkWhisper(self, avId, chat):
|
def setTalkWhisper(self, avId, chat):
|
||||||
if not base.cr.chatAgent.verifyMessage(chat):
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
|
@ -2373,56 +2366,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
reply.status = newStatus
|
reply.status = newStatus
|
||||||
break
|
break
|
||||||
|
|
||||||
def scrubTalk(self, message, mods):
|
|
||||||
scrubbed = 0
|
|
||||||
text = copy.copy(message)
|
|
||||||
for mod in mods:
|
|
||||||
index = mod[0]
|
|
||||||
length = mod[1] - mod[0] + 1
|
|
||||||
newText = text[0:index] + length * '\x07' + text[index + length:]
|
|
||||||
text = newText
|
|
||||||
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '':
|
|
||||||
newwords.append(word)
|
|
||||||
elif word[0] == '\x07' or len(word) > 1 and word[0] == '.' and word[1] == '\x07':
|
|
||||||
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
|
||||||
scrubbed = 1
|
|
||||||
elif not base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
flag = 0
|
|
||||||
for friendId, flags in self.friendsList:
|
|
||||||
if not flags & ToontownGlobals.FriendChat:
|
|
||||||
flag = 1
|
|
||||||
|
|
||||||
if flag:
|
|
||||||
scrubbed = 1
|
|
||||||
newwords.append('\x01WLDisplay\x01' + word + '\x02')
|
|
||||||
else:
|
|
||||||
newwords.append(word)
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return (newText, scrubbed)
|
|
||||||
|
|
||||||
def replaceBadWords(self, text):
|
|
||||||
words = text.split(' ')
|
|
||||||
newwords = []
|
|
||||||
for word in words:
|
|
||||||
if word == '':
|
|
||||||
newwords.append(word)
|
|
||||||
elif word[0] == '\x07':
|
|
||||||
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
|
||||||
elif not base.whiteList.isWord(word):
|
|
||||||
newwords.append(word)
|
|
||||||
else:
|
|
||||||
newwords.append('\x01WLRed\x01' + word + '\x02')
|
|
||||||
|
|
||||||
newText = ' '.join(newwords)
|
|
||||||
return newText
|
|
||||||
|
|
||||||
def toonUp(self, hpGained, hasInteractivePropBonus = False):
|
def toonUp(self, hpGained, hasInteractivePropBonus = False):
|
||||||
if self.hp == None or hpGained < 0:
|
if self.hp == None or hpGained < 0:
|
||||||
return
|
return
|
||||||
|
|
|
@ -427,12 +427,14 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
|
||||||
self.d_updateGMNameTag()
|
self.d_updateGMNameTag()
|
||||||
|
|
||||||
def displayTalkWhisper(self, avId, chat):
|
def displayTalkWhisper(self, avId, chat):
|
||||||
# SKRUB PLZ
|
|
||||||
sender = base.cr.identifyAvatar(avId)
|
sender = base.cr.identifyAvatar(avId)
|
||||||
|
|
||||||
if not sender:
|
if not sender:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if base.whiteList:
|
||||||
|
chat = base.whiteList.processThroughAll(chat, sender, self.chatGarbler)
|
||||||
|
|
||||||
name = sender.getName()
|
name = sender.getName()
|
||||||
chatString = '%s: %s' % (name, chat)
|
chatString = '%s: %s' % (name, chat)
|
||||||
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
|
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
|
||||||
|
|
|
@ -129,10 +129,7 @@ class ToonBase(OTPBase.OTPBase):
|
||||||
tpMgr = TextPropertiesManager.getGlobalPtr()
|
tpMgr = TextPropertiesManager.getGlobalPtr()
|
||||||
WLDisplay = TextProperties()
|
WLDisplay = TextProperties()
|
||||||
WLDisplay.setSlant(0.3)
|
WLDisplay.setSlant(0.3)
|
||||||
WLEnter = TextProperties()
|
|
||||||
WLEnter.setTextColor(1.0, 0.0, 0.0, 1)
|
|
||||||
tpMgr.setProperties('WLDisplay', WLDisplay)
|
tpMgr.setProperties('WLDisplay', WLDisplay)
|
||||||
tpMgr.setProperties('WLEnter', WLEnter)
|
|
||||||
del tpMgr
|
del tpMgr
|
||||||
self.lastScreenShotTime = globalClock.getRealTime()
|
self.lastScreenShotTime = globalClock.getRealTime()
|
||||||
self.accept('InputState-forward', self.__walking)
|
self.accept('InputState-forward', self.__walking)
|
||||||
|
|
Loading…
Reference in a new issue