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