3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

protocols: rename joinClient(...) -> join(...)

This commit is contained in:
James Lu 2016-01-16 16:36:45 -08:00
parent ff6841c551
commit acdd7dbb78
10 changed files with 16 additions and 16 deletions

View File

@ -392,7 +392,7 @@ class Irc():
modes={("+o", None)}, modes={("+o", None)},
manipulatable=True) manipulatable=True)
for chan in self.serverdata['channels']: for chan in self.serverdata['channels']:
self.proto.joinClient(self.pseudoclient.uid, chan) self.proto.join(self.pseudoclient.uid, chan)
# PyLink internal hook called when spawnMain is called and the # PyLink internal hook called when spawnMain is called and the
# contents of Irc().pseudoclient change. # contents of Irc().pseudoclient change.
self.callHooks([self.sid, 'PYLINK_SPAWNMAIN', {'olduser': olduserobj}]) self.callHooks([self.sid, 'PYLINK_SPAWNMAIN', {'olduser': olduserobj}])
@ -670,7 +670,7 @@ class FakeProto(Protocol):
self.irc.users[uid] = user = IrcUser(nick, ts, uid) self.irc.users[uid] = user = IrcUser(nick, ts, uid)
return user return user
def joinClient(self, client, channel): def join(self, client, channel):
self.irc.channels[channel].users.add(client) self.irc.channels[channel].users.add(client)
self.irc.users[client].channels.add(channel) self.irc.users[client].channels.add(channel)

View File

@ -20,7 +20,7 @@ def handle_kick(irc, source, command, args):
kicked = args['target'] kicked = args['target']
channel = args['channel'] channel = args['channel']
if kicked == irc.pseudoclient.uid: if kicked == irc.pseudoclient.uid:
irc.proto.joinClient(irc.pseudoclient.uid, channel) irc.proto.join(irc.pseudoclient.uid, channel)
utils.add_hook(handle_kick, 'KICK') utils.add_hook(handle_kick, 'KICK')
def handle_commands(irc, source, command, args): def handle_commands(irc, source, command, args):

View File

@ -42,7 +42,7 @@ internals](https://github.com/GLolol/PyLink/blob/0.4.0-dev/classes.py#L267-L272)
- The `manipulatable` option toggles whether the client spawned should be considered protected. Currently, all this does is prevent commands from plugins like `bots` from modifying these clients, but future client protections (anti-kill flood, etc.) may also depend on this. - The `manipulatable` option toggles whether the client spawned should be considered protected. Currently, all this does is prevent commands from plugins like `bots` from modifying these clients, but future client protections (anti-kill flood, etc.) may also depend on this.
- The `server` option optionally takes a SID of any PyLink server, and spawns the client on the one given. It will default to the root PyLink server. - The `server` option optionally takes a SID of any PyLink server, and spawns the client on the one given. It will default to the root PyLink server.
- **`joinClient`**`(self, client, channel)` - Joins the given client UID given to a channel. - **`join`**`(self, client, channel)` - Joins the given client UID given to a channel.
- **`awayClient`**`(self, source, text)` - Sends an AWAY message from a PyLink client. `text` can be an empty string to unset AWAY status. - **`awayClient`**`(self, source, text)` - Sends an AWAY message from a PyLink client. `text` can be an empty string to unset AWAY status.

View File

@ -65,7 +65,7 @@ world.whois_handlers.append(relayWhoisHandler)
Plugins receive data from the underlying protocol module, and communicate back using outgoing [command functions](pmodule-spec.md) implemented by the protocol module. They should *never* send raw data directly back to IRC, because that wouldn't be portable across different IRCds. Plugins receive data from the underlying protocol module, and communicate back using outgoing [command functions](pmodule-spec.md) implemented by the protocol module. They should *never* send raw data directly back to IRC, because that wouldn't be portable across different IRCds.
These functions are usually called in this fashion: `irc.proto.abcdClient(arg1, arg2)`. For example, the command `irc.proto.joinClient('10XAAAAAB', '#bots')` would join a PyLink client with UID `10XAAAAAB` to channel `#bots`. These functions are usually called in this fashion: `irc.proto.abcdClient(arg1, arg2)`. For example, the command `irc.proto.join('10XAAAAAB', '#bots')` would join a PyLink client with UID `10XAAAAAB` to channel `#bots`.
For sending messages (e.g. replies to commands), simpler forms of: For sending messages (e.g. replies to commands), simpler forms of:

View File

@ -67,7 +67,7 @@ def joinclient(irc, source, args):
if not utils.isChannel(channel): if not utils.isChannel(channel):
irc.reply("Error: Invalid channel name %r." % channel) irc.reply("Error: Invalid channel name %r." % channel)
return return
irc.proto.joinClient(u, channel) irc.proto.join(u, channel)
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_JOIN', {'channel': channel, 'users': [u], irc.callHooks([u, 'PYLINK_BOTSPLUGIN_JOIN', {'channel': channel, 'users': [u],
'modes': irc.channels[channel].modes, 'modes': irc.channels[channel].modes,
'parse_as': 'JOIN'}]) 'parse_as': 'JOIN'}])

View File

