DANIEL: Work on chat

This commit is contained in:
John 2015-05-30 20:46:06 +03:00 committed by Loudrob
parent d9454000b4
commit 33f99305df
11 changed files with 65 additions and 365 deletions

View file

@ -133,14 +133,8 @@ struct TalkModification {
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 {
setTalkWhisper(DoId fromAv, DoId fromAcc, string(0-256) avName,
string(0-400) chat, TalkModification [], uint8 flags) ownrecv clsend;
setTalkWhisper(uint32 avId, string(0-400) chat) ownrecv clsend;
};
dclass TalkPath_group {
@ -157,8 +151,7 @@ dclass DistributedAvatar : DistributedSmoothNode, TalkPath_whisper {
friendsNotify(DoId avId, int8 status) ownrecv airecv;
checkAvOnShard(DoId) clsend airecv;
confirmAvOnShard(DoId avId, int8 isOnShard);
setTalk(DoId fromAv, DoId fromAcc, string(0-256) avName,
string(0-400) chat, TalkModification [], uint8 flags) broadcast;
setTalk(string(0-400) chat) broadcast;
};
struct FriendEntry {
@ -194,7 +187,6 @@ dclass ChatAgent : DistributedObject {
adminChat(uint32 aboutId, string message);
chatMessage(string(0-256) message, uint8 chatMode) clsend;
whisperMessage(uint32 receiverAvId, string(0-256) message) clsend;
sfWhisperMessage(uint32 receiverAvId, string(0-256) message) clsend;
};
dclass FriendManager : DistributedObject {

View file

@ -10,8 +10,5 @@ class AvatarHandle:
def isUnderstandable(self):
return True
def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
if not base.cr.chatAgent.verifyMessage(chat):
return
newText, scrubbed = localAvatar.scrubTalk(chat, mods)
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.avatarId, self.getName(), newText, scrubbed)
def setTalkWhisper(self, avId, chat):
pass

View file

@ -38,7 +38,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
self.DISLid = 0
self.adminAccess = 0
self.autoRun = 0
self.whiteListEnabled = base.config.GetBool('whitelist-chat-enabled', 1)
self.lastTeleportQuery = time.time()
@staticmethod
@ -141,7 +140,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
if chatString:
self.displayWhisper(fromId, chatString, WTQuickTalker)
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_NORMAL, msgIndex, fromId)
return
def whisperSCCustomTo(self, msgIndex, sendToId):
@ -163,7 +161,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
if chatString:
self.displayWhisper(fromId, chatString, WTQuickTalker)
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_CUSTOM, msgIndex, fromId)
return
def whisperSCEmoteTo(self, emoteId, sendToId):
@ -177,7 +174,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
chatString = SCDecoders.decodeSCEmoteWhisperMsg(emoteId, handle.getName())
if chatString:
self.displayWhisper(fromId, chatString, WTEmote)
base.talkAssistant.receiveAvatarWhisperSpeedChat(TalkAssistant.SPEEDCHAT_EMOTE, emoteId, fromId)
return
def setChatAbsolute(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
@ -185,32 +181,27 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
if not quiet:
pass
def setTalk(self, fromAV, fromAC, avatarName, chat, mods, flags):
def setTalk(self, chat):
if not base.cr.verifyMessage(chat):
return
if base.localAvatar.isIgnored(fromAV):
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)
if base.localAvatar.isIgnored(self.doId):
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):
return
if base.localAvatar.isIgnored(fromAV):
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)
if base.localAvatar.isIgnored(avId):
return
self.displayTalkWhisper(avId, chat)
def displayTalkWhisper(self, fromId, avatarName, chatString, mods):
print 'TalkWhisper from %s: %s' % (fromId, chatString)
def displayTalk(self, chat):
print 'displaytalk AV'
print 'Talk: %s' % chat
def displayTalkWhisper(self, avId, chat):
print 'TalkWhisper from %s: %s' % (avId, chat)
def scrubTalk(self, chat, mods):
return chat
@ -229,7 +220,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
if chatString:
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout, quiet=1)
base.talkAssistant.receiveOpenSpeedChat(TalkAssistant.SPEEDCHAT_NORMAL, msgIndex, self.doId)
def b_setSCCustom(self, msgIndex):
self.setSCCustom(msgIndex)
@ -245,7 +235,6 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
if chatString:
self.setChatAbsolute(chatString, CFSpeech | CFQuicktalker | CFTimeout)
base.talkAssistant.receiveOpenSpeedChat(TalkAssistant.SPEEDCHAT_CUSTOM, msgIndex, self.doId)
def b_setSCEmote(self, emoteId):
self.b_setEmoteState(emoteId, animMultiplier=self.animMultiplier)

View file

@ -38,11 +38,6 @@ class ChatAgent(DistributedObjectGlobal):
return
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])
def chatmode(mode=-1):
""" Set the chat mode of the current avatar. """

View file

