Пример #1
0
def userStats(userID):
	# Get userID's token from tokens list
	userToken = glob.tokens.getTokenFromUserID(userID)

	# Get stats from DB
	# TODO: Caching system
	rankedScore = 	userHelper.getUserRankedScore(userID, userToken.gameMode)
	accuracy = 		userHelper.getUserAccuracy(userID, userToken.gameMode)/100
	playcount = 	userHelper.getUserPlaycount(userID, userToken.gameMode)
	totalScore = 	userHelper.getUserTotalScore(userID, userToken.gameMode)
	gameRank = 		userHelper.getUserGameRank(userID, userToken.gameMode)
	pp = 0

	return packetHelper.buildPacket(packetIDs.server_userStats,
	[
		[userID, 				dataTypes.uInt32],
		[userToken.actionID, 	dataTypes.byte],
		[userToken.actionText, 	dataTypes.string],
		[userToken.actionMd5, 	dataTypes.string],
		[userToken.actionMods,	dataTypes.sInt32],
		[userToken.gameMode, 	dataTypes.byte],
		[0, 					dataTypes.sInt32],
		[rankedScore, 			dataTypes.uInt64],
		[accuracy, 				dataTypes.ffloat],
		[playcount, 			dataTypes.uInt32],
		[totalScore, 			dataTypes.uInt64],
		[gameRank,	 			dataTypes.uInt32],
		[pp, 					dataTypes.uInt16]
	])
Пример #2
0
def userSupporterGMT(supporter, GMT):
	result = 1
	if supporter == True:
		result += 4
	if GMT == True:
		result += 2
	return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.uInt32]])
Пример #3
0
def userStats(userID):
	# Get userID's token from tokens list
	userToken = glob.tokens.getTokenFromUserID(userID)

	# Get stats from DB
	# TODO: Caching system
	rankedScore = 	userHelper.getRankedScore(userID, userToken.gameMode)
	accuracy = 		userHelper.getAccuracy(userID, userToken.gameMode)/100
	playcount = 	userHelper.getPlaycount(userID, userToken.gameMode)
	totalScore = 	userHelper.getTotalScore(userID, userToken.gameMode)
	gameRank = 		userHelper.getGameRank(userID, userToken.gameMode)
	pp = 			int(userHelper.getPP(userID, userToken.gameMode))

	return packetHelper.buildPacket(packetIDs.server_userStats,
	[
		[userID, 				dataTypes.uInt32],
		[userToken.actionID, 	dataTypes.byte],
		[userToken.actionText, 	dataTypes.string],
		[userToken.actionMd5, 	dataTypes.string],
		[userToken.actionMods,	dataTypes.sInt32],
		[userToken.gameMode, 	dataTypes.byte],
		[0, 					dataTypes.sInt32],
		[rankedScore, 			dataTypes.uInt64],
		[accuracy, 				dataTypes.ffloat],
		[playcount, 			dataTypes.uInt32],
		[totalScore, 			dataTypes.uInt64],
		[gameRank,	 			dataTypes.uInt32],
		[pp, 					dataTypes.uInt16]
	])
Пример #4
0
def userSupporterGMT(supporter, GMT):
	result = 1
	if (supporter == True):
		result += 4
	if (GMT == True):
		result += 2
	return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.uInt32]])
Пример #5
0
def userPanel(userID):
    # Get user data
    userToken = glob.tokens.getTokenFromUserID(userID)
    username = userHelper.getUserUsername(userID)
    timezone = 24  # TODO: Timezone
    country = userToken.getCountry()
    gameRank = userHelper.getUserGameRank(userID, userToken.gameMode)
    latitude = userToken.getLatitude()
    longitude = userToken.getLongitude()

    # Get username color according to rank
    # Only admins and normal users are currently supported
    rank = userHelper.getUserRank(userID)
    if (username == "FokaBot"):
        userRank = userRanks.MOD
    elif (rank == 4):
        userRank = userRanks.ADMIN
    elif (rank == 3):
        userRank = userRank.MOD
    elif (rank == 2):
        userRank = userRanks.SUPPORTER
    else:
        userRank = userRanks.NORMAL

    return packetHelper.buildPacket(
        packetIDs.server_userPanel,
        [[userID, dataTypes.sInt32], [username, dataTypes.string],
         [timezone, dataTypes.byte], [country, dataTypes.byte],
         [userRank, dataTypes.byte], [longitude, dataTypes.ffloat],
         [latitude, dataTypes.ffloat], [gameRank, dataTypes.uInt32]])
