Remove Daniels ban system.

This commit is contained in:
Loudrob 2015-06-05 18:39:18 -04:00
parent ec3df81c15
commit aad0387696
2 changed files with 46 additions and 26 deletions

View file

@ -1,5 +1,5 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from toontown.uberdog.ClientServicesManagerUD import executeHttpRequestAndLog from toontown.uberdog.ClientServicesManagerUD import executeHttpRequest
import datetime import datetime
from direct.fsm.FSM import FSM from direct.fsm.FSM import FSM
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
@ -7,13 +7,15 @@ from direct.distributed.MsgTypes import *
from otp.ai.MagicWordGlobal import * from otp.ai.MagicWordGlobal import *
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
class BanFSM(FSM): class BanFSM(FSM):
def __init__(self, air, invokerId, avId, comment, duration): def __init__(self, air, avId, comment, duration):
FSM.__init__(self, 'banFSM-%s' % avId) FSM.__init__(self, 'banFSM-%s' % avId)
self.air = air self.air = air
self.invokerId = invokerId
self.avId = avId self.avId = avId
# Needed variables for the actual banning.
self.comment = comment self.comment = comment
self.duration = duration self.duration = duration
self.DISLid = None self.DISLid = None
@ -21,19 +23,21 @@ class BanFSM(FSM):
self.avName = None self.avName = None
def performBan(self, bannedUntil): def performBan(self, bannedUntil):
executeHttpRequestAndLog('ban', username=self.accountId, enddate=bannedUntil, comment=self.comment) executeHttpRequest('accounts/ban/', Id=self.accountId, Release=bannedUntil,
Reason=self.comment)
def ejectPlayer(self): def ejectPlayer(self):
av = self.air.doId2do.get(self.avId) av = self.air.doId2do.get(self.avId)
if not av: if not av:
return return
# Send the client a 'CLIENTAGENT_EJECT' with the players name.
datagram = PyDatagram() datagram = PyDatagram()
datagram.addServerHeader( datagram.addServerHeader(
av.GetPuppetConnectionChannel(self.avId), av.GetPuppetConnectionChannel(self.avId),
self.air.ourChannel, CLIENTAGENT_EJECT) self.air.ourChannel, CLIENTAGENT_EJECT)
datagram.addUint16(103) datagram.addUint16(152)
datagram.addString(self.avName)
simbase.air.send(datagram) simbase.air.send(datagram)
def dbCallback(self, dclass, fields): def dbCallback(self, dclass, fields):
@ -42,12 +46,21 @@ class BanFSM(FSM):
self.accountId = fields.get('ACCOUNT_ID') self.accountId = fields.get('ACCOUNT_ID')
if self.accountId: if not self.accountId:
self.performBan(0 if self.duration < 0 else datetime.datetime.now() + (self.duration * 3600000)) return
date = datetime.date.today()
if simbase.config.GetBool('want-bans', True):
if self.duration == 0:
bannedUntil = "0000-00-00" # Terminated.
else:
bannedUntil = date + datetime.timedelta(days=self.duration)
self.duration = None
self.performBan(bannedUntil)
def getAvatarDetails(self): def getAvatarDetails(self):
av = self.air.doId2do.get(self.avId) av = self.air.doId2do.get(self.avId)
if not av: if not av:
return return
@ -55,14 +68,14 @@ class BanFSM(FSM):
self.avName = av.getName() self.avName = av.getName()
def log(self): def log(self):
simbase.air.writeServerEvent('ban', self.invokerId, self.accountId, self.comment) simbase.air.writeServerEvent('ban', self.accountId, self.comment)
def cleanup(self): def cleanup(self):
self.air = None self.air = None
self.avId = None self.avId = None
self.DISLid = None self.DISLid = None
self.avName = None self.avName = None
self.invokerId = None
self.accountId = None self.accountId = None
self.comment = None self.comment = None
self.duration = None self.duration = None
@ -70,7 +83,8 @@ class BanFSM(FSM):
def enterStart(self): def enterStart(self):
self.getAvatarDetails() self.getAvatarDetails()
self.air.dbInterface.queryObject(self.air.dbId, self.DISLid, self.dbCallback) self.air.dbInterface.queryObject(self.air.dbId, self.DISLid,
self.dbCallback)
self.ejectPlayer() self.ejectPlayer()
def exitStart(self): def exitStart(self):
@ -91,8 +105,8 @@ class BanManagerAI(DirectObject):
self.air = air self.air = air
self.banFSMs = {} self.banFSMs = {}
def ban(self, invokerId, avId, duration, comment): def ban(self, avId, duration, comment):
self.banFSMs[avId] = BanFSM(self.air, invokerId, avId, comment, duration) self.banFSMs[avId] = BanFSM(self.air, avId, comment, duration)
self.banFSMs[avId].request('Start') self.banFSMs[avId].request('Start')
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.banDone, [avId]) self.acceptOnce(self.air.getAvatarExitEvent(avId), self.banDone, [avId])
@ -103,22 +117,20 @@ class BanManagerAI(DirectObject):
@magicWord(category=CATEGORY_MODERATOR, types=[str]) @magicWord(category=CATEGORY_MODERATOR, types=[str])
def kick(reason): def kick(reason='No reason specified'):
""" """
Kick the target from the game server. Kick the target from the game server.
""" """
target = spellbook.getTarget() target = spellbook.getTarget()
invoker = spellbook.getInvoker() if target == spellbook.getInvoker():
if target == invoker:
return "You can't kick yourself!" return "You can't kick yourself!"
datagram = PyDatagram() datagram = PyDatagram()
datagram.addServerHeader( datagram.addServerHeader(
target.GetPuppetConnectionChannel(target.doId), target.GetPuppetConnectionChannel(target.doId),
simbase.air.ourChannel, CLIENTAGENT_EJECT) simbase.air.ourChannel, CLIENTAGENT_EJECT)
datagram.addUint16(104) datagram.addUint16(155)
datagram.addString('You were kicked by a moderator for the following reason: "%s"\n\nBehave next time!' % reason) datagram.addString('You were kicked by a moderator for the following reason: %s' % reason)
simbase.air.send(datagram) simbase.air.send(datagram)
simbase.air.writeServerEvent('kick', invoker.doId, target.doId, reason)
return "Kicked %s from the game server!" % target.getName() return "Kicked %s from the game server!" % target.getName()
@ -128,8 +140,9 @@ def ban(reason, duration):
Ban the target from the game server. Ban the target from the game server.
""" """
target = spellbook.getTarget() target = spellbook.getTarget()
invoker = spellbook.getInvoker() if target == spellbook.getInvoker():
if target == invoker:
return "You can't ban yourself!" return "You can't ban yourself!"
simbase.air.banManager.ban(invoker.doId, target.doId, duration, reason) if reason not in ('hacking', 'language', 'other'):
return "'%s' is not a valid reason." % reason
simbase.air.banManager.ban(target.doId, duration, reason)
return "Banned %s from the game server!" % target.getName() return "Banned %s from the game server!" % target.getName()

