3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

ts6_common: consolidate kickClient and kickServer into kick

This commit is contained in:
James Lu 2016-01-16 16:56:40 -08:00
parent ee65ac60e1
commit 975ace3e04

View File

@ -41,29 +41,23 @@ class TS6BaseProtocol(Protocol):
replies.""" replies."""
self._send(source, '%s %s %s' % (numeric, target, text)) self._send(source, '%s %s %s' % (numeric, target, text))
def _sendKick(self, numeric, channel, target, reason=None): def kick(self, numeric, channel, target, reason=None):
"""Internal function to send kicks from a PyLink client/server.""" """Sends kicks from a PyLink client/server."""
if (not self.irc.isInternalClient(numeric)) and \
(not self.irc.isInternalServer(numeric)):
raise LookupError('No such PyLink client/server exists.')
channel = utils.toLower(self.irc, channel) channel = utils.toLower(self.irc, channel)
if not reason: if not reason:
reason = 'No reason given' reason = 'No reason given'
self._send(numeric, 'KICK %s %s :%s' % (channel, target, reason)) self._send(numeric, 'KICK %s %s :%s' % (channel, target, reason))
# We can pretend the target left by its own will; all we really care about # We can pretend the target left by its own will; all we really care about
# is that the target gets removed from the channel userlist, and calling # is that the target gets removed from the channel userlist, and calling
# handle_part() does that just fine. # handle_part() does that just fine.
self.handle_part(target, 'KICK', [channel]) self.handle_part(target, 'KICK', [channel])
def kickClient(self, numeric, channel, target, reason=None):
"""Sends a kick from a PyLink client."""
if not self.irc.isInternalClient(numeric):
raise LookupError('No such PyLink client exists.')
self._sendKick(numeric, channel, target, reason=reason)
def kickServer(self, numeric, channel, target, reason=None):
"""Sends a kick from a PyLink server."""
if not self.irc.isInternalServer(numeric):
raise LookupError('No such PyLink server exists.')
self._sendKick(numeric, channel, target, reason=reason)
def nick(self, numeric, newnick): def nick(self, numeric, newnick):
"""Changes the nick of a PyLink client.""" """Changes the nick of a PyLink client."""
if not self.irc.isInternalClient(numeric): if not self.irc.isInternalClient(numeric):