mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
parent
61bc7a974d
commit
010c075265
6 changed files with 44 additions and 119 deletions
|
@ -43,9 +43,9 @@ def chatmode(mode=-1):
|
|||
return "You are currently talking in the %s chat mode." % mode2name.get(base.cr.chatAgent.chatMode, "N/A")
|
||||
if not 0 <= mode <= 3:
|
||||
return "Invalid chat mode specified."
|
||||
if mode == 3 and spellbook.getInvoker().getAdminAccess() < 600:
|
||||
if mode == 3 and spellbook.getInvoker().getAdminAccess() < 500:
|
||||
return "Chat mode 3 is reserved for system administrators."
|
||||
if mode == 2 and spellbook.getInvoker().getAdminAccess() < 500:
|
||||
if mode == 2 and spellbook.getInvoker().getAdminAccess() < 400:
|
||||
return "Chat mode 2 is reserved for administrators."
|
||||
if mode == 1 and spellbook.getInvoker().getAdminAccess() < 200:
|
||||
# Like this will ever happen, but whatever.
|
||||
|
|
|
@ -27,7 +27,17 @@ class ChatAgentUD(DistributedObjectGlobalUD):
|
|||
2 : "[ADMIN] ",
|
||||
3 : "[SYSADMIN] ",
|
||||
}
|
||||
|
||||
|
||||
self.muted = {}
|
||||
|
||||
def muteAccount(self, account, howLong):
|
||||
print ['muteAccount', account, howLong]
|
||||
self.muted[account] = int(time.time()/60) + howLong
|
||||
|
||||
def unmuteAccount(self, account):
|
||||
print ['unmuteAccount', account]
|
||||
if account in self.muted:
|
||||
del self.muted[account]
|
||||
# Open chat
|
||||
def chatMessage(self, message, chatMode):
|
||||
sender = self.air.getAvatarIdFromSender()
|
||||
|
@ -36,6 +46,9 @@ class ChatAgentUD(DistributedObjectGlobalUD):
|
|||
issue='Account sent chat without an avatar', message=message)
|
||||
return
|
||||
|
||||
if sender in self.muted and int(time.time()/60) < self.muted[sender]:
|
||||
return
|
||||
|
||||
if self.wantWhitelist:
|
||||
cleanMessage, modifications = self.cleanWhitelist(message)
|
||||
else:
|
||||
|
|
|
@ -4,10 +4,6 @@ from direct.fsm import State
|
|||
from direct.gui.DirectGui import *
|
||||
from direct.showbase import DirectObject
|
||||
from pandac.PandaModules import *
|
||||
|
||||
from otp.login import LeaveToPayDialog
|
||||
from otp.login import PrivacyPolicyPanel
|
||||
from otp.login import SecretFriendsInfoPanel
|
||||
from otp.otpbase import OTPLocalizer
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
||||
|
@ -49,17 +45,13 @@ class ChatManager(DirectObject.DirectObject):
|
|||
self.__normalObscured = 0
|
||||
self.openChatWarning = None
|
||||
self.unpaidChatWarning = None
|
||||
self.teaser = None
|
||||
self.paidNoParentPassword = None
|
||||
self.noSecretChatAtAll = None
|
||||
self.noSecretChatAtAllAndNoWhitelist = None
|
||||
self.noSecretChatWarning = None
|
||||
self.activateChatGui = None
|
||||
self.chatMoreInfo = None
|
||||
self.chatPrivacyPolicy = None
|
||||
self.secretChatActivated = None
|
||||
self.problemActivatingChat = None
|
||||
self.leaveToPayDialog = None
|
||||
self.fsm = ClassicFSM.ClassicFSM('chatManager', [State.State('off', self.enterOff, self.exitOff),
|
||||
State.State('mainMenu', self.enterMainMenu, self.exitMainMenu),
|
||||
State.State('speedChat', self.enterSpeedChat, self.exitSpeedChat),
|
||||
|
@ -70,7 +62,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
State.State('whisperSpeedChat', self.enterWhisperSpeedChat, self.exitWhisperSpeedChat),
|
||||
State.State('whisperSpeedChatPlayer', self.enterWhisperSpeedChatPlayer, self.exitWhisperSpeedChatPlayer),
|
||||
State.State('openChatWarning', self.enterOpenChatWarning, self.exitOpenChatWarning),
|
||||
State.State('leaveToPayDialog', self.enterLeaveToPayDialog, self.exitLeaveToPayDialog),
|
||||
State.State('unpaidChatWarning', self.enterUnpaidChatWarning, self.exitUnpaidChatWarning),
|
||||
State.State('noSecretChatAtAll', self.enterNoSecretChatAtAll, self.exitNoSecretChatAtAll),
|
||||
State.State('noSecretChatAtAllAndNoWhitelist', self.enterNoSecretChatAtAllAndNoWhitelist, self.exitNoSecretChatAtAllAndNoWhitelist),
|
||||
|
@ -78,14 +69,11 @@ class ChatManager(DirectObject.DirectObject):
|
|||
State.State('noFriendsWarning', self.enterNoFriendsWarning, self.exitNoFriendsWarning),
|
||||
State.State('otherDialog', self.enterOtherDialog, self.exitOtherDialog),
|
||||
State.State('activateChat', self.enterActivateChat, self.exitActivateChat),
|
||||
State.State('chatMoreInfo', self.enterChatMoreInfo, self.exitChatMoreInfo),
|
||||
State.State('chatPrivacyPolicy', self.enterChatPrivacyPolicy, self.exitChatPrivacyPolicy),
|
||||
State.State('secretChatActivated', self.enterSecretChatActivated, self.exitSecretChatActivated),
|
||||
State.State('problemActivatingChat', self.enterProblemActivatingChat, self.exitProblemActivatingChat),
|
||||
State.State('whiteListOpenChat', self.enterWhiteListOpenChat, self.exitWhiteListOpenChat),
|
||||
State.State('whiteListAvatarChat', self.enterWhiteListAvatarChat, self.exitWhiteListAvatarChat),
|
||||
State.State('whiteListPlayerChat', self.enterWhiteListPlayerChat, self.exitWhiteListPlayerChat),
|
||||
State.State('trueFriendTeaserPanel', self.enterTrueFriendTeaserPanel, self.exitTrueFriendTeaserPanel)], 'off', 'off')
|
||||
State.State('whiteListPlayerChat', self.enterWhiteListPlayerChat, self.exitWhiteListPlayerChat)], 'off', 'off')
|
||||
self.fsm.enterInitialState()
|
||||
return
|
||||
|
||||
|
@ -105,10 +93,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
self.payButton = None
|
||||
self.unpaidChatWarning.destroy()
|
||||
self.unpaidChatWarning = None
|
||||
if self.teaser:
|
||||
self.teaser.cleanup()
|
||||
self.teaser.unload()
|
||||
self.teaser = None
|
||||
if self.noSecretChatAtAll:
|
||||
self.noSecretChatAtAll.destroy()
|
||||
self.noSecretChatAtAll = None
|
||||
|
@ -121,12 +105,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
if self.activateChatGui:
|
||||
self.activateChatGui.destroy()
|
||||
self.activateChatGui = None
|
||||
if self.chatMoreInfo:
|
||||
self.chatMoreInfo.destroy()
|
||||
self.chatMoreInfo = None
|
||||
if self.chatPrivacyPolicy:
|
||||
self.chatPrivacyPolicy.destroy()
|
||||
self.chatPrivacyPolicy = None
|
||||
if self.secretChatActivated:
|
||||
self.secretChatActivated.destroy()
|
||||
self.secretChatActivated = None
|
||||
|
@ -218,8 +196,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
if self.wantBackgroundFocus:
|
||||
self.chatInputNormal.chatEntry['backgroundFocus'] = 1
|
||||
self.acceptOnce('enterNormalChat', self.fsm.request, ['normalChat'])
|
||||
if not self.wantBackgroundFocus:
|
||||
self.accept('t', messenger.send, ['enterNormalChat'])
|
||||
|
||||
def checkObscurred(self):
|
||||
if not self.__scObscured:
|
||||
|
@ -411,19 +387,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
def exitOpenChatWarning(self):
|
||||
self.notify.error('called exitOpenChatWarning() on parent class')
|
||||
|
||||
def enterLeaveToPayDialog(self):
|
||||
if self.leaveToPayDialog == None:
|
||||
self.leaveToPayDialog = LeaveToPayDialog.LeaveToPayDialog(self.paidNoParentPassword)
|
||||
self.leaveToPayDialog.setCancel(self.__handleLeaveToPayCancel)
|
||||
self.leaveToPayDialog.show()
|
||||
return
|
||||
|
||||
def exitLeaveToPayDialog(self):
|
||||
if self.leaveToPayDialog:
|
||||
self.leaveToPayDialog.destroy()
|
||||
self.leaveToPayDialog = None
|
||||
return
|
||||
|
||||
def enterUnpaidChatWarning(self):
|
||||
self.notify.error('called enterUnpaidChatWarning() on parent class')
|
||||
|
||||
|
@ -466,30 +429,6 @@ class ChatManager(DirectObject.DirectObject):
|
|||
def exitOtherDialog(self):
|
||||
pass
|
||||
|
||||
def enterChatMoreInfo(self):
|
||||
if self.chatMoreInfo == None:
|
||||
self.chatMoreInfo = SecretFriendsInfoPanel.SecretFriendsInfoPanel('secretFriendsInfoDone')
|
||||
self.chatMoreInfo.show()
|
||||
self.accept('secretFriendsInfoDone', self.__secretFriendsInfoDone)
|
||||
return
|
||||
|
||||
def exitChatMoreInfo(self):
|
||||
self.chatMoreInfo.hide()
|
||||
self.ignore('secretFriendsInfoDone')
|
||||
|
||||
def enterChatPrivacyPolicy(self):
|
||||
if self.chatPrivacyPolicy == None:
|
||||
self.chatPrivacyPolicy = PrivacyPolicyPanel.PrivacyPolicyPanel('privacyPolicyDone')
|
||||
self.chatPrivacyPolicy.show()
|
||||
self.accept('privacyPolicyDone', self.__privacyPolicyDone)
|
||||
return
|
||||
|
||||
def exitChatPrivacyPolicy(self):
|
||||
cleanupDialog('privacyPolicyDialog')
|
||||
self.chatPrivacyPolicy = None
|
||||
self.ignore('privacyPolicyDone')
|
||||
return
|
||||
|
||||
def enterSecretChatActivated(self):
|
||||
self.notify.error('called enterSecretChatActivated() on parent class')
|
||||
|
||||
|
@ -500,19 +439,4 @@ class ChatManager(DirectObject.DirectObject):
|
|||
self.notify.error('called enterProblemActivatingChat() on parent class')
|
||||
|
||||
def exitProblemActivatingChat(self):
|
||||
self.notify.error('called exitProblemActivatingChat() on parent class')
|
||||
|
||||
def enterTrueFriendTeaserPanel(self):
|
||||
self.notify.error('called enterTrueFriendTeaserPanel () on parent class')
|
||||
|
||||
def exitTrueFriendTeaserPanel(self):
|
||||
self.notify.error('called exitTrueFriendTeaserPanel () on parent class')
|
||||
|
||||
def __handleLeaveToPayCancel(self):
|
||||
self.fsm.request('mainMenu')
|
||||
|
||||
def __secretFriendsInfoDone(self):
|
||||
self.fsm.request('activateChat')
|
||||
|
||||
def __privacyPolicyDone(self):
|
||||
self.fsm.request('activateChat')
|
||||
self.notify.error('called exitProblemActivatingChat() on parent class')
|
|
@ -574,10 +574,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
def sendOpenTalk(self, message):
|
||||
error = None
|
||||
doId = base.localAvatar.doId
|
||||
try:
|
||||
message.encode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
return
|
||||
if base.config.GetBool('want-talkative-tyler', False):
|
||||
if base.localAvatar.zoneId == 2000:
|
||||
tyler = base.cr.doFind('Talkative Tyler')
|
||||
|
@ -610,7 +606,7 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
|
||||
message, scrubbed = base.localAvatar.scrubTalk(cleanMessage, modifications)
|
||||
|
||||
base.cr.ttiFriendsManager.sendUpdate('sendTalkWhisper', [receiverAvId, message])
|
||||
base.cr.ttuFriendsManager.sendUpdate('sendTalkWhisper', [receiverAvId, message])
|
||||
|
||||
def sendAccountTalk(self, message, receiverAccount):
|
||||
error = None
|
||||
|
@ -671,24 +667,8 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
return error
|
||||
|
||||
def sendPlayerWhisperSpeedChat(self, type, messageIndex, receiverId):
|
||||
error = None
|
||||
if type == SPEEDCHAT_NORMAL:
|
||||
base.cr.speedchatRelay.sendSpeedchat(receiverId, messageIndex)
|
||||
message = self.SCDecoder.decodeSCStaticTextMsg(messageIndex)
|
||||
elif type == SPEEDCHAT_EMOTE:
|
||||
base.cr.speedchatRelay.sendSpeedchatEmote(receiverId, messageIndex)
|
||||
message = self.SCDecoder.decodeSCEmoteWhisperMsg(messageIndex, localAvatar.getName())
|
||||
return
|
||||
elif type == SPEEDCHAT_CUSTOM:
|
||||
base.cr.speedchatRelay.sendSpeedchatCustom(receiverId, messageIndex)
|
||||
message = self.SCDecoder.decodeSCCustomMsg(messageIndex)
|
||||
if self.logWhispers:
|
||||
receiverName = self.findName(receiverId, 1)
|
||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, None, None, receiverId, receiverName, TALK_ACCOUNT, None)
|
||||
self.historyComplete.append(newMessage)
|
||||
self.addToHistoryDoId(newMessage, localAvatar.doId)
|
||||
messenger.send('NewOpenMessage', [newMessage])
|
||||
return error
|
||||
# TODO: Remove Player system
|
||||
return None
|
||||
|
||||
def sendGuildSpeedChat(self, type, msgIndex):
|
||||
error = None
|
||||
|
|
|
@ -1,27 +1,41 @@
|
|||
from bisect import bisect_left
|
||||
|
||||
import string
|
||||
import sys
|
||||
import os
|
||||
|
||||
class WhiteList:
|
||||
def __init__(self, words):
|
||||
self.words = words
|
||||
|
||||
def __init__(self, wordlist):
|
||||
self.words = []
|
||||
for line in wordlist:
|
||||
self.words.append(line.strip('\n\r').lower())
|
||||
|
||||
self.words.sort()
|
||||
self.numWords = len(self.words)
|
||||
|
||||
def cleanText(self, text):
|
||||
text = text.strip('.,?!')
|
||||
return text.lower()
|
||||
text = text.lower()
|
||||
return text
|
||||
|
||||
def isWord(self, text):
|
||||
return self.cleanText(text) in self.words
|
||||
try:
|
||||
text = self.cleanText(text)
|
||||
i = bisect_left(self.words, text)
|
||||
if i == self.numWords:
|
||||
return False
|
||||
return self.words[i] == text
|
||||
except UnicodeDecodeError:
|
||||
return False # Lets not open ourselves up to obscure keyboards...
|
||||
|
||||
|
||||
def isPrefix(self, text):
|
||||
text = self.cleanText(text)
|
||||
i = bisect_left(self.words, text)
|
||||
|
||||
if i == self.numWords:
|
||||
return False
|
||||
|
||||
return self.words[i].startswith(text)
|
||||
|
||||
|
||||
def prefixCount(self, text):
|
||||
text = self.cleanText(text)
|
||||
i = bisect_left(self.words, text)
|
||||
|
@ -38,4 +52,4 @@ class WhiteList:
|
|||
while j < self.numWords and self.words[j].startswith(text):
|
||||
j += 1
|
||||
|
||||
return self.words[i:j]
|
||||
return self.words[i:j]
|
||||
|
|
|
@ -101,12 +101,6 @@ class AccountDB:
|
|||
def lookup(self, username, callback):
|
||||
pass # Inheritors should override this.
|
||||
|
||||
def persistMessage(self, category, description, sender, receiver):
|
||||
print ['persistMessage', category, description, sender, receiver]
|
||||
|
||||
def persistChat(self, sender, message, channel):
|
||||
pass
|
||||
|
||||
def storeAccountID(self, userId, accountId, callback):
|
||||
self.dbm[str(userId)] = str(accountId) # anydbm only allows strings.
|
||||
if getattr(self.dbm, 'sync', None):
|
||||
|
|
Loading…
Reference in a new issue