View file

@ -10,7 +10,7 @@ from toontown.rpc.ToontownRPCHandlerBase import *
from toontown.suit.SuitInvasionGlobals import INVASION_TYPE_NORMAL from toontown.suit.SuitInvasionGlobals import INVASION_TYPE_NORMAL
from toontown.toon import ToonDNA from toontown.toon import ToonDNA
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
from toontown.uberdog.ClientServicesManagerUD import executeHttpRequestAndLog from toontown.uberdog.ClientServicesManagerUD import executeHttpRequest
class ToontownRPCHandler(ToontownRPCHandlerBase): class ToontownRPCHandler(ToontownRPCHandlerBase):
@ -362,9 +362,16 @@ class ToontownRPCHandler(ToontownRPCHandlerBase):
On success: True On success: True
On failure: False On failure: False
""" """
if reason not in ('hacking', 'language', 'other'):
return False
self.air.writeServerEvent('ban', userId, duration, reason) self.air.writeServerEvent('ban', userId, duration, reason)
release = 0 if duration < 0 else datetime.date.now() + (duration * 3600000) if duration > 0:
executeHttpRequestAndLog('ban', username=userId, enddate=release, comment=reason) now = datetime.date.today()
release = str(now + datetime.timedelta(hours=duration))
else:
release = '0000-00-00' # Permanent ban.
executeHttpRequest('accounts/ban/', Id=userId, Release=release,
Reason=reason)
self.rpc_kickUser(userId, 152, reason) self.rpc_kickUser(userId, 152, reason)
return True return True