pep.py/events/startSpectatingEvent.py

22 lines
651 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 clientPackets
from constants import exceptions
2016-10-02 20:48:14 +00:00
from objects import glob
2016-04-19 17:40:59 +00:00
def handle(userToken, packetData):
try:
# Start spectating packet
packetData = clientPackets.startSpectating(packetData)
# Get host token
targetToken = glob.tokens.getTokenFromUserID(packetData["userID"])
2016-09-02 15:45:10 +00:00
if targetToken is None:
2016-04-19 17:40:59 +00:00
raise exceptions.tokenNotFoundException
# Start spectating new user
userToken.startSpectating(targetToken)
2016-04-19 17:40:59 +00:00
except exceptions.tokenNotFoundException:
# Stop spectating if token not found
log.warning("Spectator start: token not found")
2016-04-19 17:40:59 +00:00
userToken.stopSpectating()