3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

relay: don't send empty MODE commands if there are no supported modes left after filtering

This commit is contained in:
James Lu 2015-07-16 16:27:17 -07:00
parent cf32461d8e
commit 2a586a6dba

View File

@ -88,10 +88,13 @@ def getRemoteUser(irc, remoteirc, user):
# If the user (stored here as {(netname, UID): # If the user (stored here as {(netname, UID):
# {network1: UID1, network2: UID2}}) exists, don't spawn it # {network1: UID1, network2: UID2}}) exists, don't spawn it
# again! # again!
if user == remoteirc.pseudoclient.uid: try:
return irc.pseudoclient.uid if user == remoteirc.pseudoclient.uid:
if user == irc.pseudoclient.uid: return irc.pseudoclient.uid
return remoteirc.pseudoclient.uid if user == irc.pseudoclient.uid:
return remoteirc.pseudoclient.uid
except AttributeError: # Network hasn't been initialized yet?
pass
try: try:
u = relayusers[(irc.name, user)][remoteirc.name] u = relayusers[(irc.name, user)][remoteirc.name]
except KeyError: except KeyError:
@ -386,12 +389,14 @@ def relayModes(irc, remoteirc, sender, channel, modes=None):
if supported_char: if supported_char:
supported_modes.append((prefix+supported_char, arg)) supported_modes.append((prefix+supported_char, arg))
log.debug('(%s) Relay mode: final modelist (sending to %s%s) is %s', irc.name, remoteirc.name, remotechan, supported_modes) log.debug('(%s) Relay mode: final modelist (sending to %s%s) is %s', irc.name, remoteirc.name, remotechan, supported_modes)
# Check if the sender is a user; remember servers are allowed to set modes too. # Don't send anything if there are no supported modes left after filtering.
if sender in irc.users: if supported_modes:
u = getRemoteUser(irc, remoteirc, sender) # Check if the sender is a user; remember servers are allowed to set modes too.
remoteirc.proto.modeClient(remoteirc, u, channel, supported_modes) if sender in irc.users:
else: u = getRemoteUser(irc, remoteirc, sender)
remoteirc.proto.modeServer(remoteirc, remoteirc.sid, channel, supported_modes) remoteirc.proto.modeClient(remoteirc, u, channel, supported_modes)
else:
remoteirc.proto.modeServer(remoteirc, remoteirc.sid, channel, supported_modes)
def handle_mode(irc, numeric, command, args): def handle_mode(irc, numeric, command, args):
target = args['target'] target = args['target']