From fa5a502a3318f20c5fc15fed06189b05d4a3b209 Mon Sep 17 00:00:00 2001 From: Rykov7 Date: Sun, 24 Dec 2023 15:45:26 +0300 Subject: [PATCH] Refactor stats command. --- src/admin_commands.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/admin_commands.py b/src/admin_commands.py index 13daa6c..39d1951 100644 --- a/src/admin_commands.py +++ b/src/admin_commands.py @@ -52,12 +52,13 @@ async def list_jobs(_message): @bot.message_handler(func=is_admin, commands=["stats"]) async def send_stats(message: types.Message): - if len(message.text.split()) == 1: - rep = create_report_text(message.chat.id) - if rep: - await bot.send_message(message.chat.id, rep) + """Show group statistics.""" + chat_id = message.chat.id if len(message.text.split()) == 1 else message.text.split()[-1] + report_text = create_report_text(chat_id) + if report_text: + await bot.send_message(message.chat.id, report_text) else: - await bot.send_message(message.chat.id, create_report_text(message.text.split()[-1])) + logging.info("[STATS] Невозможно отправить отчёт, недостаточно данных.") @bot.message_handler(func=is_admin, commands=["reset_stats"], chat_types=["supergroup", "group"])