pep.py/events/cantSpectateEvent.py

19 lines
613 B
Python
Raw Normal View History

2016-10-02 20:48:14 +00:00
from common.log import logUtils as log
2016-05-18 17:12:46 +00:00
from constants import exceptions
2016-10-02 20:48:14 +00:00
from constants import serverPackets
from objects import glob
2016-04-19 17:40:59 +00:00
2016-09-02 15:45:10 +00:00
def handle(userToken, _):
2016-04-19 17:40:59 +00:00
try:
# We don't have the beatmap, we can't spectate
if userToken.spectating not in glob.tokens.tokens:
2016-10-07 11:44:00 +00:00
raise exceptions.tokenNotFoundException()
2016-04-19 17:40:59 +00:00
# Send the packet to host
glob.tokens.tokens[userToken.spectating].enqueue(serverPackets.noSongSpectator(userToken.userID))
2016-04-19 17:40:59 +00:00
except exceptions.tokenNotFoundException:
# Stop spectating if token not found
log.warning("Spectator can't spectate: token not found")
2016-04-19 17:40:59 +00:00
userToken.stopSpectating()