RelayNext: merge 'unset' and 'remove' commands into 'remove'

New behavior: 'remove' without arguments removes entire relay, 'remove' with
channels specified will remove those channels in question. 'unset' is dropped.

Also update the README accordingly.
This commit is contained in:
James Lu 2015-02-01 20:44:57 -05:00
parent 45879709e5
commit 78006970a5
2 changed files with 19 additions and 21 deletions

View File

@ -31,8 +31,17 @@ The `list` command will list all relays defined.
### Removing/clearing relays
The `unset` command removes a relay name, while the `clear` command clears all relays. The `remove` command removes individual channels from a relay, deleting it completely when the amount of channels is less than 2.
Once a relay is created, you can remove the relays (or channels within them) using the `remove` command. There is also a `clear` command which clears all relays.
To remove channels from an existing relay:
* `relaynext remove Your-relay-name #channel1@networkone #blah@networktwo`
Or, to delete an entire relay:
* `relaynext remove Your-relay-name`
Relays require at least two channels to relay between. When the last two channels are removed, the relay is automatically deleted.
## Configuration
### Relaying non-PRIVMSG events

View File

@ -440,21 +440,23 @@ class RelayNext(callbacks.Plugin):
many('somethingWithoutSpaces')])
def remove(self, irc, msg, args, rid, relays):
"""<id> <relays>
"""<id> [<relays>]
Removes <relays> from relay <id>. <relays> is a space separated
list of #channel@network combinations, where <network> is the name
of your network. <id> is the name of your relay, which can be a
number, string, etc.
number, string, etc. If <relays> is not given, removes the entire
relay.
"""
try:
current_relays = self.db[rid]
except KeyError:
irc.error("No such relay '%s' exists." % rid, Raise=True)
if type(relays) == list:
relays = list(map(str.lower, relays))
else:
relays = [relays.lower()]
if not relays:
del self.db[rid]
irc.replySuccess()
return
relays = list(map(str.lower, relays))
self.checkRelays(irc, relays)
for relay in relays:
current_relays.discard(relay)
@ -462,20 +464,7 @@ class RelayNext(callbacks.Plugin):
del self.db[rid]
irc.replySuccess()
remove = wrap(remove, ['admin', 'somethingWithoutSpaces',
many('somethingWithoutSpaces')])
def unset(self, irc, msg, args, rid):
"""<id>
Removes relay <id>.
"""
try:
del self.db[rid]
except KeyError:
irc.error("No such relay '%s' exists." % rid, Raise=True)
else:
irc.replySuccess()
unset = wrap(unset, ['admin', 'somethingWithoutSpaces'])
any('somethingWithoutSpaces')])
def list(self, irc, msg, args):
"""takes no arguments.