.HIDE. General refactoring
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from common.log import logUtils as log
|
||||
from constants import serverPackets
|
||||
from objects import channel
|
||||
from objects import glob
|
||||
from helpers import chatHelper as chat
|
||||
|
@@ -376,7 +376,7 @@ class match:
|
||||
"""
|
||||
Add someone to users in match
|
||||
|
||||
:param userID: user id of the user
|
||||
:param user: user object of the user
|
||||
:return: True if join success, False if fail (room is full)
|
||||
"""
|
||||
# Make sure we're not in this match
|
||||
@@ -404,7 +404,7 @@ class match:
|
||||
"""
|
||||
Remove someone from users in match
|
||||
|
||||
:param userID: user if of the user
|
||||
:param user: user object of the user
|
||||
:return:
|
||||
"""
|
||||
# Make sure the user is in room
|
||||
|
@@ -1,7 +1,6 @@
|
||||
from objects import match
|
||||
from objects import glob
|
||||
from constants import serverPackets
|
||||
from common.log import logUtils as log
|
||||
|
||||
class matchList:
|
||||
def __init__(self):
|
||||
@@ -40,11 +39,11 @@ class matchList:
|
||||
return
|
||||
|
||||
# Remove match object and stream
|
||||
match = self.matches.pop(matchID)
|
||||
glob.streams.dispose(match.streamName)
|
||||
glob.streams.dispose(match.playingStreamName)
|
||||
glob.streams.remove(match.streamName)
|
||||
glob.streams.remove(match.playingStreamName)
|
||||
_match = self.matches.pop(matchID)
|
||||
glob.streams.dispose(_match.streamName)
|
||||
glob.streams.dispose(_match.playingStreamName)
|
||||
glob.streams.remove(_match.streamName)
|
||||
glob.streams.remove(_match.playingStreamName)
|
||||
|
||||
# Send match dispose packet to everyone in lobby
|
||||
glob.streams.broadcast("lobby", serverPackets.disposeMatch(matchID))
|
@@ -98,7 +98,7 @@ class token:
|
||||
"""
|
||||
Add bytes (packets) to queue
|
||||
|
||||
:param bytes: (packet) bytes to enqueue
|
||||
:param bytes_: (packet) bytes to enqueue
|
||||
"""
|
||||
|
||||
# Never enqueue for IRC clients or Foka
|
||||
@@ -144,7 +144,8 @@ class token:
|
||||
"""
|
||||
Set client location
|
||||
|
||||
:param location: [latitude, longitude]
|
||||
:param latitude: latitude
|
||||
:param longitude: longitude
|
||||
"""
|
||||
self.location = (latitude, longitude)
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import threading
|
||||
import time
|
||||
|
||||
import redis
|
||||
|
||||
from common.ripple import userUtils
|
||||
from common.log import logUtils as log
|
||||
from constants import serverPackets
|
||||
@@ -17,6 +19,7 @@ class tokenList:
|
||||
Add a token object to tokens list
|
||||
|
||||
:param userID: user id associated to that token
|
||||
:param ip: ip address of the client
|
||||
:param irc: if True, set this token as IRC client
|
||||
:param timeOffset: the time offset from UTC for this user. Default: 0.
|
||||
:param tournament: if True, flag this client as a tournement client. Default: True.
|
||||
@@ -54,13 +57,13 @@ class tokenList:
|
||||
# Get userID associated to that token
|
||||
return self.tokens[token].userID
|
||||
|
||||
def getTokenFromUserID(self, userID, ignoreIRC=False, all=False):
|
||||
def getTokenFromUserID(self, userID, ignoreIRC=False, _all=False):
|
||||
"""
|
||||
Get token from a user ID
|
||||
|
||||
:param userID: user ID to find
|
||||
:param ignoreIRC: if True, consider bancho clients only and skip IRC clients
|
||||
:param all: if True, return a list with all clients that match given username, otherwise return
|
||||
:param _all: if True, return a list with all clients that match given username, otherwise return
|
||||
only the first occurrence.
|
||||
:return: False if not found, token object if found
|
||||
"""
|
||||
@@ -70,18 +73,18 @@ class tokenList:
|
||||
if value.userID == userID:
|
||||
if ignoreIRC and value.irc:
|
||||
continue
|
||||
if all:
|
||||
if _all:
|
||||
ret.append(value)
|
||||
else:
|
||||
return value
|
||||
|
||||
# Return full list or None if not found
|
||||
if all:
|
||||
if _all:
|
||||
return ret
|
||||
else:
|
||||
return None
|
||||
|
||||
def getTokenFromUsername(self, username, ignoreIRC=False, safe=False, all=False):
|
||||
def getTokenFromUsername(self, username, ignoreIRC=False, safe=False, _all=False):
|
||||
"""
|
||||
Get an osuToken object from an username
|
||||
|
||||
@@ -89,7 +92,7 @@ class tokenList:
|
||||
:param ignoreIRC: if True, consider bancho clients only and skip IRC clients
|
||||
:param safe: if True, username is a safe username,
|
||||
compare it with token's safe username rather than normal username
|
||||
:param all: if True, return a list with all clients that match given username, otherwise return
|
||||
:param _all: if True, return a list with all clients that match given username, otherwise return
|
||||
only the first occurrence.
|
||||
:return: osuToken object or None
|
||||
"""
|
||||
@@ -102,13 +105,13 @@ class tokenList:
|
||||
if (not safe and value.username.lower() == who) or (safe and value.safeUsername == who):
|
||||
if ignoreIRC and value.irc:
|
||||
continue
|
||||
if all:
|
||||
if _all:
|
||||
ret.append(value)
|
||||
else:
|
||||
return value
|
||||
|
||||
# Return full list or None if not found
|
||||
if all:
|
||||
if _all:
|
||||
return ret
|
||||
else:
|
||||
return None
|
||||
@@ -215,7 +218,7 @@ class tokenList:
|
||||
try:
|
||||
# TODO: Make function or some redis meme
|
||||
glob.redis.eval("return redis.call('del', unpack(redis.call('keys', ARGV[1])))", 0, "peppy:sessions:*")
|
||||
except:
|
||||
except redis.RedisError:
|
||||
pass
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user