2016-04-19 17:40:59 +00:00
|
|
|
"""
|
|
|
|
Event called when someone parts a channel
|
|
|
|
"""
|
|
|
|
|
2016-05-17 21:40:34 +00:00
|
|
|
from helpers import consoleHelper
|
|
|
|
from constants import bcolors
|
2016-05-18 17:12:46 +00:00
|
|
|
from objects import glob
|
|
|
|
from constants import clientPackets
|
|
|
|
from constants import serverPackets
|
2016-06-04 10:44:54 +00:00
|
|
|
from helpers import logHelper as log
|
2016-07-14 10:37:07 +00:00
|
|
|
from helpers import chatHelper as chat
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
def handle(userToken, packetData):
|
2016-07-14 10:37:07 +00:00
|
|
|
# Channel join packet
|
2016-04-19 17:40:59 +00:00
|
|
|
packetData = clientPackets.channelPart(packetData)
|
2016-07-14 10:37:07 +00:00
|
|
|
chat.partChannel(token=userToken, channel=packetData["channel"])
|
2016-04-19 17:40:59 +00:00
|
|
|
|
2016-07-14 10:37:07 +00:00
|
|
|
"""def partChannel(userToken, channelName, kick = False):
|
2016-04-19 17:40:59 +00:00
|
|
|
# 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
|
2016-07-14 10:37:07 +00:00
|
|
|
log.info("{} parted channel {}".format(username, channelName))"""
|