mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-24 20:22:33 -06:00
DANIEL: Work on chat
This commit is contained in:
parent
d9454000b4
commit
33f99305df
11 changed files with 65 additions and 365 deletions
12
dependencies/astron/dclass/stride.dc
vendored
12
dependencies/astron/dclass/stride.dc
vendored
|
@ -133,14 +133,8 @@ struct TalkModification {
|
||||||
uint16 size;
|
uint16 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass TalkPath_owner {
|
|
||||||
setTalk(DoId fromAv, DoId fromAcc, string(0-256) avName,
|
|
||||||
string(0-400) chat, TalkModification [], uint8 flags) broadcast ownsend;
|
|
||||||
};
|
|
||||||
|
|
||||||
dclass TalkPath_whisper {
|
dclass TalkPath_whisper {
|
||||||
setTalkWhisper(DoId fromAv, DoId fromAcc, string(0-256) avName,
|
setTalkWhisper(uint32 avId, string(0-400) chat) ownrecv clsend;
|
||||||
string(0-400) chat, TalkModification [], uint8 flags) ownrecv clsend;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass TalkPath_group {
|
dclass TalkPath_group {
|
||||||
|
@ -157,8 +151,7 @@ dclass DistributedAvatar : DistributedSmoothNode, TalkPath_whisper {
|
||||||
friendsNotify(DoId avId, int8 status) ownrecv airecv;
|
friendsNotify(DoId avId, int8 status) ownrecv airecv;
|
||||||
checkAvOnShard(DoId) clsend airecv;
|
checkAvOnShard(DoId) clsend airecv;
|
||||||
confirmAvOnShard(DoId avId, int8 isOnShard);
|
confirmAvOnShard(DoId avId, int8 isOnShard);
|
||||||
setTalk(DoId fromAv, DoId fromAcc, string(0-256) avName,
|
setTalk(string(0-400) chat) broadcast;
|
||||||
string(0-400) chat, TalkModification [], uint8 flags) broadcast;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FriendEntry {
|
struct FriendEntry {
|
||||||
|
@ -194,7 +187,6 @@ dclass ChatAgent : DistributedObject {
|
||||||
adminChat(uint32 aboutId, string message);
|
adminChat(uint32 aboutId, string message);
|
||||||
chatMessage(string(0-256) message, uint8 chatMode) clsend;
|
chatMessage(string(0-256) message, uint8 chatMode) clsend;
|
||||||
whisperMessage(uint32 receiverAvId, string(0-256) message) clsend;
|
whisperMessage(uint32 receiverAvId, string(0-256) message) clsend;
|
||||||
sfWhisperMessage(uint32 receiverAvId, string(0-256) message) clsend;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass FriendManager : DistributedObject {
|
dclass FriendManager : DistributedObject {
|
||||||
|
|
|
@ -10,8 +10,5 @@ class AvatarHandle:
|
||||||
def isUnderstandable(self):
|
def isUnderstandable(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, avId, chat):
|
||||||
if not base.cr.chatAgent.verifyMessage(chat):
|
pass
|
||||||
return
|
|
||||||
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
|
||||||
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.avatarId, self.getName(), newText, scrubbed)
|
|
|
@ -38,7 +38,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
self.DISLid = 0
|
self.DISLid = 0
|
||||||
self.adminAccess = 0
|
self.adminAccess = 0
|
||||||
self.autoRun = 0
|
self.autoRun = 0
|
||||||
self.whiteListEnabled = base.config.GetBool('whitelist-chat-enabled', 1)
|
|
||||||
self.lastTeleportQuery = time.time()
|
self.lastTeleportQuery = time.time()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -141,7 +140,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
|
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
|
||||||
if chatString:
|
if chatString:
|
||||||
self.displayWhisper(fromId, chatString, WTQuickTalker)
|
self.displayWhisper(fromId, chatString, WTQuickTalker)
|
||||||
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_NORMAL, msgIndex, fromId)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def whisperSCCustomTo(self, msgIndex, sendToId):
|
def whisperSCCustomTo(self, msgIndex, sendToId):
|
||||||
|
@ -163,7 +161,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
|
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
|
||||||
if chatString:
|
if chatString:
|
||||||
self.displayWhisper(fromId, chatString, WTQuickTalker)
|
self.displayWhisper(fromId, chatString, WTQuickTalker)
|
||||||
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_CUSTOM, msgIndex, fromId)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def whisperSCEmoteTo(self, emoteId, sendToId):
|
def whisperSCEmoteTo(self, emoteId, sendToId):
|
||||||
|
@ -177,7 +174,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
chatString = SCDecoders.decodeSCEmoteWhisperMsg(emoteId, handle.getName())
|
chatString = SCDecoders.decodeSCEmoteWhisperMsg(emoteId, handle.getName())
|
||||||
if chatString:
|
if chatString:
|
||||||
self.displayWhisper(fromId, chatString, WTEmote)
|
self.displayWhisper(fromId, chatString, WTEmote)
|
||||||
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_EMOTE, emoteId, fromId)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def setChatAbsolute(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
|
def setChatAbsolute(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
|
||||||
|
@ -185,32 +181,27 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
if not quiet:
|
if not quiet:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalk(self, chat):
|
||||||
if not base.cr.verifyMessage(chat):
|
if not base.cr.verifyMessage(chat):
|
||||||
return
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(self.doId):
|
||||||
return
|
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
|
||||||
self.displayTalk(newText)
|
|
||||||
if base.talkAssistant.isThought(newText):
|
|
||||||
newText = base.talkAssistant.removeThoughtPrefix(newText)
|
|
||||||
base.talkAssistant.receiveThought(fromAV, avatarName, fromAC, None, newText, scrubbed)
|
|
||||||
else:
|
|
||||||
base.talkAssistant.receiveOpenTalk(fromAV, avatarName, fromAC, None, newText, scrubbed)
|
|
||||||
return
|
return
|
||||||
|
#newText, scrubbed = self.scrubTalk(chat, mods)
|
||||||
|
self.displayTalk(chat)
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalkWhisper(self, avId, chat):
|
||||||
if not base.cr.verifyMessage(chat):
|
if not base.cr.verifyMessage(chat):
|
||||||
return
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(avId):
|
||||||
return
|
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
|
||||||
self.displayTalkWhisper(fromAV, avatarName, chat, mods)
|
|
||||||
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.doId, self.getName(), newText, scrubbed)
|
|
||||||
return
|
return
|
||||||
|
self.displayTalkWhisper(avId, chat)
|
||||||
|
|
||||||
def displayTalkWhisper(self, fromId, avatarName, chatString, mods):
|
def displayTalk(self, chat):
|
||||||
print 'TalkWhisper from %s: %s' % (fromId, chatString)
|
print 'displaytalk AV'
|
||||||
|
print 'Talk: %s' % chat
|
||||||
|
|
||||||
|
def displayTalkWhisper(self, avId, chat):
|
||||||
|
print 'TalkWhisper from %s: %s' % (avId, chat)
|
||||||
|
|
||||||
def scrubTalk(self, chat, mods):
|
def scrubTalk(self, chat, mods):
|
||||||
return chat
|
return chat
|
||||||
|
@ -229,7 +220,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
|
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
|
||||||
if chatString:
|
if chatString:
|
||||||
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout, quiet=1)
|
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout, quiet=1)
|
||||||
base.talkAssistant.receiveOpenSpeedChat(TalkAssistant.SPEEDCHAT_NORMAL, msgIndex, self.doId)
|
|
||||||
|
|
||||||
def b_setSCCustom(self, msgIndex):
|
def b_setSCCustom(self, msgIndex):
|
||||||
self.setSCCustom(msgIndex)
|
self.setSCCustom(msgIndex)
|
||||||
|
@ -245,7 +235,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
|
||||||
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
|
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
|
||||||
if chatString:
|
if chatString:
|
||||||
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout)
|
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout)
|
||||||
base.talkAssistant.receiveOpenSpeedChat(TalkAssistant.SPEEDCHAT_CUSTOM, msgIndex, self.doId)
|
|
||||||
|
|
||||||
def b_setSCEmote(self, emoteId):
|
def b_setSCEmote(self, emoteId):
|
||||||
self.b_setEmoteState(emoteId, animMultiplier=self.animMultiplier)
|
self.b_setEmoteState(emoteId, animMultiplier=self.animMultiplier)
|
||||||
|
|
|
@ -38,11 +38,6 @@ class ChatAgent(DistributedObjectGlobal):
|
||||||
return
|
return
|
||||||
self.sendUpdate('whisperMessage', [receiverAvId, message])
|
self.sendUpdate('whisperMessage', [receiverAvId, message])
|
||||||
|
|
||||||
def sendSFWhisperMessage(self, receiverAvId, message):
|
|
||||||
if not self.verifyMessage(message):
|
|
||||||
return
|
|
||||||
self.sendUpdate('sfWhisperMessage', [receiverAvId, message])
|
|
||||||
|
|
||||||
@magicWord(category=CATEGORY_MODERATOR, types=[int])
|
@magicWord(category=CATEGORY_MODERATOR, types=[int])
|
||||||
def chatmode(mode=-1):
|
def chatmode(mode=-1):
|
||||||
""" Set the chat mode of the current avatar. """
|
""" Set the chat mode of the current avatar. """
|
||||||
|
|
|
@ -1,21 +1,13 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
||||||
# TODO: OTP should not depend on Toontown... Hrrm.
|
|
||||||
from toontown.chat.TTWhiteList import TTWhiteList
|
|
||||||
from otp.distributed import OtpDoGlobals
|
from otp.distributed import OtpDoGlobals
|
||||||
import SequenceList
|
|
||||||
|
|
||||||
class ChatAgentUD(DistributedObjectGlobalUD):
|
class ChatAgentUD(DistributedObjectGlobalUD):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
|
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
|
||||||
|
|
||||||
def announceGenerate(self):
|
def announceGenerate(self):
|
||||||
DistributedObjectGlobalUD.announceGenerate(self)
|
DistributedObjectGlobalUD.announceGenerate(self)
|
||||||
self.wantBlacklistSequence = config.GetBool('want-blacklist-sequence', True)
|
|
||||||
self.wantWhitelist = config.GetBool('want-whitelist', True)
|
|
||||||
if self.wantWhitelist:
|
|
||||||
self.whiteList = TTWhiteList()
|
|
||||||
if self.wantBlacklistSequence:
|
|
||||||
self.sequenceList = SequenceList.SequenceList()
|
|
||||||
self.chatMode2channel = {
|
self.chatMode2channel = {
|
||||||
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
|
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
|
||||||
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
|
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
|
||||||
|
@ -26,114 +18,36 @@ class ChatAgentUD(DistributedObjectGlobalUD):
|
||||||
2 : "[ADMIN] ",
|
2 : "[ADMIN] ",
|
||||||
3 : "[SYSADMIN] ",
|
3 : "[SYSADMIN] ",
|
||||||
}
|
}
|
||||||
# Open chat
|
|
||||||
def chatMessage(self, message, chatMode):
|
def chatMessage(self, message, chatMode):
|
||||||
sender = self.air.getAvatarIdFromSender()
|
sender = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if sender == 0:
|
if sender == 0:
|
||||||
self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
|
self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
|
||||||
issue='Account sent chat without an avatar', message=message)
|
issue='Account sent chat without an avatar', message=message)
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.wantWhitelist:
|
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message)
|
||||||
cleanMessage, modifications = self.cleanWhitelist(message)
|
|
||||||
else:
|
|
||||||
cleanMessage, modifications = message, []
|
|
||||||
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message, cleanMsg=cleanMessage)
|
|
||||||
|
|
||||||
# TODO: The above is probably a little too ugly for my taste... Maybe AIR
|
|
||||||
# should be given an API for sending updates for unknown objects?
|
|
||||||
if chatMode != 0:
|
if chatMode != 0:
|
||||||
# Staff messages do not need to be cleaned. [TODO: Blacklist this?]
|
|
||||||
if message.startswith('.'):
|
if message.startswith('.'):
|
||||||
# This is a thought bubble, move the point to the start.
|
message = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
|
||||||
cleanMessage = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
|
|
||||||
else:
|
else:
|
||||||
cleanMessage = self.chatMode2prefix.get(chatMode, "") + message
|
message = self.chatMode2prefix.get(chatMode, "") + message
|
||||||
modifications = []
|
|
||||||
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
||||||
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender),
|
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender), self.air.ourChannel, [message])
|
||||||
self.air.ourChannel,
|
|
||||||
[0, 0, '', cleanMessage, modifications, 0])
|
|
||||||
self.air.send(dg)
|
self.air.send(dg)
|
||||||
|
|
||||||
# Regular filtered chat
|
|
||||||
def whisperMessage(self, receiverAvId, message):
|
def whisperMessage(self, receiverAvId, message):
|
||||||
sender = self.air.getAvatarIdFromSender()
|
sender = self.air.getAvatarIdFromSender()
|
||||||
|
|
||||||
if sender == 0:
|
if sender == 0:
|
||||||
self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
|
self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
|
||||||
issue='Account sent chat without an avatar', message=message)
|
issue='Account sent chat without an avatar', message=message)
|
||||||
return
|
return
|
||||||
|
|
||||||
cleanMessage, modifications = self.cleanWhitelist(message)
|
self.air.writeServerEvent('whisper-said', avId=sender, reciever=receiverAvId, msg=message)
|
||||||
# Maybe a better "cleaner" way of doing this, but it works
|
|
||||||
self.air.writeServerEvent('whisper-said', avId=sender, reciever=receiverAvId, msg=message, cleanMsg=cleanMessage)
|
|
||||||
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
||||||
dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel,
|
dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel, [sender, message])
|
||||||
[sender, sender, '', cleanMessage, modifications, 0])
|
|
||||||
self.air.send(dg)
|
self.air.send(dg)
|
||||||
|
|
||||||
# True friend unfiltered chat
|
|
||||||
def sfWhisperMessage(self, receiverAvId, message):
|
|
||||||
sender = self.air.getAvatarIdFromSender()
|
|
||||||
if sender == 0:
|
|
||||||
self.air.writeServerEvent('suspicious', accId=self.air.getAccountIdFromSender(),
|
|
||||||
issue='Account sent chat without an avatar', message=message)
|
|
||||||
return
|
|
||||||
|
|
||||||
cleanMessage = self.cleanBlacklist(message)
|
|
||||||
|
|
||||||
self.air.writeServerEvent('sf-whisper-said', avId=sender, reciever=receiverAvId, msg=message, cleanMsg=cleanMessage)
|
|
||||||
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
|
||||||
dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel,
|
|
||||||
[sender, sender, '', cleanMessage, [], 0])
|
|
||||||
self.air.send(dg)
|
|
||||||
|
|
||||||
# Filter the chat message
|
|
||||||
def cleanWhitelist(self, message):
|
|
||||||
modifications = []
|
|
||||||
words = message.split(' ')
|
|
||||||
offset = 0
|
|
||||||
for word in words:
|
|
||||||
if word and not self.whiteList.isWord(word):
|
|
||||||
modifications.append((offset, offset+len(word)-1))
|
|
||||||
offset += len(word) + 1
|
|
||||||
|
|
||||||
cleanMessage = message
|
|
||||||
if self.wantBlacklistSequence:
|
|
||||||
modifications += self.cleanSequences(cleanMessage)
|
|
||||||
|
|
||||||
for modStart, modStop in modifications:
|
|
||||||
# Traverse through modification list and replace the characters of non-whitelisted words and/or blacklisted sequences with asterisks.
|
|
||||||
cleanMessage = cleanMessage[:modStart] + '*' * (modStop - modStart + 1) + cleanMessage[modStop + 1:]
|
|
||||||
|
|
||||||
return (cleanMessage, modifications)
|
|
||||||
|
|
||||||
# Check the black list for black-listed words
|
|
||||||
def cleanBlacklist(self, message):
|
|
||||||
# We don't have a black list so we just return the full message
|
|
||||||
return message
|
|
||||||
|
|
||||||
# Check for black-listed word sequences and scrub accordingly.
|
|
||||||
def cleanSequences(self, message):
|
|
||||||
modifications = []
|
|
||||||
offset = 0
|
|
||||||
words = message.split()
|
|
||||||
for wordit in xrange(len(words)):
|
|
||||||
word = words[wordit].lower()
|
|
||||||
seqlist = self.sequenceList.getList(word)
|
|
||||||
if len(seqlist) > 0:
|
|
||||||
for seqit in xrange(len(seqlist)):
|
|
||||||
sequence = seqlist[seqit]
|
|
||||||
splitseq = sequence.split()
|
|
||||||
if len(words) - (wordit + 1) >= len(splitseq):
|
|
||||||
cmplist = words[wordit + 1:]
|
|
||||||
del cmplist[len(splitseq):]
|
|
||||||
cmplist = [word.lower() for word in cmplist]
|
|
||||||
if cmp(cmplist, splitseq) == 0:
|
|
||||||
modifications.append((offset, offset + len(word) + len(sequence) - 1))
|
|
||||||
offset += len(word) + 1
|
|
||||||
|
|
||||||
return modifications
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -204,147 +204,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
message.getSenderAccountName(),
|
message.getSenderAccountName(),
|
||||||
message.getBody())
|
message.getBody())
|
||||||
|
|
||||||
def receiveOpenTalk(self, senderAvId, avatarName, accountId, accountName, message, scrubbed = 0):
|
|
||||||
error = None
|
|
||||||
if not avatarName and senderAvId:
|
|
||||||
localAvatar.sendUpdate('logSuspiciousEvent', ['receiveOpenTalk: invalid avatar name (%s)' % senderAvId])
|
|
||||||
avatarName = self.findAvatarName(senderAvId)
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, senderAvId, avatarName, accountId, accountName, None, None, None, None, TALK_OPEN, None)
|
|
||||||
if senderAvId != localAvatar.doId:
|
|
||||||
self.addHandle(senderAvId, newMessage)
|
|
||||||
reject = 0
|
|
||||||
if senderAvId:
|
|
||||||
reject = self.addToHistoryDoId(newMessage, senderAvId, scrubbed)
|
|
||||||
if accountId:
|
|
||||||
self.addToHistoryDISLId(newMessage, accountId)
|
|
||||||
if reject == 1:
|
|
||||||
newMessage.setBody(OTPLocalizer.AntiSpamInChat)
|
|
||||||
if reject != 2:
|
|
||||||
isSpam = self.spamDictByDoId.get(senderAvId) and reject
|
|
||||||
if not isSpam:
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyOpen.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
if newMessage.getBody() == OTPLocalizer.AntiSpamInChat:
|
|
||||||
self.spamDictByDoId[senderAvId] = 1
|
|
||||||
else:
|
|
||||||
self.spamDictByDoId[senderAvId] = 0
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveWhisperTalk(self, avatarId, avatarName, accountId, accountName, toId, toName, message, scrubbed = 0):
|
|
||||||
error = None
|
|
||||||
if not avatarName and avatarId:
|
|
||||||
avatarName = self.findAvatarName(avatarId)
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, avatarId, avatarName, accountId, accountName, toId, toName, None, None, TALK_WHISPER, None)
|
|
||||||
if avatarId == localAvatar.doId:
|
|
||||||
self.addHandle(toId, newMessage)
|
|
||||||
else:
|
|
||||||
self.addHandle(avatarId, newMessage)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
if avatarId:
|
|
||||||
self.addToHistoryDoId(newMessage, avatarId, scrubbed)
|
|
||||||
if accountId:
|
|
||||||
self.addToHistoryDISLId(newMessage, accountId)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveThought(self, avatarId, avatarName, accountId, accountName, message, scrubbed = 0):
|
|
||||||
error = None
|
|
||||||
if not avatarName and avatarId:
|
|
||||||
avatarName = self.findAvatarName(avatarId)
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, avatarId, avatarName, accountId, accountName, None, None, None, None, AVATAR_THOUGHT, None)
|
|
||||||
if avatarId != localAvatar.doId:
|
|
||||||
self.addHandle(avatarId, newMessage)
|
|
||||||
reject = 0
|
|
||||||
if avatarId:
|
|
||||||
reject = self.addToHistoryDoId(newMessage, avatarId, scrubbed)
|
|
||||||
if accountId:
|
|
||||||
self.addToHistoryDISLId(newMessage, accountId)
|
|
||||||
if reject == 1:
|
|
||||||
newMessage.setBody(OTPLocalizer.AntiSpamInChat)
|
|
||||||
if reject != 2:
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyOpen.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveGameMessage(self, message):
|
|
||||||
error = None
|
|
||||||
if not self.isThought(message):
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, None, None, None, None, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, INFO_GAME, None)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyUpdates.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveSystemMessage(self, message):
|
|
||||||
error = None
|
|
||||||
if not self.isThought(message):
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, None, None, None, None, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, INFO_SYSTEM, None)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyUpdates.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveFriendUpdate(self, friendId, friendName, isOnline):
|
|
||||||
if isOnline:
|
|
||||||
onlineMessage = OTPLocalizer.FriendOnline
|
|
||||||
else:
|
|
||||||
onlineMessage = OTPLocalizer.FriendOffline
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), onlineMessage, friendId, friendName, None, None, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, UPDATE_FRIEND, None)
|
|
||||||
self.addHandle(friendId, newMessage)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyUpdates.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return
|
|
||||||
|
|
||||||
def receiveFriendAccountUpdate(self, friendId, friendName, isOnline):
|
|
||||||
if isOnline:
|
|
||||||
onlineMessage = OTPLocalizer.FriendOnline
|
|
||||||
else:
|
|
||||||
onlineMessage = OTPLocalizer.FriendOffline
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), onlineMessage, None, None, friendId, friendName, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, UPDATE_FRIEND, None)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyUpdates.append(newMessage)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return
|
|
||||||
|
|
||||||
def receiveOpenSpeedChat(self, type, messageIndex, senderAvId, name = None):
|
|
||||||
error = None
|
|
||||||
if not name and senderAvId:
|
|
||||||
name = self.findAvatarName(senderAvId)
|
|
||||||
if type == SPEEDCHAT_NORMAL:
|
|
||||||
message = self.SCDecoder.decodeSCStaticTextMsg(messageIndex)
|
|
||||||
elif type == SPEEDCHAT_EMOTE:
|
|
||||||
message = self.SCDecoder.decodeSCEmoteWhisperMsg(messageIndex, name)
|
|
||||||
elif type == SPEEDCHAT_CUSTOM:
|
|
||||||
message = self.SCDecoder.decodeSCCustomMsg(messageIndex)
|
|
||||||
if message in (None, ''):
|
|
||||||
return
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, senderAvId, name, None, None, None, None, None, None, TALK_OPEN, None)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyOpen.append(newMessage)
|
|
||||||
self.addToHistoryDoId(newMessage, senderAvId)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def receiveAvatarWhisperSpeedChat(self, type, messageIndex, senderAvId, name = None):
|
|
||||||
error = None
|
|
||||||
if not name and senderAvId:
|
|
||||||
name = self.findAvatarName(senderAvId)
|
|
||||||
if type == SPEEDCHAT_NORMAL:
|
|
||||||
message = self.SCDecoder.decodeSCStaticTextMsg(messageIndex)
|
|
||||||
elif type == SPEEDCHAT_EMOTE:
|
|
||||||
message = self.SCDecoder.decodeSCEmoteWhisperMsg(messageIndex, name)
|
|
||||||
elif type == SPEEDCHAT_CUSTOM:
|
|
||||||
message = self.SCDecoder.decodeSCCustomMsg(messageIndex)
|
|
||||||
newMessage = TalkMessage(self.countMessage(), self.stampTime(), message, senderAvId, name, None, None, localAvatar.doId, localAvatar.getName(), localAvatar.DISLid, localAvatar.DISLname, TALK_WHISPER, None)
|
|
||||||
self.historyComplete.append(newMessage)
|
|
||||||
self.historyOpen.append(newMessage)
|
|
||||||
self.addToHistoryDoId(newMessage, senderAvId)
|
|
||||||
messenger.send('NewOpenMessage', [newMessage])
|
|
||||||
return error
|
|
||||||
|
|
||||||
def sendOpenTalk(self, message):
|
def sendOpenTalk(self, message):
|
||||||
error = None
|
error = None
|
||||||
doId = base.localAvatar.doId
|
doId = base.localAvatar.doId
|
||||||
|
@ -364,21 +223,6 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
return error
|
return error
|
||||||
|
|
||||||
def sendWhisperTalk(self, message, receiverAvId):
|
def sendWhisperTalk(self, message, receiverAvId):
|
||||||
modifications = []
|
|
||||||
words = message.split(' ')
|
|
||||||
offset = 0
|
|
||||||
WantWhitelist = config.GetBool('want-whitelist', 1)
|
|
||||||
for word in words:
|
|
||||||
if word and not self.whiteList.isWord(word) and WantWhitelist:
|
|
||||||
modifications.append((offset, offset+len(word)-1))
|
|
||||||
offset += len(word) + 1
|
|
||||||
|
|
||||||
cleanMessage = message
|
|
||||||
for modStart, modStop in modifications:
|
|
||||||
cleanMessage = cleanMessage[:modStart] + '*'*(modStop-modStart+1) + cleanMessage[modStop+1:]
|
|
||||||
|
|
||||||
message, scrubbed = base.localAvatar.scrubTalk(cleanMessage, modifications)
|
|
||||||
|
|
||||||
base.cr.ttsFriendsManager.sendUpdate('sendTalkWhisper', [receiverAvId, message])
|
base.cr.ttsFriendsManager.sendUpdate('sendTalkWhisper', [receiverAvId, message])
|
||||||
|
|
||||||
def sendOpenSpeedChat(self, type, messageIndex):
|
def sendOpenSpeedChat(self, type, messageIndex):
|
||||||
|
|
|
@ -34,12 +34,3 @@ class TalkHandle(AvatarHandle):
|
||||||
self.accountId = message.getReceiverAccountId()
|
self.accountId = message.getReceiverAccountId()
|
||||||
if not self.accountName and message.getReceiverAccountName():
|
if not self.accountName and message.getReceiverAccountName():
|
||||||
self.accountName = message.getReceiverAccountName()
|
self.accountName = message.getReceiverAccountName()
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
|
||||||
if not base.cr.verifyMessage(chat):
|
|
||||||
return
|
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
|
||||||
return
|
|
||||||
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
|
|
||||||
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.avatarId, self.getName(), newText, scrubbed)
|
|
||||||
return
|
|
||||||
|
|
|
@ -300,9 +300,3 @@ AvatarFriendRejectInviteEvent = 'avatarFriendRejectInviteEvent'
|
||||||
AvatarFriendRetractInviteEvent = 'avatarFriendRetractInviteEvent'
|
AvatarFriendRetractInviteEvent = 'avatarFriendRetractInviteEvent'
|
||||||
AvatarFriendRejectRemoveEvent = 'avatarFriendRejectRemoveEvent'
|
AvatarFriendRejectRemoveEvent = 'avatarFriendRejectRemoveEvent'
|
||||||
WhisperIncomingEvent = 'whisperIncomingEvent'
|
WhisperIncomingEvent = 'whisperIncomingEvent'
|
||||||
ChatFeedback_PassedBlacklist = 32
|
|
||||||
ChatFeedback_Whitelist = 64
|
|
||||||
ChatFeedback_OpenChat = 128
|
|
||||||
AvatarPendingCreate = -1
|
|
||||||
AvatarSlotUnavailable = -2
|
|
||||||
AvatarSlotAvailable = -3
|
|
|
@ -127,9 +127,7 @@ class TTSFriendsManager(DistributedObjectGlobal):
|
||||||
base.localAvatar.setWhisperSCEmoteFrom(fromId, emoteId)
|
base.localAvatar.setWhisperSCEmoteFrom(fromId, emoteId)
|
||||||
|
|
||||||
def receiveTalkWhisper(self, fromId, message):
|
def receiveTalkWhisper(self, fromId, message):
|
||||||
toon = base.cr.identifyAvatar(fromId)
|
base.localAvatar.setTalkWhisper(fromId, message)
|
||||||
if toon:
|
|
||||||
base.localAvatar.setTalkWhisper(fromId, 0, toon.getName(), message, [], 0)
|
|
||||||
|
|
||||||
def d_battleSOS(self, toId):
|
def d_battleSOS(self, toId):
|
||||||
self.sendUpdate('battleSOS', [toId])
|
self.sendUpdate('battleSOS', [toId])
|
||||||
|
|
|
@ -455,44 +455,30 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
else:
|
else:
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
|
||||||
if not base.cr.chatAgent.verifyMessage(chat):
|
|
||||||
return
|
|
||||||
if base.localAvatar.isIgnored(self.doId if fromAV == 0 else fromAV):
|
|
||||||
return
|
|
||||||
timestamp = time.strftime('%m-%d-%Y %H:%M:%S', time.localtime())
|
|
||||||
if fromAV == 0:
|
|
||||||
print ':%s: setTalk: %r, %r, %r' % (timestamp, self.doId, self.name, chat)
|
|
||||||
else:
|
|
||||||
print ':%s: setTalk: %r, %r, %r' % (timestamp, fromAV, avatarName, chat)
|
|
||||||
if base.config.GetBool('want-sleep-reply-on-regular-chat', 0):
|
|
||||||
if base.localAvatar.sleepFlag == 1:
|
|
||||||
base.cr.ttsFriendsManager.d_sleepAutoReply(fromAV)
|
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
|
||||||
self.displayTalk(newText)
|
|
||||||
base.talkAssistant.receiveOpenTalk(fromAV, avatarName, fromAC, None, newText)
|
|
||||||
|
|
||||||
def isAvFriend(self, avId):
|
def isAvFriend(self, avId):
|
||||||
return base.cr.isFriend(avId)
|
return base.cr.isFriend(avId)
|
||||||
|
|
||||||
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
|
def setTalk(self, chat):
|
||||||
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
|
return
|
||||||
|
if base.localAvatar.isIgnored(self.doId):
|
||||||
|
return
|
||||||
|
self.displayTalk(chat)
|
||||||
|
|
||||||
|
def setTalkWhisper(self, avId, chat):
|
||||||
if not base.cr.chatAgent.verifyMessage(chat):
|
if not base.cr.chatAgent.verifyMessage(chat):
|
||||||
return
|
return
|
||||||
if not localAvatar.acceptingNonFriendWhispers:
|
if not localAvatar.acceptingNonFriendWhispers:
|
||||||
if not self.isAvFriend(fromAV):
|
if not self.isAvFriend(avId):
|
||||||
return
|
return
|
||||||
if base.localAvatar.isIgnored(fromAV):
|
if base.localAvatar.isIgnored(avId):
|
||||||
return
|
|
||||||
if base.config.GetBool('ignore-whispers', 0):
|
|
||||||
return
|
return
|
||||||
if base.localAvatar.sleepFlag == 1:
|
if base.localAvatar.sleepFlag == 1:
|
||||||
if not base.cr.identifyAvatar(fromAV) == base.localAvatar:
|
if not base.cr.identifyAvatar(avId) == base.localAvatar:
|
||||||
base.cr.ttsFriendsManager.d_sleepAutoReply(fromAV)
|
base.cr.ttsFriendsManager.d_sleepAutoReply(avId)
|
||||||
newText, scrubbed = self.scrubTalk(chat, mods)
|
if base.whiteList:
|
||||||
self.displayTalkWhisper(fromAV, avatarName, chat, mods)
|
chat = base.whiteList.processThroughAll(chat, self.chatGarbler)
|
||||||
timestamp = time.strftime('%m-%d-%Y %H:%M:%S', time.localtime())
|
self.displayTalkWhisper(avId, chat)
|
||||||
print ':%s: receiveWhisperTalk: %r, %r, %r, %r, %r, %r, %r' % (timestamp, fromAV, avatarName, fromAC, None, self.doId, self.getName(), newText)
|
|
||||||
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.doId, self.getName(), newText)
|
|
||||||
|
|
||||||
def setSleepAutoReply(self, fromId):
|
def setSleepAutoReply(self, fromId):
|
||||||
pass
|
pass
|
||||||
|
@ -2177,7 +2163,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
self.nametag.setChatText(chatString, timeout=bool(chatFlags & CFTimeout))
|
self.nametag.setChatText(chatString, timeout=bool(chatFlags & CFTimeout))
|
||||||
self.playCurrentDialogue(dialogue, chatFlags - CFSpeech, interrupt)
|
self.playCurrentDialogue(dialogue, chatFlags - CFSpeech, interrupt)
|
||||||
|
|
||||||
def displayTalk(self, chatString, mods=None):
|
def displayTalk(self, chatString):
|
||||||
flags = CFSpeech | CFTimeout
|
flags = CFSpeech | CFTimeout
|
||||||
self.nametag.setChatType(NametagGlobals.CHAT)
|
self.nametag.setChatType(NametagGlobals.CHAT)
|
||||||
if base.talkAssistant.isThought(chatString):
|
if base.talkAssistant.isThought(chatString):
|
||||||
|
@ -2404,7 +2390,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
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.garble(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 base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
flag = 0
|
flag = 0
|
||||||
|
@ -2429,7 +2415,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
elif word[0] == '\x07':
|
elif word[0] == '\x07':
|
||||||
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02')
|
||||||
elif not self.whiteListEnabled or base.whiteList.isWord(word):
|
elif not base.whiteList.isWord(word):
|
||||||
newwords.append(word)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
newwords.append('\x01WLRed\x01' + word + '\x02')
|
newwords.append('\x01WLRed\x01' + word + '\x02')
|
||||||
|
|
|
@ -426,19 +426,19 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
|
||||||
self.gmNameTagEnabled = 1
|
self.gmNameTagEnabled = 1
|
||||||
self.d_updateGMNameTag()
|
self.d_updateGMNameTag()
|
||||||
|
|
||||||
def displayTalkWhisper(self, fromId, avatarName, rawString, mods):
|
def displayTalkWhisper(self, avId, chat):
|
||||||
sender = base.cr.identifyAvatar(fromId)
|
# SKRUB PLZ
|
||||||
if sender:
|
sender = base.cr.identifyAvatar(avId)
|
||||||
chatString, scrubbed = sender.scrubTalk(rawString, mods)
|
|
||||||
else:
|
if not sender:
|
||||||
chatString, scrubbed = self.scrubTalk(rawString, mods)
|
return
|
||||||
sender = self
|
|
||||||
sfx = self.soundWhisper
|
name = sender.getName()
|
||||||
chatString = avatarName + ': ' + chatString
|
chatString = '%s: %s' % (name, chat)
|
||||||
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
|
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
|
||||||
whisper.setClickable(avatarName, fromId)
|
whisper.setClickable(name, avId)
|
||||||
whisper.manage(base.marginManager)
|
whisper.manage(base.marginManager)
|
||||||
base.playSfx(sfx)
|
base.playSfx(self.soundWhisper)
|
||||||
|
|
||||||
def isLocal(self):
|
def isLocal(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue