3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

Irc: rewrite isInternalClient to use getServer & return a boolean (#355)

This commit is contained in:
James Lu 2016-11-09 18:55:13 -08:00
parent ddd0436937
commit 0815df1bca
2 changed files with 8 additions and 7 deletions

View File

@ -876,12 +876,11 @@ class Irc():
def isInternalClient(self, numeric):
"""
Checks whether the given numeric is a PyLink Client,
returning the SID of the server it's on if so.
Returns whether the given client numeric (UID) is a PyLink client.
"""
for sid in self.servers:
if self.servers[sid].internal and numeric in self.servers[sid].users:
return sid
sid = self.getServer(numeric)
if sid and self.servers[sid].internal:
return True
return False
def isInternalServer(self, sid):

View File

@ -71,10 +71,12 @@ class InspIRCdProtocol(TS6BaseProtocol):
# so what we're actually doing here is sending FJOIN from the server,
# on behalf of the clients that are joining.
channel = self.irc.toLower(channel)
server = self.irc.isInternalClient(client)
if not server:
server = self.irc.getServer(client)
if not self.irc.isInternalServer(server):
log.error('(%s) Error trying to join %r to %r (no such client exists)', self.irc.name, client, channel)
raise LookupError('No such PyLink client exists.')
# Strip out list-modes, they shouldn't be ever sent in FJOIN.
modes = [m for m in self.irc.channels[channel].modes if m[0] not in self.irc.cmodes['*A']]
self._send(server, "FJOIN {channel} {ts} {modes} :,{uid}".format(