From 0815df1bca94a504c21d8e6f8f8bf16a7d7a5703 Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 9 Nov 2016 18:55:13 -0800 Subject: [PATCH] Irc: rewrite isInternalClient to use getServer & return a boolean (#355) --- classes.py | 9 ++++----- protocols/inspircd.py | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/classes.py b/classes.py index d619508..66bb63d 100644 --- a/classes.py +++ b/classes.py @@ -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): diff --git a/protocols/inspircd.py b/protocols/inspircd.py index c09f8da..e1568b0 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -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(