[config] Register config to bot_base
All checks were successful
Gitsokyo/bot-base/pipeline/tag This commit looks good
All checks were successful
Gitsokyo/bot-base/pipeline/tag This commit looks good
[version] Bump
This commit is contained in:
parent
bed9abd194
commit
7f7532d348
@ -15,7 +15,7 @@ from config import Config, config_types
|
|||||||
from config.config_types import factory
|
from config.config_types import factory
|
||||||
import errors
|
import errors
|
||||||
|
|
||||||
__version__ = "0.1.1"
|
__version__ = "0.2.0"
|
||||||
MINIMAL_INFOS = ["version", "bot_version"]
|
MINIMAL_INFOS = ["version", "bot_version"]
|
||||||
|
|
||||||
|
|
||||||
@ -36,6 +36,8 @@ class BotBase(discord.Client):
|
|||||||
self.modules = {}
|
self.modules = {}
|
||||||
|
|
||||||
# Setup config
|
# Setup config
|
||||||
|
self.configs = {}
|
||||||
|
|
||||||
self.config = Config(path=os.path.join(data_folder, "config.toml"))
|
self.config = Config(path=os.path.join(data_folder, "config.toml"))
|
||||||
self.config.register("modules", factory(config_types.List, factory(config_types.Str)))
|
self.config.register("modules", factory(config_types.List, factory(config_types.Str)))
|
||||||
self.config.register("data_folder", factory(config_types.Str))
|
self.config.register("data_folder", factory(config_types.Str))
|
||||||
@ -104,7 +106,8 @@ class BotBase(discord.Client):
|
|||||||
try:
|
try:
|
||||||
dep_version_specifier = SpecifierSet(version)
|
dep_version_specifier = SpecifierSet(version)
|
||||||
except InvalidSpecifier:
|
except InvalidSpecifier:
|
||||||
self.warning(f"Attempt to load incompatible module {module}: dependance version is invalid ({version} for {dep})")
|
self.warning(
|
||||||
|
f"Attempt to load incompatible module {module}: dependance version is invalid ({version} for {dep})")
|
||||||
raise errors.IncompatibleModuleError(f"Module {module} is not compatible with your current "
|
raise errors.IncompatibleModuleError(f"Module {module} is not compatible with your current "
|
||||||
f"installation (version specifier {version} for {dep} is "
|
f"installation (version specifier {version} for {dep} is "
|
||||||
f"invalid.")
|
f"invalid.")
|
||||||
@ -218,3 +221,10 @@ class BotBase(discord.Client):
|
|||||||
if self.log:
|
if self.log:
|
||||||
self.log.warning(warning, *args, **kwargs)
|
self.log.warning(warning, *args, **kwargs)
|
||||||
self.dispatch("log_warning", warning, *args, **kwargs)
|
self.dispatch("log_warning", warning, *args, **kwargs)
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
def get_config(self, path):
|
||||||
|
self.configs.update({
|
||||||
|
path: self.configs.get(path) or Config(path=path)
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user