# Path: constants/serverPackets.py
# def loginFailed():
# def forceUpdate():
# def loginBanned():
# def loginLocked():
# def loginError():
# def needSupporter():
# def needVerification():
# def userID(uid):
# def silenceEndTime(seconds):
# def protocolVersion(version = 19):
# def mainMenuIcon(icon):
# def userSupporterGMT(supporter, GMT, tournamentStaff):
# def friendList(userID):
# def onlineUsers():
# def userLogout(userID):
# def userPanel(userID, force = False):
# def userStats(userID, force = False):
# def sendMessage(fro, to, message):
# def channelJoinSuccess(userID, chan):
# def channelInfo(chan):
# def channelInfoEnd():
# def channelKicked(chan):
# def userSilenced(userID):
# def addSpectator(userID):
# def removeSpectator(userID):
# def spectatorFrames(data):
# def noSongSpectator(userID):
# def fellowSpectatorJoined(userID):
# def fellowSpectatorLeft(userID):
# def createMatch(matchID):
# def updateMatch(matchID, censored = False):
# def matchStart(matchID):
# def disposeMatch(matchID):
# def matchJoinSuccess(matchID):
# def matchJoinFail():
# def changeMatchPassword(newPassword):
# def allPlayersLoaded():
# def playerSkipped(userID):
# def allPlayersSkipped():
# def matchFrames(slotID, data):
# def matchComplete():
# def playerFailed(slotID):
# def matchTransferHost():
# def matchAbort():
# def switchServer(address):
# def notification(message):
# def banchoRestart(msUntilReconnection):
# def rtx(message):
# 
# Path: constants/exceptions.py
# class periodicLoopException(Exception):
# 	pass
# 
# Path: events/logoutEvent.py
# def handle(userToken, _=None, deleteToken=True):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"
# 
# Path: objects/osuToken.py
# class token:
# 	def __init__(self, userID, token_ = None, ip ="", irc = False, timeOffset = 0, tournament = False):
# 	def enqueue(self, bytes_):
# 	def resetQueue(self):
# 	def joinChannel(self, channelObject):
# 	def partChannel(self, channelObject):
# 	def setLocation(self, latitude, longitude):
# 	def getLatitude(self):
# 	def getLongitude(self):
# 	def startSpectating(self, host):
# 	def stopSpectating(self):
# 	def updatePingTime(self):
# 	def joinMatch(self, matchID):
# 	def leaveMatch(self):
# 	def kick(self, message="You have been kicked from the server. Please login again.", reason="kick"):
# 	def silence(self, seconds = None, reason = "", author = 999):
# 	def spamProtection(self, increaseSpamRate = True):
# 	def isSilenced(self):
# 	def getSilenceSecondsLeft(self):
# 	def updateCachedStats(self):
# 	def checkRestricted(self):
# 	def checkBanned(self):
# 	def setRestricted(self):
# 	def resetRestricted(self):
# 	def joinStream(self, name):
# 	def leaveStream(self, name):
# 	def leaveAllStreams(self):
# 	def awayCheck(self, userID):
# 	def addMessageInBuffer(self, chan, message):
# 	def getMessagesBufferString(self):


import threading
import time
import redis
from common.ripple import userUtils
from common.log import logUtils as log
from common.sentry import sentry
from constants import serverPackets
from constants.exceptions import periodicLoopException
from events import logoutEvent
from objects import glob
from objects import osuToken
			if (not safe and value.username.lower() == who) or (safe and value.safeUsername == who):
				if ignoreIRC and value.irc:
					continue
				if _all:
					ret.append(value)
				else:
					return value

		# Return full list or None if not found
		if _all:
			return ret
		else:
			return None

	def deleteOldTokens(self, userID):
		"""
		Delete old userID's tokens if found

		:param userID: tokens associated to this user will be deleted
		:return:
		"""
		# Delete older tokens
		delete = []
		for key, value in list(self.tokens.items()):
			if value.userID == userID:
				# Delete this token from the dictionary
				#self.tokens[key].kick("You have logged in from somewhere else. You can't connect to Bancho/IRC from more than one device at the same time.", "kicked, multiple clients")
				delete.append(self.tokens[key])

		for i in delete:

