From e47738c27fbea94e2aaefa439f36efbda82f3620 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 19 Jun 2016 12:13:56 -0700 Subject: [PATCH] relay: forbid linking two channels on the same network --- plugins/relay.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/relay.py b/plugins/relay.py index d112bef..07f9a27 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -1405,25 +1405,36 @@ def link(irc, source, args): except IndexError: irc.reply("Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).") return + try: localchan = irc.toLower(args[2]) except IndexError: localchan = channel + for c in (channel, localchan): if not utils.isChannel(c): irc.reply('Error: Invalid channel %r.' % c) return + + if remotenet == irc.name: + irc.reply('Error: Cannot link two channels on the same network.') + return + if source not in irc.channels[localchan].users: irc.reply('Error: You must be in %r to complete this operation.' % localchan) return + irc.checkAuthenticated(source) + if remotenet not in world.networkobjects: irc.reply('Error: No network named %r exists.' % remotenet) return localentry = getRelay((irc.name, localchan)) + if localentry: irc.reply('Error: Channel %r is already part of a relay.' % localchan) return + try: entry = db[(remotenet, channel)] except KeyError: