3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 19:52:53 +01:00

Merge handle_part into IRCS2SProtocol (#454)

This commit is contained in:
James Lu 2017-06-29 21:56:56 -07:00
parent 58a4215690
commit d01e797219
3 changed files with 22 additions and 45 deletions

View File

@ -327,6 +327,28 @@ class IRCS2SProtocol(IRCCommonProtocol):
self._remove_client(numeric)
return {'text': args[0]}
def handle_part(self, source, command, args):
"""Handles incoming PART commands."""
channels = self.toLower(args[0]).split(',')
for channel in channels:
self.channels[channel].removeuser(source)
try:
self.users[source].channels.discard(channel)
except KeyError:
log.debug("(%s) handle_part: KeyError trying to remove %r from %r's channel list?", self.name, channel, source)
try:
reason = args[1]
except IndexError:
reason = ''
# Clear empty non-permanent channels.
if not (self.channels[channel].users or ((self.cmodes.get('permanent'), None) in self.channels[channel].modes)):
del self.channels[channel]
return {'channels': channels, 'text': reason}
def handle_time(self, numeric, command, args):
"""Handles incoming /TIME requests."""
return {'target': args[0]}

View File

@ -1144,32 +1144,6 @@ class P10Protocol(IRCS2SProtocol):
# OPMODE is like SAMODE on other IRCds, and it follows the same modesetting syntax.
handle_opmode = handle_mode
def handle_part(self, source, command, args):
"""Handles user parts."""
# <- ABAAA L #test,#test2
# <- ABAAA L #test :test
channels = self.toLower(args[0]).split(',')
for channel in channels:
# We should only get PART commands for channels that exist, right??
self.channels[channel].removeuser(source)
try:
self.users[source].channels.discard(channel)
except KeyError:
log.debug("(%s) handle_part: KeyError trying to remove %r from %r's channel list?",
self.name, channel, source)
try:
reason = args[1]
except IndexError:
reason = ''
# Clear empty non-permanent channels.
if not self.channels[channel].users:
del self.channels[channel]
return {'channels': channels, 'text': reason}
def handle_kick(self, source, command, args):
"""Handles incoming KICKs."""
# <- ABAAA K #TEST AyAAA :PyLink-devel

View File

@ -353,25 +353,6 @@ class TS6BaseProtocol(IRCS2SProtocol):
return {'channel': channel, 'setter': numeric, 'text': topic,
'oldtopic': oldtopic}
def handle_part(self, source, command, args):
"""Handles incoming PART commands."""
channels = self.toLower(args[0]).split(',')
for channel in channels:
# We should only get PART commands for channels that exist, right??
self.channels[channel].removeuser(source)
try:
self.users[source].channels.discard(channel)
except KeyError:
log.debug("(%s) handle_part: KeyError trying to remove %r from %r's channel list?", self.name, channel, source)
try:
reason = args[1]
except IndexError:
reason = ''
# Clear empty non-permanent channels.
if not (self.channels[channel].users or ((self.cmodes.get('permanent'), None) in self.channels[channel].modes)):
del self.channels[channel]
return {'channels': channels, 'text': reason}
def handle_svsnick(self, source, command, args):
"""Handles SVSNICK (forced nickname change attempts)."""
# InspIRCd: