mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-26 04:32:51 +01:00
relay: forbid linking two channels on the same network
This commit is contained in:
parent
9132bfcb3a
commit
e47738c27f
@ -1405,25 +1405,36 @@ def link(irc, source, args):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
irc.reply("Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).")
|
irc.reply("Error: Not enough arguments. Needs 2-3: remote netname, channel, local channel name (optional).")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
localchan = irc.toLower(args[2])
|
localchan = irc.toLower(args[2])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
localchan = channel
|
localchan = channel
|
||||||
|
|
||||||
for c in (channel, localchan):
|
for c in (channel, localchan):
|
||||||
if not utils.isChannel(c):
|
if not utils.isChannel(c):
|
||||||
irc.reply('Error: Invalid channel %r.' % c)
|
irc.reply('Error: Invalid channel %r.' % c)
|
||||||
return
|
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:
|
if source not in irc.channels[localchan].users:
|
||||||
irc.reply('Error: You must be in %r to complete this operation.' % localchan)
|
irc.reply('Error: You must be in %r to complete this operation.' % localchan)
|
||||||
return
|
return
|
||||||
|
|
||||||
irc.checkAuthenticated(source)
|
irc.checkAuthenticated(source)
|
||||||
|
|
||||||
if remotenet not in world.networkobjects:
|
if remotenet not in world.networkobjects:
|
||||||
irc.reply('Error: No network named %r exists.' % remotenet)
|
irc.reply('Error: No network named %r exists.' % remotenet)
|
||||||
return
|
return
|
||||||
localentry = getRelay((irc.name, localchan))
|
localentry = getRelay((irc.name, localchan))
|
||||||
|
|
||||||
if localentry:
|
if localentry:
|
||||||
irc.reply('Error: Channel %r is already part of a relay.' % localchan)
|
irc.reply('Error: Channel %r is already part of a relay.' % localchan)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
entry = db[(remotenet, channel)]
|
entry = db[(remotenet, channel)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user