From aff843c867311d3ffe852d38b32f4d1bf348c496 Mon Sep 17 00:00:00 2001 From: kiriharu Date: Tue, 1 Jun 2021 20:43:39 +0300 Subject: [PATCH] log warning if notification token not setted --- apps/tgbot/tgbot/handlers/helpers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/tgbot/tgbot/handlers/helpers.py b/apps/tgbot/tgbot/handlers/helpers.py index 48a8dbf..f2620cb 100644 --- a/apps/tgbot/tgbot/handlers/helpers.py +++ b/apps/tgbot/tgbot/handlers/helpers.py @@ -48,7 +48,10 @@ async def send_api_requests(endpoint: str, data: dict, nodes: List[APINode]): async def send_message_to_admins(message: str): - bot = Bot(token=NOTIFICATION_BOT_TOKEN) - for user in NOTIFICATION_USERS: - logger.info(f"Sended notification to {user}") - await bot.send_message(user, message, parse_mode='Markdown') + if NOTIFICATION_BOT_TOKEN: + bot = Bot(token=NOTIFICATION_BOT_TOKEN) + for user in NOTIFICATION_USERS: + logger.info(f"Sended notification to {user}") + await bot.send_message(user, message, parse_mode='Markdown') + else: + logger.warning(f"Notificator bot token not setted. Skipping send notifications to admin") \ No newline at end of file