From 7a0fd1caa3c4f80a7f55c4f0e239c783172b6c8c Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 4 Aug 2016 10:47:06 -0700 Subject: [PATCH] relay: rework "target in channel" requirements for clientbot links Closes #305. --- plugins/relay.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/relay.py b/plugins/relay.py index f50d5b4..54c28f0 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -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)