.BANCHO. Add !ban and !unban fokabot commands
This commit is contained in:
parent
c68fdf6d7c
commit
e1cdbfd6c9
|
@ -180,6 +180,43 @@ def removeSilence(fro, chan, message):
|
||||||
|
|
||||||
return "{}'s silence reset".format(target)
|
return "{}'s silence reset".format(target)
|
||||||
|
|
||||||
|
def ban(fro, chan, message):
|
||||||
|
# Get parameters
|
||||||
|
for i in message:
|
||||||
|
i = i.lower()
|
||||||
|
target = message[0].replace("_", " ")
|
||||||
|
|
||||||
|
# Make sure the user exists
|
||||||
|
targetUserID = userHelper.getID(target)
|
||||||
|
if targetUserID == False:
|
||||||
|
return "{}: user not found".format(target)
|
||||||
|
|
||||||
|
# Set allowed to 0
|
||||||
|
userHelper.setAllowed(targetUserID, 0)
|
||||||
|
|
||||||
|
# Send ban packet to the user if he's online
|
||||||
|
targetToken = glob.tokens.getTokenFromUsername(target)
|
||||||
|
if targetToken != None:
|
||||||
|
targetToken.enqueue(serverPackets.loginBanned())
|
||||||
|
|
||||||
|
return "RIP {}. You will not be missed.".format(target)
|
||||||
|
|
||||||
|
def unban(fro, chan, message):
|
||||||
|
# Get parameters
|
||||||
|
for i in message:
|
||||||
|
i = i.lower()
|
||||||
|
target = message[0].replace("_", " ")
|
||||||
|
|
||||||
|
# Make sure the user exists
|
||||||
|
targetUserID = userHelper.getID(target)
|
||||||
|
if targetUserID == False:
|
||||||
|
return "{}: user not found".format(target)
|
||||||
|
|
||||||
|
# Set allowed to 1
|
||||||
|
userHelper.setAllowed(targetUserID, 1)
|
||||||
|
|
||||||
|
return "Welcome back {}!".format(target)
|
||||||
|
|
||||||
def restartShutdown(restart):
|
def restartShutdown(restart):
|
||||||
"""Restart (if restart = True) or shutdown (if restart = False) pep.py safely"""
|
"""Restart (if restart = True) or shutdown (if restart = False) pep.py safely"""
|
||||||
msg = "We are performing some maintenance. Bancho will {} in 5 seconds. Thank you for your patience.".format("restart" if restart else "shutdown")
|
msg = "We are performing some maintenance. Bancho will {} in 5 seconds. Thank you for your patience.".format("restart" if restart else "shutdown")
|
||||||
|
@ -344,6 +381,16 @@ commands = [
|
||||||
"trigger": "!system status",
|
"trigger": "!system status",
|
||||||
"minRank": 3,
|
"minRank": 3,
|
||||||
"callback": systemStatus
|
"callback": systemStatus
|
||||||
|
}, {
|
||||||
|
"trigger": "!ban",
|
||||||
|
"syntax": "<target>",
|
||||||
|
"minRank": 3,
|
||||||
|
"callback": ban
|
||||||
|
}, {
|
||||||
|
"trigger": "!unban",
|
||||||
|
"syntax": "<target>",
|
||||||
|
"minRank": 3,
|
||||||
|
"callback": unban
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,10 @@ def forceUpdate():
|
||||||
return packetHelper.buildPacket(packetIDs.server_userID, [[-2, dataTypes.sInt32]])
|
return packetHelper.buildPacket(packetIDs.server_userID, [[-2, dataTypes.sInt32]])
|
||||||
|
|
||||||
def loginBanned():
|
def loginBanned():
|
||||||
return packetHelper.buildPacket(packetIDs.server_userID, [[-3, dataTypes.sInt32]])
|
packets = packetHelper.buildPacket(packetIDs.server_userID, [[-1, dataTypes.sInt32]])
|
||||||
|
packets += notification("You are banned. You can ask to get unbanned after 1 month since your ban by contacting support@ripple.moe")
|
||||||
|
return packets
|
||||||
|
#return packetHelper.buildPacket(packetIDs.server_userID, [[-3, dataTypes.sInt32]])
|
||||||
|
|
||||||
def loginError():
|
def loginError():
|
||||||
return packetHelper.buildPacket(packetIDs.server_userID, [[-5, dataTypes.sInt32]])
|
return packetHelper.buildPacket(packetIDs.server_userID, [[-5, dataTypes.sInt32]])
|
||||||
|
|
|
@ -261,8 +261,17 @@ def getPP(userID, gameMode):
|
||||||
Get userID's PP relative to gameMode
|
Get userID's PP relative to gameMode
|
||||||
|
|
||||||
userID -- user
|
userID -- user
|
||||||
return -- gameMode number
|
return -- PP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
modeForDB = gameModes.getGameModeForDB(gameMode)
|
modeForDB = gameModes.getGameModeForDB(gameMode)
|
||||||
return glob.db.fetch("SELECT pp_{} FROM users_stats WHERE id = ?".format(modeForDB), [userID])["pp_{}".format(modeForDB)]
|
return glob.db.fetch("SELECT pp_{} FROM users_stats WHERE id = ?".format(modeForDB), [userID])["pp_{}".format(modeForDB)]
|
||||||
|
|
||||||
|
def setAllowed(userID, allowed):
|
||||||
|
"""
|
||||||
|
Set userID's allowed status
|
||||||
|
|
||||||
|
userID -- user
|
||||||
|
allowed -- allowed status. 1: normal, 0: banned
|
||||||
|
"""
|
||||||
|
glob.db.execute("UPDATE users SET allowed = ? WHERE id = ?", [allowed, userID])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user