Пример #6
0
def userPanel(userID):
	# Get user data
	userToken = glob.tokens.getTokenFromUserID(userID)
	username = userHelper.getUserUsername(userID)
	timezone = 24	# TODO: Timezone
	country = userToken.getCountry()
	gameRank = userHelper.getUserGameRank(userID, userToken.gameMode)
	latitude = userToken.getLatitude()
	longitude = userToken.getLongitude()

	# Get username color according to rank
	# Only admins and normal users are currently supported
	rank = userHelper.getUserRank(userID)
	if (username == "FokaBot"):
		usernameColor = usernameColors.mod
	elif (rank == 4):
		usernameColor = usernameColors.admin
	else:
		usernameColor = usernameColors.normal


	return packetHelper.buildPacket(packetIDs.server_userPanel,
	[
		[userID, dataTypes.sInt32],
		[username, dataTypes.string],
		[timezone, dataTypes.byte],
		[country, dataTypes.byte],
		[usernameColor, dataTypes.byte],
		[longitude, dataTypes.ffloat],
		[latitude, dataTypes.ffloat],
		[gameRank, dataTypes.uInt32]
	])
Пример #7
0
def matchStart(matchID):
	# Make sure the match exists
	if matchID not in glob.matches.matches:
		return None

	# Get match binary data and build packet
	match = glob.matches.matches[matchID]
	return packetHelper.buildPacket(packetIDs.server_matchStart, match.getMatchData())
Пример #8
0
def matchStart(matchID):
	# Make sure the match exists
	if matchID not in glob.matches.matches:
		return None

	# Get match binary data and build packet
	match = glob.matches.matches[matchID]
	return packetHelper.buildPacket(packetIDs.server_matchStart, match.getMatchData())
Пример #9
0
def matchJoinSuccess(matchID):
	# Make sure the match exists
	if matchID not in glob.matches.matches:
		return None

	# Get match binary data and build packet
	match = glob.matches.matches[matchID]
	data = packetHelper.buildPacket(packetIDs.server_matchJoinSuccess, match.getMatchData())
	return data
Пример #10
0
def updateMatch(matchID):
    # Make sure the match exists
    if (matchID not in glob.matches.matches):
        return None

    # Get match binary data and build packet
    match = glob.matches.matches[matchID]
    return packetHelper.buildPacket(packetIDs.server_updateMatch,
                                    match.getMatchData())
Пример #11
0
def matchJoinSuccess(matchID):
	# Make sure the match exists
	if matchID not in glob.matches.matches:
		return None

	# Get match binary data and build packet
	match = glob.matches.matches[matchID]
	data = packetHelper.buildPacket(packetIDs.server_matchJoinSuccess, match.getMatchData())
	return data
Пример #12
0
def onlineUsers():
	onlineUsersData = []

	users = glob.tokens.tokens;

	# Users number
	onlineUsersData.append([len(users), dataTypes.uInt16])

	# Add all users user IDs to onlineUsersData
	for key,value in users.items():
		onlineUsersData.append([value.userID, dataTypes.sInt32])

	return packetHelper.buildPacket(packetIDs.server_userPresenceBundle, onlineUsersData)
Пример #13
0
def onlineUsers():
	onlineUsersData = []

	users = glob.tokens.tokens

	# Users number
	onlineUsersData.append([len(users), dataTypes.uInt16])

	# Add all users user IDs to onlineUsersData
	for _,value in users.items():
		onlineUsersData.append([value.userID, dataTypes.sInt32])

	return packetHelper.buildPacket(packetIDs.server_userPresenceBundle, onlineUsersData)
Пример #14
0
def friendList(userID):
	friendsData = []

	# Get friend IDs from db
	friends = userHelper.getFriendList(userID)

	# Friends number
	friendsData.append([len(friends), dataTypes.uInt16])

	# Add all friend user IDs to friendsData
	for i in friends:
		friendsData.append([i, dataTypes.sInt32])

	return packetHelper.buildPacket(packetIDs.server_friendsList, friendsData)
