|
|
@@ -129,12 +129,14 @@ class Config(dict): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} web path: collides with map {seenWebPaths[map_["webpath"]]!r}') |
|
|
|
seenWebPaths[map_['webpath']] = key |
|
|
|
|
|
|
|
if 'ircchannel' in map_: |
|
|
|
if not isinstance(map_['ircchannel'], str): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} IRC channel: not a string') |
|
|
|
if not map_['ircchannel'].startswith('#') and not map_['ircchannel'].startswith('&'): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} IRC channel: does not start with # or &') |
|
|
|
#TODO Check if it's a valid name per IRC spec |
|
|
|
if 'ircchannel' not in map_: |
|
|
|
map_['ircchannel'] = f'#{key}' |
|
|
|
if not isinstance(map_['ircchannel'], str): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} IRC channel: not a string') |
|
|
|
if not map_['ircchannel'].startswith('#') and not map_['ircchannel'].startswith('&'): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} IRC channel: does not start with # or &') |
|
|
|
if any(x in map_['ircchannel'][1:] for x in (' ', '\x00', '\x07', '\r', '\n', ',')): |
|
|
|
raise InvalidConfig(f'Invalid map {key!r} IRC channel: contains forbidden characters') |
|
|
|
|
|
|
|
if 'auth' in map_: |
|
|
|
if map_['auth'] is not False and not isinstance(map_['auth'], str): |
|
|
@@ -156,8 +158,7 @@ class Config(dict): |
|
|
|
# Fill in default values for the maps |
|
|
|
for key, map_ in obj['maps'].items(): |
|
|
|
# webpath is already set above for duplicate checking |
|
|
|
if 'ircchannel' not in map_: |
|
|
|
map_['ircchannel'] = f'#{key}' |
|
|
|
# ircchannel is set above for validation |
|
|
|
if 'auth' not in map_: |
|
|
|
map_['auth'] = False |
|
|
|
if 'module' not in map_: |
|
|
|