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

View File

@ -161,6 +161,7 @@ class ValidNicksAllowingPercentS(ValidNicks):
class ValidChannel(registry.String): 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):
self.channel = v
if ',' in v: if ',' in v:
# To prevent stupid users from: a) trying to add a channel key # To prevent stupid users from: a) trying to add a channel key
# with a comma in it, b) trying to add channels separated by # with a comma in it, b) trying to add channels separated by
@ -176,6 +177,13 @@ class ValidChannel(registry.String):
else: else:
registry.String.setValue(self, v) 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): class ValidHostmask(registry.String):
"""Value must be a valid user hostmask.""" """Value must be a valid user hostmask."""
def setValue(self, v): def setValue(self, v):