From 589f014a2eae035bd28f5362edd9f923093d39f4 Mon Sep 17 00:00:00 2001 From: Open Toontown <57279094+opentoontown@users.noreply.github.com> Date: Thu, 20 Jan 2022 00:02:49 -0500 Subject: [PATCH] chat clean up --- otp/chat/WhiteList.py | 5 +---- toontown/chat/TTChatInputWhiteList.py | 4 ++-- toontown/chat/TTWhiteList.py | 13 ++++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/otp/chat/WhiteList.py b/otp/chat/WhiteList.py index 8c17a7e..2e717db 100644 --- a/otp/chat/WhiteList.py +++ b/otp/chat/WhiteList.py @@ -14,10 +14,7 @@ class WhiteList: self.numWords = len(self.words) def cleanText(self, text): - if type(text) == bytes: - text = text.decode('utf-8').strip('.,?!') - else: - text = text.strip('.,?!') + text = text.strip('.,?!') text = text.lower().encode('utf-8') return text diff --git a/toontown/chat/TTChatInputWhiteList.py b/toontown/chat/TTChatInputWhiteList.py index 8186cc7..5e6e6a8 100644 --- a/toontown/chat/TTChatInputWhiteList.py +++ b/toontown/chat/TTChatInputWhiteList.py @@ -192,7 +192,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame): flag = 1 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) else: if self.checkBeforeSend: @@ -206,7 +206,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame): if not strict: 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 elif flag: newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02' diff --git a/toontown/chat/TTWhiteList.py b/toontown/chat/TTWhiteList.py index cad231d..184ae96 100644 --- a/toontown/chat/TTWhiteList.py +++ b/toontown/chat/TTWhiteList.py @@ -1,12 +1,11 @@ -import os import datetime from panda3d.core import * from direct.directnotify import DirectNotifyGlobal -from direct.distributed import DistributedObject +from direct.showbase.DirectObject import DirectObject from otp.chat.WhiteList import WhiteList from toontown.toonbase import TTLocalizer -class TTWhiteList(WhiteList, DistributedObject.DistributedObject): +class TTWhiteList(WhiteList, DirectObject): RedownloadTaskName = 'RedownloadWhitelistTask' WhitelistBaseDir = ConfigVariableString('whitelist-base-dir', '').value WhitelistStageDir = ConfigVariableString('whitelist-stage-dir', 'whitelist').value @@ -14,6 +13,7 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject): WhitelistFileName = ConfigVariableString('whitelist-filename', 'twhitelist.dat').value def __init__(self): + DirectObject.__init__(self) self.redownloadingWhitelist = False self.startRedownload = datetime.datetime.now() self.endRedownload = datetime.datetime.now() @@ -36,10 +36,13 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject): self.accept('updateWhitelist', self.handleNewWhitelist) def unload(self): - self.ignore('updateWhitelist') - self.removeDownloadingTextTask() + if self.WhitelistOverHttp: + self.ignore('updateWhitelist') + self.removeDownloadingTextTask() def redownloadWhitelist(self): + if not self.WhitelistOverHttp: + return self.percentDownload = 0.0 self.notify.info('starting redownloadWhitelist') self.startRedownload = datetime.datetime.now()