Update ValidChannel exceptions to contain the invalid channel.

This commit is contained in:
James Vega 2005-04-04 03:05:52 +00:00
parent 99ea2e199e
commit aea980ce41
2 changed files with 13 additions and 6 deletions

View File

@ -379,12 +379,11 @@ def main():
try:
network.channels.set(channels)
break
except registry.InvalidRegistryValue:
# FIXME: say which ones weren't channels.
output("""Not all of those are valid IRC channels. Be sure to
prefix the channel with # (or +, or !, or &, but no one uses
those channels, really). Be sure the channel key (if you are
supplying one) does not contain a comma.""")
except registry.InvalidRegistryValue, e:
output("""%s is an invalid IRC channel. Be sure to prefix the
channel with # (or +, or !, or &, but no one uses those
channels, really). Be sure the channel key (if you are
supplying one) does not contain a comma.""" % e.channel)
else:
network.channels.setValue([])

View File

@ -161,6 +161,7 @@ class ValidNicksAllowingPercentS(ValidNicks):
class ValidChannel(registry.String):
"""Value must be a valid IRC channel name."""
def setValue(self, v):
self.channel = v
if ',' in v:
# To prevent stupid users from: a) trying to add a channel key
# with a comma in it, b) trying to add channels separated by
@ -176,6 +177,13 @@ class ValidChannel(registry.String):
else:
registry.String.setValue(self, v)
def error(self):
try:
super(ValidChannel, self).error()
except registry.InvalidRegistryValue, e:
e.channel = self.channel
raise e
class ValidHostmask(registry.String):
"""Value must be a valid user hostmask."""
def setValue(self, v):