mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Chat Offense
This commit is contained in:
parent
ae40f21034
commit
a89e89f99a
4 changed files with 1355 additions and 26 deletions
|
@ -1,40 +1,83 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD
|
||||
from direct.distributed.PyDatagram import PyDatagram
|
||||
from direct.distributed.MsgTypes import *
|
||||
from otp.distributed import OtpDoGlobals
|
||||
from toontown.toonbase import TTLocalizer
|
||||
|
||||
BLACKLIST = TTLocalizer.Blacklist
|
||||
OFFENSE_MSGS = ('-- DEV CHAT -- word blocked: %s', 'Watch your language! This is your first offense. You said "%s".',
|
||||
'Watch your language! This is your second offense. Next offense you\'ll get banned for 24 hours. You said "%s".')
|
||||
|
||||
class ChatAgentUD(DistributedObjectGlobalUD):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("ChatAgentUD")
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('ChatAgentUD')
|
||||
WantWhitelist = config.GetBool('want-whitelist', True)
|
||||
|
||||
chatMode2channel = {
|
||||
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
|
||||
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
|
||||
3 : OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
|
||||
}
|
||||
chatMode2prefix = {
|
||||
1 : "[MOD] ",
|
||||
2 : "[ADMIN] ",
|
||||
3 : "[SYSADMIN] ",
|
||||
}
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectGlobalUD.announceGenerate(self)
|
||||
|
||||
self.chatMode2channel = {
|
||||
1 : OtpDoGlobals.OTP_MOD_CHANNEL,
|
||||
2 : OtpDoGlobals.OTP_ADMIN_CHANNEL,
|
||||
3 : OtpDoGlobals.OTP_SYSADMIN_CHANNEL,
|
||||
}
|
||||
self.chatMode2prefix = {
|
||||
1 : "[MOD] ",
|
||||
2 : "[ADMIN] ",
|
||||
3 : "[SYSADMIN] ",
|
||||
}
|
||||
self.offenses = {}
|
||||
|
||||
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)
|
||||
self.air.writeServerEvent('suspicious', self.air.getAccountIdFromSender(),
|
||||
'Account sent chat without an avatar', message)
|
||||
return
|
||||
|
||||
self.air.writeServerEvent('chat-said', avId=sender, chatMode=chatMode, msg=message)
|
||||
if chatMode == 0:
|
||||
if self.detectBadWords(self.air.getMsgSender(), message):
|
||||
return
|
||||
|
||||
if chatMode != 0:
|
||||
if message.startswith('.'):
|
||||
message = '.' + self.chatMode2prefix.get(chatMode, "") + message[1:]
|
||||
else:
|
||||
message = self.chatMode2prefix.get(chatMode, "") + message
|
||||
self.air.writeServerEvent('chat-said', sender, message)
|
||||
|
||||
DistributedAvatar = self.air.dclassesByName['DistributedAvatarUD']
|
||||
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, self.chatMode2channel.get(chatMode, sender), self.air.ourChannel, [message])
|
||||
dg = DistributedAvatar.aiFormatUpdate('setTalk', sender, sender,
|
||||
self.air.ourChannel,
|
||||
[message])
|
||||
self.air.send(dg)
|
||||
|
||||
def detectBadWords(self, sender, message):
|
||||
words = message.split()
|
||||
print words
|
||||
for word in words:
|
||||
if word.lower() in BLACKLIST:
|
||||
accountId = (sender >> 32) & 0xFFFFFFFF
|
||||
avId = sender & 0xFFFFFFFF
|
||||
|
||||
if not sender in self.offenses:
|
||||
self.offenses[sender] = 0
|
||||
|
||||
if self.air.friendsManager.getToonAccess(avId) < 300:
|
||||
self.offenses[sender] += 1
|
||||
|
||||
if self.offenses[sender] >= 3:
|
||||
msg = 'Banned'
|
||||
|
||||
else:
|
||||
msg = OFFENSE_MSGS[self.offenses[sender]] % word
|
||||
dclass = self.air.dclassesByName['ClientServicesManagerUD']
|
||||
dg = dclass.aiFormatUpdate('systemMessage',
|
||||
OtpDoGlobals.OTP_DO_ID_CLIENT_SERVICES_MANAGER,
|
||||
sender, 1000000, [msg])
|
||||
self.air.send(dg)
|
||||
#self.air.banManager.ban(sender, 2, 'language')
|
||||
|
||||
self.air.writeServerEvent('chat-offense', accountId, word=word, num=self.offenses[sender], msg=msg)
|
||||
if self.offenses[sender] >= 3:
|
||||
del self.offenses[sender]
|
||||
|
||||
return 1
|
||||
|
||||
return 0
|
|
@ -149,6 +149,7 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD):
|
|||
self.onlineToons = []
|
||||
self.tpRequests = {}
|
||||
self.whisperRequests = {}
|
||||
self.toon2data = {}
|
||||
self.operations = []
|
||||
self.delayTime = 1.0
|
||||
|
||||
|
@ -252,6 +253,8 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD):
|
|||
self.sendUpdateToAvatarId(friendId, 'friendOffline', [doId])
|
||||
if doId in self.onlineToons:
|
||||
self.onlineToons.remove(doId)
|
||||
if doId in self.toon2data:
|
||||
del self.toon2data[doId]
|
||||
self.air.dbInterface.queryObject(self.air.dbId, doId, handleToon)
|
||||
|
||||
# -- Clear List --
|
||||
|
@ -356,3 +359,19 @@ class TTSFriendsManagerUD(DistributedObjectGlobalUD):
|
|||
def sleepAutoReply(self, toId):
|
||||
requester = self.air.getAvatarIdFromSender()
|
||||
self.sendUpdateToAvatarId(toId, 'setSleepAutoReply', [requester])
|
||||
|
||||
def getToonAccess(self, doId):
|
||||
return self.toon2data.get(doId, {}).get('access', 0)
|
||||
|
||||
def getToonName(self, doId):
|
||||
return self.toon2data.get(doId, {}).get('name', '???')
|
||||
|
||||
def getToonAccId(self, doId):
|
||||
return self.toon2data.get(doId, {}).get('accId', 0)
|
||||
|
||||
def addToonData(self, doId, fields):
|
||||
data = {}
|
||||
data['access'] = fields.get('setAdminAccess', [0])[0]
|
||||
data['name'] = fields['setName'][0]
|
||||
data['accId'] = fields.get('setDISLid', [0])[0]
|
||||
self.toon2data[doId] = data
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -917,6 +917,10 @@ class LoadAvatarFSM(AvatarOperationFSM):
|
|||
# Tell the GlobalPartyManager as well:
|
||||
self.csm.air.globalPartyMgr.avatarJoined(self.avId)
|
||||
|
||||
fields = self.avatar
|
||||
fields.update({'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
|
||||
self.csm.air.friendsManager.addToonData(self.avId, fields)
|
||||
|
||||
self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
|
||||
self.demand('Off')
|
||||
return task.done
|
||||
|
|
Loading…
Reference in a new issue