chat: dymanically allow prefixes

This commit is contained in:
Little Cat 2021-07-09 01:35:56 -03:00
parent 5fccccd206
commit 2f764e00a7
No known key found for this signature in database
GPG key ID: 68CC2B4D0E5AF41C
2 changed files with 7 additions and 3 deletions

View file

@ -175,7 +175,12 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
def applyFilter(self, keyArgs, strict = False):
text = self.chatEntry.get(plain=True)
if len(text) > 0 and text[0] in ['~', '>']:
prefixes = []
if base.cr.magicWordManager and base.cr.wantMagicWords:
prefixes.append(base.cr.magicWordManager.chatPrefix)
if config.GetBool('exec-chat', 0):
prefixes.append('>')
if len(text) > 0 and text[0] in prefixes:
self.okayToSubmit = True
else:
words = text.split(' ')

View file

@ -49,8 +49,7 @@ class ToontownMagicWordManager(DistributedObject.DistributedObject):
DistributedObject.DistributedObject.announceGenerate(self)
# Only use a custom Magic Word activator if the index is allowed
# TODO: Uncomment after adding settings support
activatorIndex = 0 # base.settings.getInt('game', 'magic-word-activator', 0)
activatorIndex = base.settings.getSetting('magic-word-activator', 0)
if 0 <= activatorIndex <= (len(PREFIX_ALLOWED) - 1):
self.chatPrefix = PREFIX_ALLOWED[activatorIndex]