Пример #15
0
def friendList(userID):
    friendsData = []

    # Get friend IDs from db
    friends = userHelper.getFriendList(userID)

    # Friends number
    friendsData.append([len(friends), dataTypes.uInt16])

    # Add all friend user IDs to friendsData
    for i in friends:
        friendsData.append([i, dataTypes.sInt32])

    return packetHelper.buildPacket(packetIDs.server_friendsList, friendsData)
Пример #16
0
def userPanel(userID):
	# Get user data
	userToken = glob.tokens.getTokenFromUserID(userID)
	username = userHelper.getUsername(userID)
	timezone = 24	# TODO: Timezone
	country = userToken.getCountry()
	gameRank = userHelper.getGameRank(userID, userToken.gameMode)
	latitude = userToken.getLatitude()
	longitude = userToken.getLongitude()

	# Get username color according to rank
	# Only admins and normal users are currently supported
	rank = userHelper.getRankPrivileges(userID)
	if username == "FokaBot":
		userRank = userRanks.MOD
	elif rank == 4:
		userRank = userRanks.ADMIN
	elif rank == 3:
		userRank = userRank.MOD
	elif rank == 2:
		userRank = userRanks.SUPPORTER
	else:
		userRank = userRanks.NORMAL


	return packetHelper.buildPacket(packetIDs.server_userPanel,
	[
		[userID, dataTypes.sInt32],
		[username, dataTypes.string],
		[timezone, dataTypes.byte],
		[country, dataTypes.byte],
		[userRank, dataTypes.byte],
		[longitude, dataTypes.ffloat],
		[latitude, dataTypes.ffloat],
		[gameRank, dataTypes.uInt32]
	])
Пример #17
0
def loginBanned():
	return packetHelper.buildPacket(packetIDs.server_userID, [[-3, dataTypes.sInt32]])
Пример #18
0
def noSongSpectator(userID):
	return packetHelper.buildPacket(packetIDs.server_spectatorCantSpectate, [[userID, dataTypes.sInt32]])
Пример #19
0
def jumpscare(message):
	return packetHelper.buildPacket(packetIDs.server_jumpscare, [[message, dataTypes.string]])
Пример #20
0
def channelInfoEnd():
	return packetHelper.buildPacket(packetIDs.server_channelInfoEnd, [[0, dataTypes.uInt32]])
Пример #21
0
def removeSpectator(userID):
	return packetHelper.buildPacket(packetIDs.server_spectatorLeft, [[userID, dataTypes.sInt32]])
Пример #22
0
def silenceEndTime(seconds):
	return packetHelper.buildPacket(packetIDs.server_silenceEnd, [[seconds, dataTypes.uInt32]])
Пример #23
0
def allPlayersSkipped():
    return packetHelper.buildPacket(packetIDs.server_matchSkip)
Пример #24
0
def jumpscare(message):
    return packetHelper.buildPacket(packetIDs.server_jumpscare,
                                    [[message, dataTypes.string]])
Пример #25
0
def banchoRestart(msUntilReconnection):
    return packetHelper.buildPacket(packetIDs.server_restart,
                                    [[msUntilReconnection, dataTypes.uInt32]])
Пример #26
0
def matchTransferHost():
    return packetHelper.buildPacket(packetIDs.server_matchTransferHost)
Пример #27
0
def notification(message):
    return packetHelper.buildPacket(packetIDs.server_notification,
                                    [[message, dataTypes.string]])
Пример #28
0
def playerFailed(slotID):
    return packetHelper.buildPacket(packetIDs.server_matchPlayerFailed,
                                    [[slotID, dataTypes.uInt32]])
Пример #29
0
def matchComplete():
    return packetHelper.buildPacket(packetIDs.server_matchComplete)
Пример #30
0
def matchFrames(slotID, data):
    return packetHelper.buildPacket(
        packetIDs.server_matchScoreUpdate,
        [[data[7:11], dataTypes.bbytes], [slotID, dataTypes.byte],
         [data[12:], dataTypes.bbytes]])
Пример #31
0
def packet80():
	return packetHelper.buildPacket(packetIDs.server_topBotnet)
Пример #32
0
def needSupporter():
    return packetHelper.buildPacket(packetIDs.server_userID,
                                    [[-6, dataTypes.sInt32]])
Пример #33
0
def needSupporter():
	return packetHelper.buildPacket(packetIDs.server_userID, [[-6, dataTypes.sInt32]])
Пример #34
0
def getAttention():
    return packetHelper.buildPacket(packetIDs.server_getAttention)
