chore: misc
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
version: '3.8'
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
@ -9,7 +9,7 @@ services:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: bdbot
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "5432"
|
||||
# Persist data in a local folder ./postgres_data
|
||||
volumes:
|
||||
- ./postgres_data:/var/lib/postgresql/data
|
||||
|
||||
@ -23,9 +23,18 @@ def register_command_handlers(bot: telebot.TeleBot) -> None:
|
||||
bot.reply_to(message, "Мне нужны права администратора для выполнения этой команды.")
|
||||
return
|
||||
|
||||
# Get total members count
|
||||
# Get total members count (exclude bots)
|
||||
try:
|
||||
total_members = bot.get_chat_member_count(chat_id)
|
||||
total_members_raw = bot.get_chat_member_count(chat_id)
|
||||
# Try to subtract all bots (including this bot) using admin list
|
||||
human_members = total_members_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(total_members_raw - bots_in_admins, 0)
|
||||
except Exception:
|
||||
human_members = total_members_raw
|
||||
total_members = human_members
|
||||
except Exception:
|
||||
total_members = 0
|
||||
|
||||
@ -34,7 +43,7 @@ def register_command_handlers(bot: telebot.TeleBot) -> None:
|
||||
UserChat.chat_id == chat_id
|
||||
).distinct().count()
|
||||
|
||||
users_without_birthday = total_members - users_with_birthday
|
||||
users_without_birthday = max(total_members - users_with_birthday, 0)
|
||||
|
||||
# Format message
|
||||
if total_members > 0:
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user