.BANCHO. .FIX. Fix not parting channels when leaving multiplayer matches
This commit is contained in:
parent
a5fd8b0431
commit
59bcb351cf
|
@ -5,9 +5,6 @@ from helpers import userHelper
|
||||||
from objects import glob
|
from objects import glob
|
||||||
from constants import userRanks
|
from constants import userRanks
|
||||||
from constants import packetIDs
|
from constants import packetIDs
|
||||||
from constants import slotStatuses
|
|
||||||
from constants import matchModModes
|
|
||||||
import random
|
|
||||||
|
|
||||||
""" Login errors packets
|
""" Login errors packets
|
||||||
(userID packets derivates) """
|
(userID packets derivates) """
|
||||||
|
|
|
@ -1,38 +1,10 @@
|
||||||
"""
|
"""
|
||||||
Event called when someone parts a channel
|
Event called when someone parts a channel
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from helpers import consoleHelper
|
|
||||||
from constants import bcolors
|
|
||||||
from objects import glob
|
|
||||||
from constants import clientPackets
|
from constants import clientPackets
|
||||||
from constants import serverPackets
|
|
||||||
from helpers import logHelper as log
|
|
||||||
from helpers import chatHelper as chat
|
from helpers import chatHelper as chat
|
||||||
|
|
||||||
def handle(userToken, packetData):
|
def handle(userToken, packetData):
|
||||||
# Channel join packet
|
# Channel join packet
|
||||||
packetData = clientPackets.channelPart(packetData)
|
packetData = clientPackets.channelPart(packetData)
|
||||||
chat.partChannel(token=userToken, channel=packetData["channel"])
|
chat.partChannel(token=userToken, channel=packetData["channel"])
|
||||||
|
|
||||||
"""def partChannel(userToken, channelName, kick = False):
|
|
||||||
# Get usertoken data
|
|
||||||
username = userToken.username
|
|
||||||
userID = userToken.userID
|
|
||||||
|
|
||||||
# Remove us from joined users and joined channels
|
|
||||||
if channelName in glob.channels.channels:
|
|
||||||
# Check that user is in channel
|
|
||||||
if channelName in userToken.joinedChannels:
|
|
||||||
userToken.partChannel(channelName)
|
|
||||||
|
|
||||||
# Check if user is in channel
|
|
||||||
if userID in glob.channels.channels[channelName].connectedUsers:
|
|
||||||
glob.channels.channels[channelName].userPart(userID)
|
|
||||||
|
|
||||||
# Force close tab if needed
|
|
||||||
if kick == True:
|
|
||||||
userToken.enqueue(serverPackets.channelKicked(channelName))
|
|
||||||
|
|
||||||
# Console output
|
|
||||||
log.info("{} parted channel {}".format(username, channelName))"""
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from objects import glob
|
from objects import glob
|
||||||
from helpers import chatHelper as chat
|
from helpers import chatHelper as chat
|
||||||
from constants import serverPackets
|
|
||||||
|
|
||||||
def handle(userToken, _):
|
def handle(userToken, _):
|
||||||
# get data from usertoken
|
# get data from usertoken
|
||||||
|
@ -24,7 +23,7 @@ def handle(userToken, _):
|
||||||
match.userLeft(userID)
|
match.userLeft(userID)
|
||||||
|
|
||||||
# Part #multiplayer channel
|
# Part #multiplayer channel
|
||||||
chat.partChannel(token=userToken, channel="#multi_{}".format(matchID))
|
#chat.partChannel(token=userToken, channel="#multi_{}".format(matchID), kick=True)
|
||||||
|
|
||||||
# Set usertoken match to -1
|
# Set usertoken match to -1
|
||||||
userToken.partMatch()
|
userToken.partMatch()
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import gzip
|
import gzip
|
||||||
import time
|
|
||||||
from helpers import generalFunctions
|
|
||||||
from helpers import requestHelper
|
from helpers import requestHelper
|
||||||
from objects import glob
|
from objects import glob
|
||||||
from helpers import consoleHelper
|
|
||||||
from constants import bcolors
|
|
||||||
from constants import exceptions
|
from constants import exceptions
|
||||||
from constants import packetIDs
|
from constants import packetIDs
|
||||||
from helpers import packetHelper
|
from helpers import packetHelper
|
||||||
|
@ -117,19 +113,25 @@ class handler(SentryMixin, requestHelper.asyncRequestHandler):
|
||||||
eventHandler = {
|
eventHandler = {
|
||||||
# TODO: Rename packets and events
|
# TODO: Rename packets and events
|
||||||
# TODO: Host check for multi
|
# TODO: Host check for multi
|
||||||
|
packetIDs.client_changeAction: handleEvent(changeActionEvent),
|
||||||
|
packetIDs.client_logout: handleEvent(logoutEvent),
|
||||||
|
packetIDs.client_friendAdd: handleEvent(friendAddEvent),
|
||||||
|
packetIDs.client_friendRemove: handleEvent(friendRemoveEvent),
|
||||||
|
packetIDs.client_userStatsRequest: handleEvent(userStatsRequestEvent),
|
||||||
|
packetIDs.client_requestStatusUpdate: handleEvent(requestStatusUpdateEvent),
|
||||||
|
packetIDs.client_userPanelRequest: handleEvent(userPanelRequestEvent),
|
||||||
|
|
||||||
|
packetIDs.client_channelJoin: handleEvent(channelJoinEvent),
|
||||||
|
packetIDs.client_channelPart: handleEvent(channelPartEvent),
|
||||||
packetIDs.client_sendPublicMessage: handleEvent(sendPublicMessageEvent),
|
packetIDs.client_sendPublicMessage: handleEvent(sendPublicMessageEvent),
|
||||||
packetIDs.client_sendPrivateMessage: handleEvent(sendPrivateMessageEvent),
|
packetIDs.client_sendPrivateMessage: handleEvent(sendPrivateMessageEvent),
|
||||||
packetIDs.client_setAwayMessage: handleEvent(setAwayMessageEvent),
|
packetIDs.client_setAwayMessage: handleEvent(setAwayMessageEvent),
|
||||||
packetIDs.client_channelJoin: handleEvent(channelJoinEvent),
|
|
||||||
packetIDs.client_channelPart: handleEvent(channelPartEvent),
|
|
||||||
packetIDs.client_changeAction: handleEvent(changeActionEvent),
|
|
||||||
packetIDs.client_startSpectating: handleEvent(startSpectatingEvent),
|
packetIDs.client_startSpectating: handleEvent(startSpectatingEvent),
|
||||||
packetIDs.client_stopSpectating: handleEvent(stopSpectatingEvent),
|
packetIDs.client_stopSpectating: handleEvent(stopSpectatingEvent),
|
||||||
packetIDs.client_cantSpectate: handleEvent(cantSpectateEvent),
|
packetIDs.client_cantSpectate: handleEvent(cantSpectateEvent),
|
||||||
packetIDs.client_spectateFrames: handleEvent(spectateFramesEvent),
|
packetIDs.client_spectateFrames: handleEvent(spectateFramesEvent),
|
||||||
packetIDs.client_friendAdd: handleEvent(friendAddEvent),
|
|
||||||
packetIDs.client_friendRemove: handleEvent(friendRemoveEvent),
|
|
||||||
packetIDs.client_logout: handleEvent(logoutEvent),
|
|
||||||
packetIDs.client_joinLobby: handleEvent(joinLobbyEvent),
|
packetIDs.client_joinLobby: handleEvent(joinLobbyEvent),
|
||||||
packetIDs.client_partLobby: handleEvent(partLobbyEvent),
|
packetIDs.client_partLobby: handleEvent(partLobbyEvent),
|
||||||
packetIDs.client_createMatch: handleEvent(createMatchEvent),
|
packetIDs.client_createMatch: handleEvent(createMatchEvent),
|
||||||
|
@ -151,11 +153,8 @@ class handler(SentryMixin, requestHelper.asyncRequestHandler):
|
||||||
packetIDs.client_matchHasBeatmap: handleEvent(matchHasBeatmapEvent),
|
packetIDs.client_matchHasBeatmap: handleEvent(matchHasBeatmapEvent),
|
||||||
packetIDs.client_matchTransferHost: handleEvent(matchTransferHostEvent),
|
packetIDs.client_matchTransferHost: handleEvent(matchTransferHostEvent),
|
||||||
packetIDs.client_matchFailed: handleEvent(matchFailedEvent),
|
packetIDs.client_matchFailed: handleEvent(matchFailedEvent),
|
||||||
packetIDs.client_invite: handleEvent(matchInviteEvent),
|
|
||||||
packetIDs.client_matchChangeTeam: handleEvent(matchChangeTeamEvent),
|
packetIDs.client_matchChangeTeam: handleEvent(matchChangeTeamEvent),
|
||||||
packetIDs.client_userStatsRequest: handleEvent(userStatsRequestEvent),
|
packetIDs.client_invite: handleEvent(matchInviteEvent),
|
||||||
packetIDs.client_requestStatusUpdate: handleEvent(requestStatusUpdateEvent),
|
|
||||||
packetIDs.client_userPanelRequest: handleEvent(userPanelRequestEvent),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Packets processed if in restricted mode.
|
# Packets processed if in restricted mode.
|
||||||
|
|
|
@ -129,14 +129,14 @@ def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = Fal
|
||||||
# Force close tab if needed
|
# Force close tab if needed
|
||||||
# NOTE: Maybe always needed, will check later
|
# NOTE: Maybe always needed, will check later
|
||||||
if kick == True:
|
if kick == True:
|
||||||
token.enqueue(serverPackets.channelKicked(channelObject.clientName))
|
token.enqueue(serverPackets.channelKicked(channelClient))
|
||||||
|
|
||||||
# IRC part
|
# IRC part
|
||||||
if glob.irc == True and toIRC == True:
|
if glob.irc == True and toIRC == True:
|
||||||
glob.ircServer.banchoPartChannel(username, channel)
|
glob.ircServer.banchoPartChannel(username, channel)
|
||||||
|
|
||||||
# Console output
|
# Console output
|
||||||
log.info("{} parted channel {}".format(username, channel))
|
log.info("{} parted channel {} ({})".format(username, channel, channelClient))
|
||||||
|
|
||||||
# Return IRC code
|
# Return IRC code
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import os
|
|
||||||
|
|
||||||
class chatFilters:
|
class chatFilters:
|
||||||
def __init__(self, fileName="filters.txt"):
|
def __init__(self, fileName="filters.txt"):
|
||||||
self.filters = {}
|
self.filters = {}
|
||||||
|
@ -9,9 +7,8 @@ class chatFilters:
|
||||||
# Reset chat filters
|
# Reset chat filters
|
||||||
self.filters = {}
|
self.filters = {}
|
||||||
|
|
||||||
# Open filters.txt
|
# Open filters file
|
||||||
#with open(os.path.dirname(os.path.realpath(__file__)) + "/../"+fileName+".txt", "r") as f:
|
with open(fileName, "r") as f:
|
||||||
with open("filters.txt", "r") as f:
|
|
||||||
# Read all lines
|
# Read all lines
|
||||||
data = f.readlines()
|
data = f.readlines()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user