Пример #35
0
def mainMenuIcon(icon):
	return packetHelper.buildPacket(packetIDs.server_mainMenuIcon, [[icon, dataTypes.string]])
Пример #36
0
def packet80():
    return packetHelper.buildPacket(packetIDs.server_topBotnet)
Пример #37
0
def forceUpdate():
	return packetHelper.buildPacket(packetIDs.server_userID, [[-2, dataTypes.sInt32]])
Пример #38
0
def userID(uid):
    return packetHelper.buildPacket(packetIDs.server_userID,
                                    [[uid, dataTypes.sInt32]])
Пример #39
0
def addSpectator(userID):
	return packetHelper.buildPacket(packetIDs.server_spectatorJoined, [[userID, dataTypes.sInt32]])
Пример #40
0
def silenceEndTime(seconds):
    return packetHelper.buildPacket(packetIDs.server_silenceEnd,
                                    [[seconds, dataTypes.uInt32]])
Пример #41
0
def spectatorFrames(data):
	return packetHelper.buildPacket(packetIDs.server_spectateFrames, [[data, dataTypes.bbytes]])
Пример #42
0
def disposeMatch(matchID):
    return packetHelper.buildPacket(packetIDs.server_disposeMatch,
                                    [[matchID, dataTypes.uInt16]])
Пример #43
0
def notification(message):
	return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.string]])
Пример #44
0
def mainMenuIcon(icon):
    return packetHelper.buildPacket(packetIDs.server_mainMenuIcon,
                                    [[icon, dataTypes.string]])
Пример #45
0
def banchoRestart(msUntilReconnection):
	return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.uInt32]])
Пример #46
0
def loginError():
    return packetHelper.buildPacket(packetIDs.server_userID,
                                    [[-5, dataTypes.sInt32]])
Пример #47
0
def getAttention():
	return packetHelper.buildPacket(packetIDs.server_getAttention)
Пример #48
0
def userLogout(userID):
	return packetHelper.buildPacket(packetIDs.server_userLogout, [[userID, dataTypes.sInt32], [0, dataTypes.byte]])
Пример #49
0
def loginError():
	return packetHelper.buildPacket(packetIDs.server_userID, [[-5, dataTypes.sInt32]])
Пример #50
0
def allPlayersLoaded():
    return packetHelper.buildPacket(packetIDs.server_matchAllPlayersLoaded)
Пример #51
0
def userID(uid):
	return packetHelper.buildPacket(packetIDs.server_userID, [[uid, dataTypes.sInt32]])
Пример #52
0
def changeMatchPassword(newPassword):
    return packetHelper.buildPacket(packetIDs.server_matchChangePassword,
                                    [[newPassword, dataTypes.string]])
Пример #53
0
def protocolVersion(version = 19):
	return packetHelper.buildPacket(packetIDs.server_protocolVersion, [[version, dataTypes.uInt32]])
Пример #54
0
def channelInfo(chan):
	channel = glob.channels.channels[chan]
	return packetHelper.buildPacket(packetIDs.server_channelInfo, [[chan, dataTypes.string], [channel.description, dataTypes.string], [channel.getConnectedUsersCount(), dataTypes.uInt16]])
Пример #55
0
def loginBanned():
    return packetHelper.buildPacket(packetIDs.server_userID,
                                    [[-3, dataTypes.sInt32]])
Пример #56
0
def playerSkipped(userID):
    return packetHelper.buildPacket(packetIDs.server_matchPlayerSkipped,
                                    [[userID, dataTypes.sInt32]])
Пример #57
0
def channelJoinSuccess(userID, chan):
	return packetHelper.buildPacket(packetIDs.server_channelJoinSuccess, [[chan, dataTypes.string]])
Пример #58
0
def matchJoinFail():
    return packetHelper.buildPacket(packetIDs.server_matchJoinFail)
Пример #59
0
def protocolVersion(version=19):
    return packetHelper.buildPacket(packetIDs.server_protocolVersion,
                                    [[version, dataTypes.uInt32]])
Пример #60
0
def sendMessage(fro, to, message):
	return packetHelper.buildPacket(packetIDs.server_sendMessage, [[fro, dataTypes.string], [message, dataTypes.string], [to, dataTypes.string], [userHelper.getUserID(fro), dataTypes.sInt32]])