pep.py/cantSpectateEvent.py

22 lines
635 B
Python
Raw Normal View History

2016-04-19 17:40:59 +00:00
import glob
import serverPackets
from helpers import consoleHelper
from constants import bcolors
2016-04-19 17:40:59 +00:00
import exceptions
def handle(userToken, packetData):
# get usertoken data
userID = userToken.userID
try:
# We don't have the beatmap, we can't spectate
target = userToken.spectating
targetToken = glob.tokens.getTokenFromUserID(target)
# Send the packet to host
targetToken.enqueue(serverPackets.noSongSpectator(userID))
except exceptions.tokenNotFoundException:
# Stop spectating if token not found
consoleHelper.printColored("[!] Spectator can't spectate: token not found", bcolors.RED)
userToken.stopSpectating()