chore: misc

This commit is contained in:
2026-01-28 12:47:48 +03:00
parent 0ceb92b3be
commit c3e0da7029
4 changed files with 26 additions and 8 deletions

View File

@ -145,9 +145,18 @@ def show_statistics(bot: telebot.TeleBot, chat: telebot.types.Chat) -> None:
try:
chat_id = chat.id
# Get all chat members
# Get all chat members (exclude bots where possible)
try:
members_count = bot.get_chat_member_count(chat_id)
members_count_raw = bot.get_chat_member_count(chat_id)
# Try to subtract all bots (including this bot) using admin list
human_members = members_count_raw
try:
admins = bot.get_chat_administrators(chat_id)
bots_in_admins = sum(1 for m in admins if getattr(m.user, "is_bot", False))
human_members = max(members_count_raw - bots_in_admins, 0)
except Exception:
human_members = members_count_raw
members_count = human_members
except Exception:
members_count = 0