3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 11:42:51 +01:00

relay: rework "target in channel" requirements for clientbot links

Closes #305.
This commit is contained in:
James Lu 2016-08-04 10:47:06 -07:00
parent e50684e367
commit 7a0fd1caa3

View File

@ -1574,8 +1574,22 @@ def link(irc, source, args):
return
if source not in irc.channels[localchan].users:
irc.reply('Error: You must be in %r to complete this operation.' % localchan)
return
# Caller is not in the requested channel.
log.debug('(%s) Source not in channel %s; protoname=%s', irc.name, localchan, irc.protoname)
if irc.protoname == 'clientbot':
# Special case for Clientbot: join the requested channel first, then
# require that the caller be opped.
if localchan not in irc.pseudoclient.channels:
irc.proto.join(irc.pseudoclient.uid, localchan)
irc.reply('Joining %r now; please run this command again in a few seconds.' % localchan)
return
elif not irc.channels[localchan].isOpPlus(source):
irc.reply('Error: You must be opped in %r to complete this operation.' % localchan)
return
else:
irc.reply('Error: You must be in %r to complete this operation.' % localchan)
return
irc.checkAuthenticated(source)