Correct our ValidChannel checking (no , in channel key) and provide a little

more information in supybot-wizard if there's an error when adding channels.
This commit is contained in:
James Vega 2004-10-07 18:47:26 +00:00
parent b196d3fc21
commit c5db149f65
2 changed files with 9 additions and 2 deletions

View File

@ -383,7 +383,8 @@ def main():
# FIXME: say which ones weren't channels. # FIXME: say which ones weren't channels.
output("""Not all of those are valid IRC channels. Be sure to output("""Not all of those are valid IRC channels. Be sure to
prefix the channel with # (or +, or !, or &, but no one uses prefix the channel with # (or +, or !, or &, but no one uses
those channels, really).""") those channels, really). Be sure the channel key (if you are
supplying one) does not contain a comma.""")
else: else:
conf.supybot.channels.setValue([]) conf.supybot.channels.setValue([])

View File

@ -168,7 +168,13 @@ class ValidChannel(registry.String):
"""Value must be a valid IRC channel name.""" """Value must be a valid IRC channel name."""
def setValue(self, v): def setValue(self, v):
if ',' in v: if ',' in v:
(channel, _) = v.split(',', 1) # To prevent stupid users from: a) trying to add a channel key
# with a comma in it, b) trying to add channels separated by
# commas instead of spaces
try:
(channel, _) = v.split(',')
except ValueError:
self.error()
else: else:
channel = v channel = v
if not ircutils.isChannel(channel): if not ircutils.isChannel(channel):