Add submodules
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from objects import glob
|
||||
from constants import serverPackets
|
||||
from common.log import logUtils as log
|
||||
from constants import exceptions
|
||||
from helpers import logHelper as log
|
||||
from constants import serverPackets
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, _):
|
||||
# get usertoken data
|
||||
|
@@ -1,9 +1,10 @@
|
||||
from objects import glob
|
||||
from common.constants import actions
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from helpers import userHelper
|
||||
from helpers import logHelper as log
|
||||
from constants import actions
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Get usertoken data
|
||||
@@ -11,13 +12,13 @@ def handle(userToken, packetData):
|
||||
username = userToken.username
|
||||
|
||||
# Make sure we are not banned
|
||||
if userHelper.isBanned(userID):
|
||||
if userUtils.isBanned(userID):
|
||||
userToken.enqueue(serverPackets.loginBanned())
|
||||
return
|
||||
|
||||
# Send restricted message if needed
|
||||
if not userToken.restricted:
|
||||
if userHelper.isRestricted(userID):
|
||||
if userUtils.isRestricted(userID):
|
||||
userToken.setRestricted()
|
||||
|
||||
# Change action packet
|
||||
@@ -34,7 +35,7 @@ if userToken.matchID != -1 and userToken.actionID != actions.MULTIPLAYING and us
|
||||
'''
|
||||
|
||||
# Update cached stats if our pp changedm 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 != userHelper.getPP(userID, userToken.gameMode)) or (userToken.gameMode != packetData["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
|
||||
userToken.gameMode = packetData["gameMode"]
|
||||
userToken.updateCachedStats()
|
||||
|
@@ -1,7 +1,8 @@
|
||||
from objects import glob
|
||||
from common.constants import mods
|
||||
from constants import clientPackets
|
||||
from constants import matchModModes
|
||||
from constants import mods
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Get token data
|
||||
@@ -22,13 +23,13 @@ def handle(userToken, packetData):
|
||||
# Host can set global DT/HT
|
||||
if userID == match.hostUserID:
|
||||
# If host has selected DT/HT and Freemod is enabled, set DT/HT as match mod
|
||||
if (packetData["mods"] & mods.DoubleTime) > 0:
|
||||
match.changeMatchMods(mods.DoubleTime)
|
||||
if (packetData["mods"] & mods.DOUBLETIME) > 0:
|
||||
match.changeMatchMods(mods.DOUBLETIME)
|
||||
# Nightcore
|
||||
if (packetData["mods"] & mods.Nightcore) > 0:
|
||||
match.changeMatchMods(match.mods+mods.Nightcore)
|
||||
elif (packetData["mods"] & mods.HalfTime) > 0:
|
||||
match.changeMatchMods(mods.HalfTime)
|
||||
if (packetData["mods"] & mods.NIGHTCORE) > 0:
|
||||
match.changeMatchMods(match.mods + mods.NIGHTCORE)
|
||||
elif (packetData["mods"] & mods.HALFTIME) > 0:
|
||||
match.changeMatchMods(mods.HALFTIME)
|
||||
else:
|
||||
# No DT/HT, set global mods to 0 (we are in freemod mode)
|
||||
match.changeMatchMods(0)
|
||||
|
@@ -1,12 +1,14 @@
|
||||
from objects import glob
|
||||
import random
|
||||
|
||||
from common import generalUtils
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from constants import matchModModes
|
||||
import random
|
||||
from constants import matchTeamTypes
|
||||
from constants import matchTeams
|
||||
from constants import slotStatuses
|
||||
from helpers import logHelper as log
|
||||
from helpers import generalFunctions
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Read new settings
|
||||
@@ -59,7 +61,7 @@ def handle(userToken, packetData):
|
||||
# Update match settings
|
||||
match.inProgress = packetData["inProgress"]
|
||||
if packetData["matchPassword"] != "":
|
||||
match.matchPassword = generalFunctions.stringMd5(packetData["matchPassword"])
|
||||
match.matchPassword = generalUtils.stringMd5(packetData["matchPassword"])
|
||||
else:
|
||||
match.matchPassword = ""
|
||||
match.beatmapName = packetData["beatmapName"]
|
||||
|
@@ -1,9 +1,10 @@
|
||||
from constants import serverPackets
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from objects import glob
|
||||
from events import joinMatchEvent
|
||||
from constants import exceptions
|
||||
from helpers import logHelper as log
|
||||
from constants import serverPackets
|
||||
from events import joinMatchEvent
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
try:
|
||||
|
@@ -1,11 +1,12 @@
|
||||
from helpers import userHelper
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import clientPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Friend add packet
|
||||
packetData = clientPackets.addRemoveFriend(packetData)
|
||||
userHelper.addFriend(userToken.userID, packetData["friendID"])
|
||||
userUtils.addFriend(userToken.userID, packetData["friendID"])
|
||||
|
||||
# Console output
|
||||
log.info("{} have added {} to their friends".format(userToken.username, str(packetData["friendID"])))
|
||||
|
@@ -1,11 +1,12 @@
|
||||
from helpers import userHelper
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import clientPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Friend remove packet
|
||||
packetData = clientPackets.addRemoveFriend(packetData)
|
||||
userHelper.removeFriend(userToken.userID, packetData["friendID"])
|
||||
userUtils.removeFriend(userToken.userID, packetData["friendID"])
|
||||
|
||||
# Console output
|
||||
log.info("{} have removed {} from their friends".format(userToken.username, str(packetData["friendID"])))
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from common.log import logUtils as log
|
||||
from constants import serverPackets
|
||||
from objects import glob
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, _):
|
||||
# Get userToken data
|
||||
|
@@ -1,10 +1,11 @@
|
||||
from common import generalUtils
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from objects import glob
|
||||
from constants import exceptions
|
||||
from helpers import logHelper as log
|
||||
from constants import serverPackets
|
||||
from helpers import chatHelper as chat
|
||||
from helpers import generalFunctions
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# read packet data
|
||||
@@ -34,7 +35,7 @@ def joinMatch(userToken, matchID, password, isPasswordHashed = False):
|
||||
|
||||
# Hash password if needed
|
||||
if isPasswordHashed == False and password != "":
|
||||
password = generalFunctions.stringMd5(password)
|
||||
password = generalUtils.stringMd5(password)
|
||||
|
||||
# Check password
|
||||
# TODO: Admins can enter every match
|
||||
|
@@ -1,15 +1,17 @@
|
||||
from helpers import userHelper
|
||||
from constants import serverPackets
|
||||
from constants import exceptions
|
||||
from objects import glob
|
||||
from helpers import locationHelper
|
||||
from helpers import countryHelper
|
||||
import sys
|
||||
import traceback
|
||||
from helpers import logHelper as log
|
||||
from helpers import chatHelper as chat
|
||||
from constants import privileges
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from common.constants import privileges
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import exceptions
|
||||
from constants import serverPackets
|
||||
from helpers import chatHelper as chat
|
||||
from helpers import countryHelper
|
||||
from helpers import locationHelper
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(tornadoRequest):
|
||||
# Data to return
|
||||
@@ -51,24 +53,24 @@ def handle(tornadoRequest):
|
||||
|
||||
# Try to get the ID from username
|
||||
username = str(loginData[0])
|
||||
userID = userHelper.getID(username)
|
||||
userID = userUtils.getID(username)
|
||||
|
||||
if not userID:
|
||||
# Invalid username
|
||||
raise exceptions.loginFailedException()
|
||||
if not userHelper.checkLogin(userID, loginData[1]):
|
||||
if not userUtils.checkLogin(userID, loginData[1]):
|
||||
# Invalid password
|
||||
raise exceptions.loginFailedException()
|
||||
|
||||
# Make sure we are not banned or locked
|
||||
priv = userHelper.getPrivileges(userID)
|
||||
if userHelper.isBanned(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||
priv = userUtils.getPrivileges(userID)
|
||||
if userUtils.isBanned(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||
raise exceptions.loginBannedException()
|
||||
if userHelper.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||
if userUtils.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
|
||||
raise exceptions.loginLockedException()
|
||||
|
||||
# 2FA check
|
||||
if userHelper.check2FA(userID, requestIP):
|
||||
if userUtils.check2FA(userID, requestIP):
|
||||
log.warning("Need 2FA check for user {}".format(loginData[0]))
|
||||
raise exceptions.need2FAException()
|
||||
|
||||
@@ -76,8 +78,8 @@ def handle(tornadoRequest):
|
||||
|
||||
# Verify this user (if pending activation)
|
||||
firstLogin = False
|
||||
if priv & privileges.USER_PENDING_VERIFICATION > 0 or userHelper.hasVerifiedHardware(userID) == False:
|
||||
if userHelper.verifyUser(userID, clientData):
|
||||
if priv & privileges.USER_PENDING_VERIFICATION > 0 or userUtils.hasVerifiedHardware(userID) == False:
|
||||
if userUtils.verifyUser(userID, clientData):
|
||||
# Valid account
|
||||
log.info("Account {} verified successfully!".format(userID))
|
||||
glob.verifiedCache[str(userID)] = 1
|
||||
@@ -90,7 +92,7 @@ def handle(tornadoRequest):
|
||||
|
||||
|
||||
# Save HWID in db for multiaccount detection
|
||||
hwAllowed = userHelper.logHardware(userID, clientData, firstLogin)
|
||||
hwAllowed = userUtils.logHardware(userID, clientData, firstLogin)
|
||||
|
||||
# This is false only if HWID is empty
|
||||
# if HWID is banned, we get restricted so there's no
|
||||
@@ -99,7 +101,7 @@ def handle(tornadoRequest):
|
||||
raise exceptions.haxException()
|
||||
|
||||
# Log user IP
|
||||
userHelper.logIP(userID, requestIP)
|
||||
userUtils.logIP(userID, requestIP)
|
||||
|
||||
# Delete old tokens for that user and generate a new one
|
||||
glob.tokens.deleteOldTokens(userID)
|
||||
@@ -111,7 +113,7 @@ def handle(tornadoRequest):
|
||||
|
||||
# Send message if donor expires soon
|
||||
if responseToken.privileges & privileges.USER_DONOR > 0:
|
||||
expireDate = userHelper.getDonorExpire(responseToken.userID)
|
||||
expireDate = userUtils.getDonorExpire(responseToken.userID)
|
||||
if expireDate-int(time.time()) <= 86400*3:
|
||||
expireDays = round((expireDate-int(time.time()))/86400)
|
||||
expireIn = "{} days".format(expireDays) if expireDays > 1 else "less than 24 hours"
|
||||
@@ -119,7 +121,7 @@ def handle(tornadoRequest):
|
||||
|
||||
|
||||
# Set silence end UNIX time in token
|
||||
responseToken.silenceEndTime = userHelper.getSilenceEnd(userID)
|
||||
responseToken.silenceEndTime = userUtils.getSilenceEnd(userID)
|
||||
|
||||
# Get only silence remaining seconds
|
||||
silenceSeconds = responseToken.getSilenceSecondsLeft()
|
||||
@@ -193,15 +195,15 @@ def handle(tornadoRequest):
|
||||
log.warning("Location skipped")
|
||||
location = [0,0]
|
||||
countryLetters = "XX"
|
||||
country = countryHelper.getCountryID(userHelper.getCountry(userID))
|
||||
country = countryHelper.getCountryID(userUtils.getCountry(userID))
|
||||
|
||||
# Set location and country
|
||||
responseToken.setLocation(location)
|
||||
responseToken.setCountry(country)
|
||||
|
||||
# Set country in db if user has no country (first bancho login)
|
||||
if userHelper.getCountry(userID) == "XX":
|
||||
userHelper.setCountry(userID, countryLetters)
|
||||
if userUtils.getCountry(userID) == "XX":
|
||||
userUtils.setCountry(userID, countryLetters)
|
||||
|
||||
# Send to everyone our userpanel if we are not restricted
|
||||
if not responseToken.restricted:
|
||||
|
@@ -1,8 +1,10 @@
|
||||
from objects import glob
|
||||
from constants import serverPackets
|
||||
import time
|
||||
from helpers import logHelper as log
|
||||
|
||||
from common.log import logUtils as log
|
||||
from constants import serverPackets
|
||||
from helpers import chatHelper as chat
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, _=None):
|
||||
# get usertoken data
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from objects import glob
|
||||
from helpers import logHelper as log
|
||||
from common.log import logUtils as log
|
||||
from helpers import chatHelper as chat
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, _):
|
||||
# Get usertoken data
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from constants import serverPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Update cache and send new stats
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# get token data
|
||||
|
@@ -1,10 +1,11 @@
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from constants import exceptions
|
||||
from objects import glob
|
||||
from helpers import userHelper
|
||||
from helpers import logHelper as log
|
||||
from constants import serverPackets
|
||||
from helpers import chatHelper as chat
|
||||
from objects import glob
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
try:
|
||||
@@ -50,7 +51,7 @@ def handle(userToken, packetData):
|
||||
c.enqueue(serverPackets.fellowSpectatorJoined(userID))
|
||||
|
||||
# Console output
|
||||
log.info("{} are spectating {}".format(username, userHelper.getUsername(packetData["userID"])))
|
||||
log.info("{} are spectating {}".format(username, userUtils.getUsername(packetData["userID"])))
|
||||
except exceptions.tokenNotFoundException:
|
||||
# Stop spectating if token not found
|
||||
log.warning("Spectator start: token not found")
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Read userIDs list
|
||||
|
@@ -1,6 +1,7 @@
|
||||
from common.log import logUtils as log
|
||||
from constants import clientPackets
|
||||
from constants import serverPackets
|
||||
from helpers import logHelper as log
|
||||
|
||||
|
||||
def handle(userToken, packetData):
|
||||
# Read userIDs list
|
||||
|
Reference in New Issue
Block a user