@ -1,21 +1,13 @@
from direct.directnotify import DirectNotifyGlobal
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
import SequenceList
class ChatAgentUD(DistributedObjectGlobalUD):
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
def 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 = {
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
@ -26,114 +18,36 @@ class ChatAgentUD(DistributedObjectGlobalUD):
2 : "[ADMIN] ",
3 : "[SYSADMIN] ",
}
# Open chat
def chatMessage(self, message, chatMode):
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
if self.wantWhitelist:
cleanMessage, modifications = self.cleanWhitelist(message)
else:
cleanMessage, modifications = message, []
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message, cleanMsg=cleanMessage)
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message)
# 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:
# Staff messages do not need to be cleaned. [TODO: Blacklist this?]
if message.startswith('.'):
# This is a thought bubble, move the point to the start.
cleanMessage = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
message = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
else:
cleanMessage = self.chatMode2prefix.get(chatMode, "") + message
modifications = []
message = self.chatMode2prefix.get(chatMode, "") + message
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender),
self.air.ourChannel,
[0, 0, '', cleanMessage, modifications, 0])
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender), self.air.ourChannel, [message])
self.air.send(dg)
# Regular filtered chat
def whisperMessage(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, modifications = self.cleanWhitelist(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)
self.air.writeServerEvent('whisper-said', avId=sender, reciever=receiverAvId, msg=message)
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel,
[sender, sender, '', cleanMessage, modifications, 0])
dg = DistributedAvatar.aiFormatUpdate('setTalkWhisper', receiverAvId, receiverAvId, self.air.ourChannel, [sender, message])
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

View file

@ -204,147 +204,6 @@ class TalkAssistant(DirectObject.DirectObject):
message.getSenderAccountName(),
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):
error = None
doId = base.localAvatar.doId
@ -364,21 +223,6 @@ class TalkAssistant(DirectObject.DirectObject):
return error
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])
def sendOpenSpeedChat(self, type, messageIndex):

View file

@ -34,12 +34,3 @@ class TalkHandle(AvatarHandle):
self.accountId = message.getReceiverAccountId()
if not self.accountName and 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

View file

@ -300,9 +300,3 @@ AvatarFriendRejectInviteEvent = 'avatarFriendRejectInviteEvent'
AvatarFriendRetractInviteEvent = 'avatarFriendRetractInviteEvent'
AvatarFriendRejectRemoveEvent = 'avatarFriendRejectRemoveEvent'
WhisperIncomingEvent = 'whisperIncomingEvent'
ChatFeedback_PassedBlacklist = 32
ChatFeedback_Whitelist = 64
ChatFeedback_OpenChat = 128
AvatarPendingCreate = -1
AvatarSlotUnavailable = -2
AvatarSlotAvailable = -3

View file

@ -127,9 +127,7 @@ class TTSFriendsManager(DistributedObjectGlobal):
base.localAvatar.setWhisperSCEmoteFrom(fromId, emoteId)
def receiveTalkWhisper(self, fromId, message):
toon = base.cr.identifyAvatar(fromId)
if toon:
base.localAvatar.setTalkWhisper(fromId, 0, toon.getName(), message, [], 0)
base.localAvatar.setTalkWhisper(fromId, message)
def d_battleSOS(self, toId):
self.sendUpdate('battleSOS', [toId])

View file

@ -455,44 +455,30 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
else:
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):
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):
return
if not localAvatar.acceptingNonFriendWhispers:
if not self.isAvFriend(fromAV):
if not self.isAvFriend(avId):
return
if base.localAvatar.isIgnored(fromAV):
return
if base.config.GetBool('ignore-whispers', 0):
if base.localAvatar.isIgnored(avId):
return
if base.localAvatar.sleepFlag == 1:
if not base.cr.identifyAvatar(fromAV) == base.localAvatar:
base.cr.ttsFriendsManager.d_sleepAutoReply(fromAV)
newText, scrubbed = self.scrubTalk(chat, mods)
self.displayTalkWhisper(fromAV, avatarName, chat, mods)
timestamp = time.strftime('%m-%d-%Y %H:%M:%S', time.localtime())
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)
if not base.cr.identifyAvatar(avId) == base.localAvatar:
base.cr.ttsFriendsManager.d_sleepAutoReply(avId)
if base.whiteList:
chat = base.whiteList.processThroughAll(chat, self.chatGarbler)
self.displayTalkWhisper(avId, chat)
def setSleepAutoReply(self, fromId):
pass
@ -2177,7 +2163,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.nametag.setChatText(chatString, timeout=bool(chatFlags & CFTimeout))
self.playCurrentDialogue(dialogue, chatFlags - CFSpeech, interrupt)
def displayTalk(self, chatString, mods=None):
def displayTalk(self, chatString):
flags = CFSpeech | CFTimeout
self.nametag.setChatType(NametagGlobals.CHAT)
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':
newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02')
scrubbed = 1
elif not self.whiteListEnabled or base.whiteList.isWord(word):
elif not base.whiteList.isWord(word):
newwords.append(word)
else:
flag = 0
@ -2429,7 +2415,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
newwords.append(word)
elif word[0] == '\x07':
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)
else:
newwords.append('\x01WLRed\x01' + word + '\x02')

View file

@ -426,19 +426,19 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.gmNameTagEnabled = 1
self.d_updateGMNameTag()
def displayTalkWhisper(self, fromId, avatarName, rawString, mods):
sender = base.cr.identifyAvatar(fromId)
if sender:
chatString, scrubbed = sender.scrubTalk(rawString, mods)
else:
chatString, scrubbed = self.scrubTalk(rawString, mods)
sender = self
sfx = self.soundWhisper
chatString = avatarName + ': ' + chatString
def displayTalkWhisper(self, avId, chat):
# SKRUB PLZ
sender = base.cr.identifyAvatar(avId)
if not sender:
return
name = sender.getName()
chatString = '%s: %s' % (name, chat)
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
whisper.setClickable(avatarName, fromId)
whisper.setClickable(name, avId)
whisper.manage(base.marginManager)
base.playSfx(sfx)
base.playSfx(self.soundWhisper)
def isLocal(self):
return 1