mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Work on chat garbler
This commit is contained in:
parent
1b2c00f7a1
commit
d9454000b4
7 changed files with 36 additions and 78 deletions
2
dependencies/config/release/dev.prc
vendored
2
dependencies/config/release/dev.prc
vendored
|
@ -31,7 +31,7 @@ want-checkers #t
|
||||||
want-house-types #t
|
want-house-types #t
|
||||||
|
|
||||||
# Chat:
|
# Chat:
|
||||||
want-whitelist #f
|
want-whitelist #t
|
||||||
|
|
||||||
# Optional:
|
# Optional:
|
||||||
want-jor-el-cam #f
|
want-jor-el-cam #f
|
||||||
|
|
|
@ -5,21 +5,18 @@ import string
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from otp.ai.MagicWordGlobal import *
|
from otp.ai.MagicWordGlobal import *
|
||||||
from otp.avatar import Avatar, PlayerBase
|
from otp.avatar import Avatar, PlayerBase, DistributedAvatar
|
||||||
from otp.avatar import DistributedAvatar
|
|
||||||
from otp.avatar.Avatar import teleportNotify
|
from otp.avatar.Avatar import teleportNotify
|
||||||
from otp.chat import ChatGarbler
|
from otp.chat import ChatGarbler, TalkAssistant
|
||||||
from otp.chat import TalkAssistant
|
|
||||||
from otp.distributed.TelemetryLimited import TelemetryLimited
|
from otp.distributed.TelemetryLimited import TelemetryLimited
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals, 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.WhisperPopup import WhisperPopup
|
from toontown.chat.WhisperPopup import WhisperPopup
|
||||||
|
|
||||||
class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBase, TelemetryLimited):
|
class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBase, TelemetryLimited):
|
||||||
TeleportFailureTimeout = 60.0
|
TeleportFailureTimeout = 60.0
|
||||||
chatGarbler = ChatGarbler.ChatGarbler()
|
chatGarbler = ChatGarbler.ChatGarbler({'default': OTPLocalizer.ChatGarblerDefault})
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -54,7 +54,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
|
||||||
self.customMessages = []
|
self.customMessages = []
|
||||||
self.chatMgr = chatMgr
|
self.chatMgr = chatMgr
|
||||||
base.talkAssistant = talkAssistant
|
base.talkAssistant = talkAssistant
|
||||||
self.garbleChat = 1
|
|
||||||
self.teleportAllowed = 1
|
self.teleportAllowed = 1
|
||||||
self.lockedDown = 0
|
self.lockedDown = 0
|
||||||
self.isPageUp = 0
|
self.isPageUp = 0
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
import string
|
|
||||||
import random
|
import random
|
||||||
from otp.otpbase import OTPLocalizer
|
|
||||||
|
|
||||||
class ChatGarbler:
|
class ChatGarbler:
|
||||||
|
|
||||||
def garble(self, avatar, message):
|
def __init__(self, messages):
|
||||||
|
self.messages = messages
|
||||||
|
|
||||||
|
def garble(self, avatar, message, isRandom=False):
|
||||||
newMessage = ''
|
newMessage = ''
|
||||||
numWords = random.randint(1, 7)
|
|
||||||
wordlist = OTPLocalizer.ChatGarblerDefault
|
if avatar.style:
|
||||||
|
avatarType = avatar.style.getType()
|
||||||
|
wordList = self.messages[avatarType if avatarType in self.messages else 'default']
|
||||||
|
|
||||||
|
numWords = random.randint(1, 7) if isRandom else 1
|
||||||
|
|
||||||
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)
|
||||||
newMessage = newMessage + wordlist[wordIndex]
|
newMessage = newMessage + wordList[wordIndex]
|
||||||
if i < numWords:
|
|
||||||
newMessage = newMessage + ' '
|
|
||||||
|
|
||||||
return newMessage
|
|
||||||
|
|
||||||
def garbleSingle(self, avatar, message):
|
|
||||||
newMessage = ''
|
|
||||||
numWords = 1
|
|
||||||
wordlist = OTPLocalizer.ChatGarblerDefault
|
|
||||||
for i in xrange(1, numWords + 1):
|
|
||||||
wordIndex = random.randint(0, len(wordlist) - 1)
|
|
||||||
newMessage = newMessage + wordlist[wordIndex]
|
|
||||||
if i < numWords:
|
if i < numWords:
|
||||||
newMessage = newMessage + ' '
|
newMessage = newMessage + ' '
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import string
|
|
||||||
import random
|
|
||||||
from toontown.toonbase import TTLocalizer
|
|
||||||
from otp.otpbase import OTPLocalizer
|
|
||||||
from otp.chat import ChatGarbler
|
from otp.chat import ChatGarbler
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
|
||||||
class ToonChatGarbler(ChatGarbler.ChatGarbler):
|
class ToonChatGarbler(ChatGarbler.ChatGarbler):
|
||||||
animalSounds = {'dog': TTLocalizer.ChatGarblerDog,
|
|
||||||
|
def __init__(self):
|
||||||
|
self.messages = {'dog': TTLocalizer.ChatGarblerDog,
|
||||||
'cat': TTLocalizer.ChatGarblerCat,
|
'cat': TTLocalizer.ChatGarblerCat,
|
||||||
'mouse': TTLocalizer.ChatGarblerMouse,
|
'mouse': TTLocalizer.ChatGarblerMouse,
|
||||||
'horse': TTLocalizer.ChatGarblerHorse,
|
'horse': TTLocalizer.ChatGarblerHorse,
|
||||||
|
@ -14,36 +13,4 @@ class ToonChatGarbler(ChatGarbler.ChatGarbler):
|
||||||
'monkey': TTLocalizer.ChatGarblerMonkey,
|
'monkey': TTLocalizer.ChatGarblerMonkey,
|
||||||
'bear': TTLocalizer.ChatGarblerBear,
|
'bear': TTLocalizer.ChatGarblerBear,
|
||||||
'pig': TTLocalizer.ChatGarblerPig,
|
'pig': TTLocalizer.ChatGarblerPig,
|
||||||
'default': OTPLocalizer.ChatGarblerDefault}
|
'default': TTLocalizer.ChatGarblerDefault}
|
||||||
|
|
||||||
def garble(self, toon, message):
|
|
||||||
newMessage = ''
|
|
||||||
animalType = toon.getStyle().getType()
|
|
||||||
if animalType in ToonChatGarbler.animalSounds:
|
|
||||||
wordlist = ToonChatGarbler.animalSounds[animalType]
|
|
||||||
else:
|
|
||||||
wordlist = ToonChatGarbler.animalSounds['default']
|
|
||||||
numWords = random.randint(1, 7)
|
|
||||||
for i in xrange(1, numWords + 1):
|
|
||||||
wordIndex = random.randint(0, len(wordlist) - 1)
|
|
||||||
newMessage = newMessage + wordlist[wordIndex]
|
|
||||||
if i < numWords:
|
|
||||||
newMessage = newMessage + ' '
|
|
||||||
|
|
||||||
return newMessage
|
|
||||||
|
|
||||||
def garbleSingle(self, toon, message):
|
|
||||||
newMessage = ''
|
|
||||||
animalType = toon.getStyle().getType()
|
|
||||||
if animalType in ToonChatGarbler.animalSounds:
|
|
||||||
wordlist = ToonChatGarbler.animalSounds[animalType]
|
|
||||||
else:
|
|
||||||
wordlist = ToonChatGarbler.animalSounds['default']
|
|
||||||
numWords = 1
|
|
||||||
for i in xrange(1, numWords + 1):
|
|
||||||
wordIndex = random.randint(0, len(wordlist) - 1)
|
|
||||||
newMessage = newMessage + wordlist[wordIndex]
|
|
||||||
if i < numWords:
|
|
||||||
newMessage = newMessage + ' '
|
|
||||||
|
|
||||||
return newMessage
|
|
|
@ -81,7 +81,7 @@ class FriendHandle:
|
||||||
if word == '':
|
if word == '':
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
elif word[0] == '\x07':
|
elif word[0] == '\x07':
|
||||||
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02')
|
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
||||||
scrubbed = 1
|
scrubbed = 1
|
||||||
elif base.whiteList.isWord(word):
|
elif base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
|
@ -99,7 +99,7 @@ class FriendHandle:
|
||||||
if word == '':
|
if word == '':
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
elif word[0] == '\x07':
|
elif word[0] == '\x07':
|
||||||
newwords.append('\x01WLRed\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02')
|
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
||||||
elif base.whiteList.isWord(word):
|
elif base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -2402,7 +2402,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
if word == '':
|
if word == '':
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
elif word[0] == '\x07' or len(word) > 1 and word[0] == '.' and word[1] == '\x07':
|
elif word[0] == '\x07' or len(word) > 1 and word[0] == '.' and word[1] == '\x07':
|
||||||
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02')
|
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
||||||
scrubbed = 1
|
scrubbed = 1
|
||||||
elif not self.whiteListEnabled or base.whiteList.isWord(word):
|
elif not self.whiteListEnabled or base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
|
@ -2428,7 +2428,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
if word == '':
|
if word == '':
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
elif word[0] == '\x07':
|
elif word[0] == '\x07':
|
||||||
newwords.append('\x01WLRed\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02')
|
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
||||||
elif not self.whiteListEnabled or base.whiteList.isWord(word):
|
elif not self.whiteListEnabled or base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue