diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-09-17 04:38:12 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-09-17 04:38:12 +0300 |
commit | a32e4a1629a20026c364059c7bbaec1dbd64353b (patch) | |
tree | ae1f805e95a992742e9904d503a0848189af747b | |
parent | 44aad914a3cea1b6e39cf5db7bebeafb59191707 (diff) |
multiple fixes
-rw-r--r-- | include/py/homekit/config/config.py | 3 | ||||
-rw-r--r-- | include/py/homekit/database/_base.py | 2 | ||||
-rw-r--r-- | include/py/homekit/database/sqlite.py | 2 | ||||
-rw-r--r-- | include/py/homekit/telegram/bot.py | 2 | ||||
-rw-r--r-- | include/py/homekit/telegram/config.py | 11 |
5 files changed, 12 insertions, 8 deletions
diff --git a/include/py/homekit/config/config.py b/include/py/homekit/config/config.py index 773de1e..5fe1ae8 100644 --- a/include/py/homekit/config/config.py +++ b/include/py/homekit/config/config.py @@ -10,6 +10,7 @@ from argparse import ArgumentParser from enum import Enum, auto from os.path import join, isdir, isfile from ..util import Addr +from pprint import pprint class MyValidator(cerberus.Validator): @@ -140,7 +141,7 @@ class ConfigUnit(BaseConfigUnit): schema['logging'] = { 'type': 'dict', 'schema': { - 'logging': {'type': 'boolean'} + 'verbose': {'type': 'boolean'} } } diff --git a/include/py/homekit/database/_base.py b/include/py/homekit/database/_base.py index c01e62b..dcec9da 100644 --- a/include/py/homekit/database/_base.py +++ b/include/py/homekit/database/_base.py @@ -1,7 +1,7 @@ import os -def get_data_root_directory(name: str) -> str: +def get_data_root_directory() -> str: return os.path.join( os.environ['HOME'], '.config', diff --git a/include/py/homekit/database/sqlite.py b/include/py/homekit/database/sqlite.py index 8b0c44c..1651a93 100644 --- a/include/py/homekit/database/sqlite.py +++ b/include/py/homekit/database/sqlite.py @@ -18,7 +18,7 @@ class SQLiteBase: def __init__(self, name=None, path=None, check_same_thread=False): if not path: if not name: - name = config.app_config['database_name'] + name = config.app_name database_path = _get_database_path(name) else: database_path = path diff --git a/include/py/homekit/telegram/bot.py b/include/py/homekit/telegram/bot.py index 2efd9e4..f5f620a 100644 --- a/include/py/homekit/telegram/bot.py +++ b/include/py/homekit/telegram/bot.py @@ -266,7 +266,7 @@ class conversation: return self.invoke(state, ctx) return _invoke - def invoke(self, state, ctx: Context): + async def invoke(self, state, ctx: Context): self._logger.debug(f'invoke, state={state}') for item in dir(self): f = getattr(self, item) diff --git a/include/py/homekit/telegram/config.py b/include/py/homekit/telegram/config.py index 4c7d74b..5f41008 100644 --- a/include/py/homekit/telegram/config.py +++ b/include/py/homekit/telegram/config.py @@ -51,15 +51,15 @@ class TelegramBotConfig(ConfigUnit, ABC): 'type': 'dict', 'schema': { 'token': {'type': 'string', 'required': True}, - TelegramUserListType.USERS: {**TelegramBotConfig._userlist_schema(), 'required': True}, - TelegramUserListType.NOTIFY: TelegramBotConfig._userlist_schema(), + TelegramUserListType.USERS.value: {**TelegramBotConfig._userlist_schema(), 'required': True}, + TelegramUserListType.NOTIFY.value: TelegramBotConfig._userlist_schema(), } } } @staticmethod def _userlist_schema() -> dict: - return {'type': 'list', 'schema': {'type': ['string', 'int']}} + return {'type': 'list', 'schema': {'type': ['string', 'integer']}} @staticmethod def custom_validator(data): @@ -72,4 +72,7 @@ class TelegramBotConfig(ConfigUnit, ABC): def get_user_ids(self, ult: TelegramUserListType = TelegramUserListType.USERS) -> list[int]: - return list(map(_user_id_mapper, self['bot'][ult.value]))
\ No newline at end of file + try: + return list(map(_user_id_mapper, self['bot'][ult.value])) + except KeyError: + return []
\ No newline at end of file |