Refactor stats command.

This commit is contained in:
Rykov7
2023-12-24 15:45:26 +03:00
parent 94da39a01b
commit fa5a502a33
+6 -5
View File
@@ -52,12 +52,13 @@ async def list_jobs(_message):
@bot.message_handler(func=is_admin, commands=["stats"]) @bot.message_handler(func=is_admin, commands=["stats"])
async def send_stats(message: types.Message): async def send_stats(message: types.Message):
if len(message.text.split()) == 1: """Show group statistics."""
rep = create_report_text(message.chat.id) chat_id = message.chat.id if len(message.text.split()) == 1 else message.text.split()[-1]
if rep: report_text = create_report_text(chat_id)
await bot.send_message(message.chat.id, rep) if report_text:
await bot.send_message(message.chat.id, report_text)
else: 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"]) @bot.message_handler(func=is_admin, commands=["reset_stats"], chat_types=["supergroup", "group"])