.BANCHO. Add spam protection, better silence handling

This commit is contained in:
Nyo
2016-06-07 22:46:31 +02:00
parent c8f9825e6b
commit ef35697772
7 changed files with 103 additions and 17 deletions

View File

@@ -62,3 +62,9 @@ class apiException(Exception):
class invalidArgumentsException(Exception):
pass
class messageTooLongWarnException(Exception):
pass
class messageTooLongException(Exception):
pass

View File

@@ -164,16 +164,10 @@ def silence(fro, chan, message):
if silenceTime > 604800:
return "Invalid silence time. Max silence time is 7 days."
# Calculate silence end time
endTime = int(time.time())+silenceTime
# Update silence end in db
userHelper.silence(targetUserID, endTime, reason)
# Send silence packet to target if he's connected
targetToken = glob.tokens.getTokenFromUsername(target)
if targetToken != None:
targetToken.enqueue(serverPackets.silenceEndTime(silenceTime))
targetToken.silence(silenceTime, reason)
# Log message
msg = "{} has been silenced for the following reason: {}".format(target, reason)

View File

@@ -171,6 +171,9 @@ def channelInfoEnd():
def channelKicked(chan):
return packetHelper.buildPacket(packetIDs.server_channelKicked, [[chan, dataTypes.string]])
def userSilenced(userID):
return packetHelper.buildPacket(packetIDs.server_userSilenced, [[userID, dataTypes.uInt32]])
""" Spectator packets """
def addSpectator(userID):