.BANCHO. Add pubsub handlers for username changes, bans, restrictions, silences, stats update, kicks and bancho settings reload.
This commit is contained in:
@@ -5,20 +5,19 @@ from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Get usertoken data
|
||||
userID = userToken.userID
|
||||
username = userToken.username
|
||||
|
||||
# Make sure we are not banned
|
||||
if userUtils.isBanned(userID):
|
||||
userToken.enqueue(serverPackets.loginBanned())
|
||||
return
|
||||
#if userUtils.isBanned(userID):
|
||||
# userToken.enqueue(serverPackets.loginBanned())
|
||||
# return
|
||||
|
||||
# Send restricted message if needed
|
||||
if userToken.restricted:
|
||||
userToken.checkRestricted(True)
|
||||
#if userToken.restricted:
|
||||
# userToken.checkRestricted(True)
|
||||
|
||||
# Change action packet
|
||||
packetData = clientPackets.userActionChange(packetData)
|
||||
@@ -34,8 +33,10 @@ if userToken.matchID != -1 and userToken.actionID != actions.MULTIPLAYING and us
|
||||
'''
|
||||
|
||||
# Update cached stats if our pp changed if we've just submitted a score or we've changed gameMode
|
||||
if (userToken.actionID == actions.PLAYING or userToken.actionID == actions.MULTIPLAYING) or (userToken.pp != userUtils.getPP(userID, userToken.gameMode)) or (userToken.gameMode != packetData["gameMode"]):
|
||||
# Always update game mode, or we'll cache stats from the wrong game mode if we've changed it
|
||||
#if (userToken.actionID == actions.PLAYING or userToken.actionID == actions.MULTIPLAYING) or (userToken.pp != userUtils.getPP(userID, userToken.gameMode)) or (userToken.gameMode != packetData["gameMode"]):
|
||||
|
||||
# Update cached stats if we've changed gamemode
|
||||
if userToken.gameMode != packetData["gameMode"]:
|
||||
userToken.gameMode = packetData["gameMode"]
|
||||
userToken.updateCachedStats()
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
import json
|
||||
|
||||
from common.log import logUtils as log
|
||||
from constants import serverPackets
|
||||
@@ -6,7 +7,7 @@ from helpers import chatHelper as chat
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, _=None):
|
||||
def handle(userToken, _=None, deleteToken=True):
|
||||
# get usertoken data
|
||||
userID = userToken.userID
|
||||
username = userToken.username
|
||||
@@ -38,7 +39,19 @@ def handle(userToken, _=None):
|
||||
glob.ircServer.forceDisconnection(userToken.username)
|
||||
|
||||
# Delete token
|
||||
glob.tokens.deleteToken(requestToken)
|
||||
if deleteToken:
|
||||
glob.tokens.deleteToken(requestToken)
|
||||
else:
|
||||
userToken.kicked = True
|
||||
|
||||
# Change username if needed
|
||||
newUsername = glob.redis.get("ripple:change_username_pending:{}".format(userID))
|
||||
if newUsername is not None:
|
||||
log.debug("Sending username change request for user {}".format(userID))
|
||||
glob.redis.publish("peppy:change_username", json.dumps({
|
||||
"userID": userID,
|
||||
"newUsername": newUsername.decode("utf-8")
|
||||
}))
|
||||
|
||||
# Console output
|
||||
log.info("{} has been disconnected. (logout)".format(username))
|
||||
|
Reference in New Issue
Block a user