diff options
Diffstat (limited to 'src/inverter_bot.py')
-rwxr-xr-x | src/inverter_bot.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/inverter_bot.py b/src/inverter_bot.py index 8a9c363..ecf01fc 100755 --- a/src/inverter_bot.py +++ b/src/inverter_bot.py @@ -4,6 +4,7 @@ import re import datetime import json import itertools +import sys from inverterd import Format, InverterError from html import escape @@ -12,6 +13,7 @@ from typing import Optional, Tuple, Union from home.util import chunks from home.config import config, AppConfigUnit from home.telegram import bot +from home.telegram.config import TelegramBotConfig, TelegramUserListType from home.inverter import ( wrapper_instance as inverter, beautify_table, @@ -29,6 +31,12 @@ from home.api.types import BotType from home.api import WebAPIClient from telegram import ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton + +if __name__ != '__main__': + print(f'this script can not be imported as module', file=sys.stderr) + sys.exit(1) + + db = None LT = escape('<=') flags_map = { @@ -44,16 +52,11 @@ flags_map = { logger = logging.getLogger(__name__) -class InverterBotConfig(AppConfigUnit): +class InverterBotConfig(AppConfigUnit, TelegramBotConfig): NAME = 'inverter_bot' @staticmethod def schema() -> Optional[dict]: - userlist_schema = { - 'type': 'list', - 'empty': False, - 'schema': {'type': 'integer'} - } acmode_item_schema = { 'thresholds': { 'type': 'list', @@ -68,15 +71,7 @@ class InverterBotConfig(AppConfigUnit): } return { - 'bot': { - 'type': 'dict', - 'required': True, - 'schema': { - 'token': {'type': 'string'}, - 'users': userlist_schema, - 'notify_users': userlist_schema - } - }, + **super(TelegramBotConfig).schema(), 'ac_mode': { 'type': 'dict', 'required': True, |