diff --git a/http2irc.py b/http2irc.py index e6cfd70..bd0133a 100644 --- a/http2irc.py +++ b/http2irc.py @@ -153,8 +153,14 @@ class Config(dict): if isinstance(map_['auth'], str) and ':' not in map_['auth']: raise InvalidConfig(f'Invalid map {key!r} auth: must contain a colon') - if 'module' in map_ and not os.path.isfile(map_['module']): - raise InvalidConfig(f'Module {map_["module"]!r} in map {key!r} is not a file') + if 'module' in map_: + # If the path is relative, try to evaluate it relative to either the config file or this file; some modules are in the repo, but this also allows overriding them. + for basePath in (os.path.dirname(self._filename), os.path.dirname(__file__)): + if os.path.isfile(os.path.join(basePath, map_['module'])): + map_['module'] = os.path.abspath(os.path.join(basePath, map_['module'])) + break + else: + raise InvalidConfig(f'Module {map_["module"]!r} in map {key!r} is not a file') if 'moduleargs' in map_: if not isinstance(map_['moduleargs'], list): raise InvalidConfig(f'Invalid module args for {key!r}: not an array')