chat clean up

This commit is contained in:
Open Toontown 2022-01-20 00:02:49 -05:00
parent 3d41e250e3
commit 589f014a2e
3 changed files with 11 additions and 11 deletions

View file

@ -14,10 +14,7 @@ class WhiteList:
self.numWords = len(self.words) self.numWords = len(self.words)
def cleanText(self, text): def cleanText(self, text):
if type(text) == bytes: text = text.strip('.,?!')
text = text.decode('utf-8').strip('.,?!')
else:
text = text.strip('.,?!')
text = text.lower().encode('utf-8') text = text.lower().encode('utf-8')
return text return text

View file

@ -192,7 +192,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
flag = 1 flag = 1
for word in words: for word in words:
if word == '' or self.whiteList.isWord(word.encode('utf-8')) or not base.cr.whiteListChatEnabled: if word == '' or self.whiteList.isWord(word) or not base.cr.whiteListChatEnabled:
newwords.append(word) newwords.append(word)
else: else:
if self.checkBeforeSend: if self.checkBeforeSend:
@ -206,7 +206,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
if not strict: if not strict:
lastword = words[-1] lastword = words[-1]
if lastword == '' or self.whiteList.isPrefix(lastword.encode('utf-8')) or not base.cr.whiteListChatEnabled: if lastword == '' or self.whiteList.isPrefix(lastword) or not base.cr.whiteListChatEnabled:
newwords[-1] = lastword newwords[-1] = lastword
elif flag: elif flag:
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02' newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'

View file

@ -1,12 +1,11 @@
import os
import datetime import datetime
from panda3d.core import * from panda3d.core import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.distributed import DistributedObject from direct.showbase.DirectObject import DirectObject
from otp.chat.WhiteList import WhiteList from otp.chat.WhiteList import WhiteList
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
class TTWhiteList(WhiteList, DistributedObject.DistributedObject): class TTWhiteList(WhiteList, DirectObject):
RedownloadTaskName = 'RedownloadWhitelistTask' RedownloadTaskName = 'RedownloadWhitelistTask'
WhitelistBaseDir = ConfigVariableString('whitelist-base-dir', '').value WhitelistBaseDir = ConfigVariableString('whitelist-base-dir', '').value
WhitelistStageDir = ConfigVariableString('whitelist-stage-dir', 'whitelist').value WhitelistStageDir = ConfigVariableString('whitelist-stage-dir', 'whitelist').value
@ -14,6 +13,7 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject):
WhitelistFileName = ConfigVariableString('whitelist-filename', 'twhitelist.dat').value WhitelistFileName = ConfigVariableString('whitelist-filename', 'twhitelist.dat').value
def __init__(self): def __init__(self):
DirectObject.__init__(self)
self.redownloadingWhitelist = False self.redownloadingWhitelist = False
self.startRedownload = datetime.datetime.now() self.startRedownload = datetime.datetime.now()
self.endRedownload = datetime.datetime.now() self.endRedownload = datetime.datetime.now()
@ -36,10 +36,13 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject):
self.accept('updateWhitelist', self.handleNewWhitelist) self.accept('updateWhitelist', self.handleNewWhitelist)
def unload(self): def unload(self):
self.ignore('updateWhitelist') if self.WhitelistOverHttp:
self.removeDownloadingTextTask() self.ignore('updateWhitelist')
self.removeDownloadingTextTask()
def redownloadWhitelist(self): def redownloadWhitelist(self):
if not self.WhitelistOverHttp:
return
self.percentDownload = 0.0 self.percentDownload = 0.0
self.notify.info('starting redownloadWhitelist') self.notify.info('starting redownloadWhitelist')
self.startRedownload = datetime.datetime.now() self.startRedownload = datetime.datetime.now()