oldschool-toontown/otp/chat/ChatGarbler.py

30 lines
906 B
Python
Raw Normal View History

2019-11-02 17:27:54 -05:00
import string
import random
from otp.otpbase import OTPLocalizer
class ChatGarbler:
def garble(self, avatar, message):
newMessage = ''
numWords = random.randint(1, 7)
wordlist = OTPLocalizer.ChatGarblerDefault
for i in range(1, numWords + 1):
wordIndex = random.randint(0, len(wordlist) - 1)
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 range(1, numWords + 1):
wordIndex = random.randint(0, len(wordlist) - 1)
newMessage = newMessage + wordlist[wordIndex]
if i < numWords:
newMessage = newMessage + ' '
return newMessage