.BANCHO. Log bans in RAP
This commit is contained in:
parent
3f9bad3d21
commit
cd363db76b
|
@ -172,7 +172,7 @@ def silence(fro, chan, message):
|
|||
targetToken.silence(silenceTime, reason, userID)
|
||||
else:
|
||||
# User offline, silence user only in db
|
||||
userHelper.silence(targetUserID, int(time.time())+silenceTime, reason, userID)
|
||||
userHelper.silence(targetUserID, silenceTime, reason, userID)
|
||||
|
||||
# Log message
|
||||
msg = "{} has been silenced for the following reason: {}".format(target, reason)
|
||||
|
@ -209,6 +209,7 @@ def ban(fro, chan, message):
|
|||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
if targetUserID == False:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
|
@ -220,6 +221,7 @@ def ban(fro, chan, message):
|
|||
if targetToken != None:
|
||||
targetToken.enqueue(serverPackets.loginBanned())
|
||||
|
||||
log.rap(userID, "has banned {}".format(target), True)
|
||||
return "RIP {}. You will not be missed.".format(target)
|
||||
|
||||
def unban(fro, chan, message):
|
||||
|
@ -230,12 +232,14 @@ def unban(fro, chan, message):
|
|||
|
||||
# Make sure the user exists
|
||||
targetUserID = userHelper.getID(target)
|
||||
userID = userHelper.getID(fro)
|
||||
if targetUserID == False:
|
||||
return "{}: user not found".format(target)
|
||||
|
||||
# Set allowed to 1
|
||||
userHelper.setAllowed(targetUserID, 1)
|
||||
|
||||
log.rap(userID, "has unbanned {}".format(target), True)
|
||||
return "Welcome back {}!".format(target)
|
||||
|
||||
def restartShutdown(restart):
|
||||
|
|
|
@ -100,22 +100,20 @@ def getSilenceEnd(userID):
|
|||
return glob.db.fetch("SELECT silence_end FROM users WHERE id = %s", [userID])["silence_end"]
|
||||
|
||||
|
||||
def silence(userID, silenceEndTime, silenceReason, author = 999):
|
||||
# TODO: user seconds insteaf od silenceEndTime
|
||||
def silence(userID, seconds, silenceReason, author = 999):
|
||||
"""
|
||||
Set userID's **ABSOLUTE** silence end UNIX time
|
||||
Remember to add time.time() to the silence length
|
||||
Silence someone
|
||||
|
||||
userID -- userID
|
||||
silenceEndtime -- UNIX time when the silence ends
|
||||
seconds -- silence length in seconds
|
||||
silenceReason -- Silence reason shown on website
|
||||
author -- userID of who silenced the user. Default: 999
|
||||
"""
|
||||
# db qurey
|
||||
silenceEndTime = int(time.time())+seconds
|
||||
glob.db.execute("UPDATE users SET silence_end = %s, silence_reason = %s WHERE id = %s", [silenceEndTime, silenceReason, userID])
|
||||
|
||||
# Loh
|
||||
seconds = silenceEndTime-int(time.time())
|
||||
targetUsername = getUsername(userID)
|
||||
# TODO: exists check im drunk rn i need to sleep (stampa piede ubriaco confirmed)
|
||||
if seconds > 0:
|
||||
|
|
|
@ -251,7 +251,7 @@ class token:
|
|||
author -- userID of who has silenced the target. Optional. Default: 999 (fokabot)
|
||||
"""
|
||||
# Silence user in db
|
||||
userHelper.silence(self.userID, int(time.time())+seconds, reason, author)
|
||||
userHelper.silence(self.userID, seconds, reason, author)
|
||||
|
||||
# Send silence packet to target
|
||||
self.enqueue(serverPackets.silenceEndTime(seconds))
|
||||
|
|
Loading…
Reference in New Issue
Block a user