3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 03:33:10 +01:00

protocols: quitClient(...) -> quit(...), partClient(...) -> part(...)

This commit is contained in:
James Lu 2016-01-16 16:51:54 -08:00
parent 7e5284969d
commit 5324475d18
5 changed files with 20 additions and 20 deletions

View File

@ -70,9 +70,9 @@ internals](https://github.com/GLolol/PyLink/blob/0.4.0-dev/classes.py#L267-L272)
- **`numeric`**`(self, source, numeric, target, text)` - Sends a raw numeric `numeric` with `text` from the `source` server to `target`.
- **`partClient`**`(self, client, channel, reason=None)` - Sends a part from a PyLink client.
- **`part`**`(self, client, channel, reason=None)` - Sends a part from a PyLink client.
- **`quitClient`**`(self, source, reason)` - Quits a PyLink client.
- **`quit`**`(self, source, reason)` - Quits a PyLink client.
- **`sjoinServer`**`(self, server, channel, users, ts=None)` - Sends an SJOIN for a group of users to a channel. The sender should always be a Server ID (SID). TS is
optional, and defaults to the one we've stored in the channel state if not given. `users` is a list of `(prefix mode, UID)` pairs. Example uses:

View File

@ -43,7 +43,7 @@ def quit(irc, source, args):
if not utils.isManipulatableClient(irc, u):
irc.reply("Error: Cannot force quit a protected PyLink services client.")
return
irc.proto.quitClient(u, quitmsg)
irc.proto.quit(u, quitmsg)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}])
def joinclient(irc, source, args):
@ -118,7 +118,7 @@ def part(irc, source, args):
if not utils.isChannel(channel):
irc.reply("Error: Invalid channel name %r." % channel)
return
irc.proto.partClient(u, channel, reason)
irc.proto.part(u, channel, reason)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_PART', {'channels': clist, 'text': reason, 'parse_as': 'PART'}])
@utils.add_cmd

View File

