# Path: constants/clientPackets.py
# def userActionChange(stream):
# def userStatsRequest(stream):
# def userPanelRequest(stream):
# def sendPublicMessage(stream):
# def sendPrivateMessage(stream):
# def setAwayMessage(stream):
# def channelJoin(stream):
# def channelPart(stream):
# def addRemoveFriend(stream):
# def startSpectating(stream):
# def matchSettings(stream):
# def createMatch(stream):
# def changeMatchSettings(stream):
# def changeSlot(stream):
# def joinMatch(stream):
# def changeMods(stream):
# def lockSlot(stream):
# def transferHost(stream):
# def matchInvite(stream):
# def matchFrames(stream):
# def tournamentMatchInfoRequest(stream):
# def tournamentJoinMatchChannel(stream):
# def tournamentLeaveMatchChannel(stream):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"
# 
# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):


from constants import clientPackets
from objects import glob
from helpers import chatHelper as chat

def handle(userToken, packetData):
	packetData = clientPackets.tournamentJoinMatchChannel(packetData)
	matchID = packetData["matchID"]
	if matchID not in glob.matches.matches or not userToken.tournament:
		return
	userToken.matchID = matchID

# Path: constants/clientPackets.py
# def userActionChange(stream):
# def userStatsRequest(stream):
# def userPanelRequest(stream):
# def sendPublicMessage(stream):
# def sendPrivateMessage(stream):
# def setAwayMessage(stream):
# def channelJoin(stream):
# def channelPart(stream):
# def addRemoveFriend(stream):
# def startSpectating(stream):
# def matchSettings(stream):
# def createMatch(stream):
# def changeMatchSettings(stream):
# def changeSlot(stream):
# def joinMatch(stream):
# def changeMods(stream):
# def lockSlot(stream):
# def transferHost(stream):
# def matchInvite(stream):
# def matchFrames(stream):
# def tournamentMatchInfoRequest(stream):
# def tournamentJoinMatchChannel(stream):
# def tournamentLeaveMatchChannel(stream):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"
# 
# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):


# Path: events/tournamentJoinMatchChannelEvent.py
from constants import clientPackets
from objects import glob
from helpers import chatHelper as chat


def handle(userToken, packetData):
	packetData = clientPackets.tournamentJoinMatchChannel(packetData)
	matchID = packetData["matchID"]
	if matchID not in glob.matches.matches or not userToken.tournament:
		return
	userToken.matchID = matchID

	chat.joinChannel(token=userToken, channel="#multi_{}".format(matchID), force=True)