# Path: constants/serverPackets.py
# def loginFailed():
# def forceUpdate():
# def loginBanned():
# def loginLocked():
# def loginError():
# def needSupporter():
# def needVerification():
# def userID(uid):
# def silenceEndTime(seconds):
# def protocolVersion(version = 19):
# def mainMenuIcon(icon):
# def userSupporterGMT(supporter, GMT, tournamentStaff):
# def friendList(userID):
# def onlineUsers():
# def userLogout(userID):
# def userPanel(userID, force = False):
# def userStats(userID, force = False):
# def sendMessage(fro, to, message):
# def channelJoinSuccess(userID, chan):
# def channelInfo(chan):
# def channelInfoEnd():
# def channelKicked(chan):
# def userSilenced(userID):
# def addSpectator(userID):
# def removeSpectator(userID):
# def spectatorFrames(data):
# def noSongSpectator(userID):
# def fellowSpectatorJoined(userID):
# def fellowSpectatorLeft(userID):
# def createMatch(matchID):
# def updateMatch(matchID, censored = False):
# def matchStart(matchID):
# def disposeMatch(matchID):
# def matchJoinSuccess(matchID):
# def matchJoinFail():
# def changeMatchPassword(newPassword):
# def allPlayersLoaded():
# def playerSkipped(userID):
# def allPlayersSkipped():
# def matchFrames(slotID, data):
# def matchComplete():
# def playerFailed(slotID):
# def matchTransferHost():
# def matchAbort():
# def switchServer(address):
# def notification(message):
# def banchoRestart(msUntilReconnection):
# def rtx(message):
# 
# Path: constants/exceptions.py
# class periodicLoopException(Exception):
# 	pass
# 
# Path: events/logoutEvent.py
# def handle(userToken, _=None, deleteToken=True):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"
# 
# Path: objects/osuToken.py
# class token:
# 	def __init__(self, userID, token_ = None, ip ="", irc = False, timeOffset = 0, tournament = False):
# 	def enqueue(self, bytes_):
# 	def resetQueue(self):
# 	def joinChannel(self, channelObject):
# 	def partChannel(self, channelObject):
# 	def setLocation(self, latitude, longitude):
# 	def getLatitude(self):
# 	def getLongitude(self):
# 	def startSpectating(self, host):
# 	def stopSpectating(self):
# 	def updatePingTime(self):
# 	def joinMatch(self, matchID):
# 	def leaveMatch(self):
# 	def kick(self, message="You have been kicked from the server. Please login again.", reason="kick"):
# 	def silence(self, seconds = None, reason = "", author = 999):
# 	def spamProtection(self, increaseSpamRate = True):
# 	def isSilenced(self):
# 	def getSilenceSecondsLeft(self):
# 	def updateCachedStats(self):
# 	def checkRestricted(self):
# 	def checkBanned(self):
# 	def setRestricted(self):
# 	def resetRestricted(self):
# 	def joinStream(self, name):
# 	def leaveStream(self, name):
# 	def leaveAllStreams(self):
# 	def awayCheck(self, userID):
# 	def addMessageInBuffer(self, chan, message):
# 	def getMessagesBufferString(self):


# Path: objects/tokenList.py
import threading
import time
import redis
from common.ripple import userUtils
from common.log import logUtils as log
from common.sentry import sentry
from constants import serverPackets
from constants.exceptions import periodicLoopException
from events import logoutEvent
from objects import glob
from objects import osuToken

			if (not safe and value.username.lower() == who) or (safe and value.safeUsername == who):
				if ignoreIRC and value.irc:
					continue
				if _all:
					ret.append(value)
				else:
					return value

		# Return full list or None if not found
		if _all:
			return ret
		else:
			return None

	def deleteOldTokens(self, userID):
		"""
		Delete old userID's tokens if found

		:param userID: tokens associated to this user will be deleted
		:return:
		"""
		# Delete older tokens
		delete = []
		for key, value in list(self.tokens.items()):
			if value.userID == userID:
				# Delete this token from the dictionary
				#self.tokens[key].kick("You have logged in from somewhere else. You can't connect to Bancho/IRC from more than one device at the same time.", "kicked, multiple clients")
				delete.append(self.tokens[key])

		for i in delete:

			logoutEvent.handle(i)