@ -61,7 +61,7 @@ def die(sourceirc):
for irc in world.networkobjects.values():
for user in irc.users.copy():
if isRelayClient(irc, user):
irc.proto.quitClient(user, "Relay plugin unloaded.")
irc.proto.quit(user, "Relay plugin unloaded.")
for server, sobj in irc.servers.copy().items():
if hasattr(sobj, 'remote'):
irc.proto.squitServer(irc.sid, server, text="Relay plugin unloaded.")
@ -388,7 +388,7 @@ def removeChannel(irc, channel):
if irc is None:
return
if channel not in map(str.lower, irc.serverdata['channels']):
irc.proto.partClient(irc.pseudoclient.uid, channel, 'Channel delinked.')
irc.proto.part(irc.pseudoclient.uid, channel, 'Channel delinked.')
relay = getRelay((irc.name, channel))
if relay:
for user in irc.channels[channel].users.copy():
@ -399,12 +399,12 @@ def removeChannel(irc, channel):
if user == irc.pseudoclient.uid and channel in \
irc.serverdata['channels']:
continue
irc.proto.partClient(user, channel, 'Channel delinked.')
irc.proto.part(user, channel, 'Channel delinked.')
# Don't ever quit it either...
if user != irc.pseudoclient.uid and not irc.users[user].channels:
remoteuser = getOrigUser(irc, user)
del relayusers[remoteuser][irc.name]
irc.proto.quitClient(user, 'Left all shared channels.')
irc.proto.quit(user, 'Left all shared channels.')
def checkClaim(irc, channel, sender, chanobj=None):
"""
@ -530,9 +530,9 @@ def relayPart(irc, channel, user):
log.debug('(%s) relayPart: remoteuser for %s/%s found as %s', irc.name, user, irc.name, remoteuser)
if remotechan is None or remoteuser is None:
continue
remoteirc.proto.partClient(remoteuser, remotechan, 'Channel delinked.')
remoteirc.proto.part(remoteuser, remotechan, 'Channel delinked.')
if isRelayClient(remoteirc, remoteuser) and not remoteirc.users[remoteuser].channels:
remoteirc.proto.quitClient(remoteuser, 'Left all shared channels.')
remoteirc.proto.quit(remoteuser, 'Left all shared channels.')
del relayusers[(irc.name, user)][remoteirc.name]
@ -658,7 +658,7 @@ utils.add_hook(handle_join, 'JOIN')
def handle_quit(irc, numeric, command, args):
for netname, user in relayusers[(irc.name, numeric)].copy().items():
remoteirc = world.networkobjects[netname]
remoteirc.proto.quitClient(user, args['text'])
remoteirc.proto.quit(user, args['text'])
del relayusers[(irc.name, numeric)]
utils.add_hook(handle_quit, 'QUIT')
@ -703,9 +703,9 @@ def handle_part(irc, numeric, command, args):
remotechan = getRemoteChan(irc, remoteirc, channel)
if remotechan is None:
continue
remoteirc.proto.partClient(user, remotechan, text)
remoteirc.proto.part(user, remotechan, text)
if not remoteirc.users[user].channels:
remoteirc.proto.quitClient(user, 'Left all shared channels.')
remoteirc.proto.quit(user, 'Left all shared channels.')
del relayusers[(irc.name, numeric)][remoteirc.name]
utils.add_hook(handle_part, 'PART')
@ -855,11 +855,11 @@ def handle_kick(irc, source, command, args):
# If the target isn't on any channels, quit them.
if remoteirc != irc and (not remoteirc.users[real_target].channels) and not origuser:
del relayusers[(irc.name, target)][remoteirc.name]
remoteirc.proto.quitClient(real_target, 'Left all shared channels.')
remoteirc.proto.quit(real_target, 'Left all shared channels.')
if origuser and not irc.users[target].channels:
del relayusers[origuser][irc.name]
irc.proto.quitClient(target, 'Left all shared channels.')
irc.proto.quit(target, 'Left all shared channels.')
utils.add_hook(handle_kick, 'KICK')

View File

@ -71,7 +71,7 @@ class TS6BaseProtocol(Protocol):
self._send(numeric, 'NICK %s %s' % (newnick, int(time.time())))
self.irc.users[numeric].nick = newnick
def partClient(self, client, channel, reason=None):
def part(self, client, channel, reason=None):
"""Sends a part from a PyLink client."""
channel = utils.toLower(self.irc, channel)
if not self.irc.isInternalClient(client):
@ -83,7 +83,7 @@ class TS6BaseProtocol(Protocol):
self._send(client, msg)
self.handle_part(client, 'PART', [channel])
def quitClient(self, numeric, reason):
def quit(self, numeric, reason):
"""Quits a PyLink client."""
if self.irc.isInternalClient(numeric):
self._send(numeric, "QUIT :%s" % reason)

View File

@ -61,14 +61,14 @@ class CommonProtoTestCase(PluginTestCase):
def testPartClient(self):
u = self.u
self.proto.join(u, '#channel')
self.proto.partClient(u, '#channel')
self.proto.part(u, '#channel')
self.assertNotIn(u, self.irc.channels['#channel'].users)
def testQuitClient(self):
u = self.proto.spawnClient('testuser3', 'moo', 'hello.world').uid
self.proto.join(u, '#channel')
self.assertRaises(LookupError, self.proto.quitClient, '9PYZZZZZZ', 'quit reason')
self.proto.quitClient(u, 'quit reason')
self.assertRaises(LookupError, self.proto.quit, '9PYZZZZZZ', 'quit reason')
self.proto.quit(u, 'quit reason')
self.assertNotIn(u, self.irc.channels['#channel'].users)
self.assertNotIn(u, self.irc.users)
self.assertNotIn(u, self.irc.servers[self.irc.sid].users)