mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-20 07:20:59 +01:00
Irc: rewrite isInternalClient to use getServer & return a boolean (#355)
This commit is contained in:
parent
ddd0436937
commit
0815df1bca
@ -876,12 +876,11 @@ class Irc():
|
|||||||
|
|
||||||
def isInternalClient(self, numeric):
|
def isInternalClient(self, numeric):
|
||||||
"""
|
"""
|
||||||
Checks whether the given numeric is a PyLink Client,
|
Returns whether the given client numeric (UID) is a PyLink client.
|
||||||
returning the SID of the server it's on if so.
|
|
||||||
"""
|
"""
|
||||||
for sid in self.servers:
|
sid = self.getServer(numeric)
|
||||||
if self.servers[sid].internal and numeric in self.servers[sid].users:
|
if sid and self.servers[sid].internal:
|
||||||
return sid
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isInternalServer(self, sid):
|
def isInternalServer(self, sid):
|
||||||
|
@ -71,10 +71,12 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
# 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,
|
||||||
# on behalf of the clients that are joining.
|
# on behalf of the clients that are joining.
|
||||||
channel = self.irc.toLower(channel)
|
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)
|
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.')
|
raise LookupError('No such PyLink client exists.')
|
||||||
|
|
||||||
# Strip out list-modes, they shouldn't be ever sent in FJOIN.
|
# 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']]
|
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(
|
self._send(server, "FJOIN {channel} {ts} {modes} :,{uid}".format(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user