@ -381,7 +381,7 @@ def initializeChannel(irc, channel):
log.debug('(%s) initializeChannel: joining our (%s) users: %s', irc.name, remotenet, irc.channels[channel].users) log.debug('(%s) initializeChannel: joining our (%s) users: %s', irc.name, remotenet, irc.channels[channel].users)
relayJoins(irc, channel, irc.channels[channel].users, irc.channels[channel].ts) relayJoins(irc, channel, irc.channels[channel].users, irc.channels[channel].ts)
if irc.pseudoclient.uid not in irc.channels[channel].users: if irc.pseudoclient.uid not in irc.channels[channel].users:
irc.proto.joinClient(irc.pseudoclient.uid, channel) irc.proto.join(irc.pseudoclient.uid, channel)
def removeChannel(irc, channel): def removeChannel(irc, channel):
"""Destroys a relay channel by parting all of its users.""" """Destroys a relay channel by parting all of its users."""
@ -516,7 +516,7 @@ def relayJoins(irc, channel, users, ts, burst=True):
remoteirc.proto.sjoinServer(rsid, remotechan, queued_users, ts=ts) remoteirc.proto.sjoinServer(rsid, remotechan, queued_users, ts=ts)
relayModes(irc, remoteirc, getRemoteSid(irc, remoteirc), channel, irc.channels[channel].modes) relayModes(irc, remoteirc, getRemoteSid(irc, remoteirc), channel, irc.channels[channel].modes)
else: else:
remoteirc.proto.joinClient(queued_users[0][1], remotechan) remoteirc.proto.join(queued_users[0][1], remotechan)
def relayPart(irc, channel, user): def relayPart(irc, channel, user):
for name, remoteirc in world.networkobjects.items(): for name, remoteirc in world.networkobjects.items():

View File

@ -62,7 +62,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
self._operUp(uid, opertype=opertype or 'IRC Operator') self._operUp(uid, opertype=opertype or 'IRC Operator')
return u return u
def joinClient(self, client, channel): def join(self, client, channel):
"""Joins a PyLink client to a channel.""" """Joins a PyLink client to a channel."""
# InspIRCd doesn't distinguish between burst joins and regular joins, # InspIRCd doesn't distinguish between burst joins and regular joins,
# so what we're actually doing here is sending FJOIN from the server, # so what we're actually doing here is sending FJOIN from the server,

View File

@ -56,7 +56,7 @@ class TS6Protocol(TS6BaseProtocol):
realhost=realhost)) realhost=realhost))
return u return u
def joinClient(self, client, channel): def join(self, client, channel):
"""Joins a PyLink client to a channel.""" """Joins a PyLink client to a channel."""
channel = utils.toLower(self.irc, channel) channel = utils.toLower(self.irc, channel)
# JOIN: # JOIN:

View File

@ -104,7 +104,7 @@ class UnrealProtocol(TS6BaseProtocol):
return u return u
def joinClient(self, client, channel): def join(self, client, channel):
"""Joins a PyLink client to a channel.""" """Joins a PyLink client to a channel."""
channel = utils.toLower(self.irc, channel) channel = utils.toLower(self.irc, channel)
if not self.irc.isInternalClient(client): if not self.irc.isInternalClient(client):

View File

@ -27,14 +27,14 @@ class PluginTestCase(unittest.TestCase):
class CommonProtoTestCase(PluginTestCase): class CommonProtoTestCase(PluginTestCase):
def testJoinClient(self): def testJoinClient(self):
u = self.u u = self.u
self.proto.joinClient(u, '#Channel') self.proto.join(u, '#Channel')
self.assertIn(u, self.irc.channels['#channel'].users) self.assertIn(u, self.irc.channels['#channel'].users)
# Non-existant user. # Non-existant user.
self.assertRaises(LookupError, self.proto.joinClient, '9PYZZZZZZ', '#test') self.assertRaises(LookupError, self.proto.join, '9PYZZZZZZ', '#test')
def testKickClient(self): def testKickClient(self):
target = self.proto.spawnClient('soccerball', 'soccerball', 'abcd').uid target = self.proto.spawnClient('soccerball', 'soccerball', 'abcd').uid
self.proto.joinClient(target, '#pylink') self.proto.join(target, '#pylink')
self.assertIn(self.u, self.irc.channels['#pylink'].users) self.assertIn(self.u, self.irc.channels['#pylink'].users)
self.assertIn(target, self.irc.channels['#pylink'].users) self.assertIn(target, self.irc.channels['#pylink'].users)
self.proto.kickClient(self.u, '#pylink', target, 'Pow!') self.proto.kickClient(self.u, '#pylink', target, 'Pow!')
@ -60,13 +60,13 @@ class CommonProtoTestCase(PluginTestCase):
def testPartClient(self): def testPartClient(self):
u = self.u u = self.u
self.proto.joinClient(u, '#channel') self.proto.join(u, '#channel')
self.proto.partClient(u, '#channel') self.proto.partClient(u, '#channel')
self.assertNotIn(u, self.irc.channels['#channel'].users) self.assertNotIn(u, self.irc.channels['#channel'].users)
def testQuitClient(self): def testQuitClient(self):
u = self.proto.spawnClient('testuser3', 'moo', 'hello.world').uid u = self.proto.spawnClient('testuser3', 'moo', 'hello.world').uid
self.proto.joinClient(u, '#channel') self.proto.join(u, '#channel')
self.assertRaises(LookupError, self.proto.quitClient, '9PYZZZZZZ', 'quit reason') self.assertRaises(LookupError, self.proto.quitClient, '9PYZZZZZZ', 'quit reason')
self.proto.quitClient(u, 'quit reason') self.proto.quitClient(u, 'quit reason')
self.assertNotIn(u, self.irc.channels['#channel'].users) self.assertNotIn(u, self.irc.channels['#channel'].users)