3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-27 04:34:13 +01:00

relay: fixes to support IDs as channel name

- Don't enforce local channel validity rules on the remote channel name
- Normalize channels to str before looking them up in the DB
This commit is contained in:
James Lu 2019-02-16 16:33:02 -08:00
parent 55360dd0b2
commit 9d459fab92

View File

@ -524,7 +524,7 @@ def get_relay(irc, channel):
"""Finds the matching relay entry name for the given network, channel """Finds the matching relay entry name for the given network, channel
pair, if one exists.""" pair, if one exists."""
chanpair = (irc.name, irc.to_lower(channel)) chanpair = (irc.name, irc.to_lower(str(channel)))
if chanpair in db: # This chanpair is a shared channel; others link to it if chanpair in db: # This chanpair is a shared channel; others link to it
return chanpair return chanpair
@ -2241,7 +2241,7 @@ def create(irc, source, args):
creator = irc.get_hostmask(source) creator = irc.get_hostmask(source)
# Create the relay database entry with the (network name, channel name) # Create the relay database entry with the (network name, channel name)
# pair - this is just a dict with various keys. # pair - this is just a dict with various keys.
db[(irc.name, channel)] = {'links': set(), db[(irc.name, str(channel))] = {'links': set(),
'blocked_nets': set(), 'blocked_nets': set(),
'creator': creator, 'creator': creator,
'ts': time.time(), 'ts': time.time(),
@ -2350,12 +2350,11 @@ def link(irc, source, args):
args = link_parser.parse_args(args) args = link_parser.parse_args(args)
# Normalize channel case # Normalize channel case
channel = irc.to_lower(args.channel) channel = irc.to_lower(str(args.channel))
localchan = irc.to_lower(args.localchannel or args.channel) localchan = irc.to_lower(str(args.localchannel or args.channel))
remotenet = args.remotenet remotenet = args.remotenet
for c in (channel, localchan): if not irc.is_channel(localchan):
if not irc.is_channel(c):
irc.error('Invalid channel %r.' % c) irc.error('Invalid channel %r.' % c)
return return