From c8de713771bd44e935c80d1182714c10ee110534 Mon Sep 17 00:00:00 2001 From: Verum Date: Thu, 6 Mar 2025 05:12:32 +0700 Subject: [PATCH] =?UTF-8?q?1.10=20=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BE=D0=B2,=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BA=D1=80=D1=8B=D1=82=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B8=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BE=D0=B2=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BotCode/utils/admin_list.py | 22 ++++++++++++++++++++++ BotCode/utils/all_admins_hide.py | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 BotCode/utils/admin_list.py create mode 100644 BotCode/utils/all_admins_hide.py diff --git a/BotCode/utils/admin_list.py b/BotCode/utils/admin_list.py new file mode 100644 index 0000000..bf16c15 --- /dev/null +++ b/BotCode/utils/admin_list.py @@ -0,0 +1,22 @@ +# BotCode/utils/admin_lists.py +# Составления листа администраторов + +from BotLibrary import bot + +# Настройки экспорта в модули +__all__ = ("admin_lists",) + + +# Функция составления словаря администраторов +async def admin_lists(chat_id: int): + admins = await bot.get_chat_administrators(chat_id) + # Формируем список упоминаний администраторов + admin_mentions = [] + for admin in admins: + if admin.user.is_bot: + continue + admin_mentions.append( + f"@{admin.user.username}" if admin.user.username else f"{admin.user.full_name}") + + admins_text = ", ".join(admin_mentions) if admin_mentions else "Нет администраторов" + return admins_text diff --git a/BotCode/utils/all_admins_hide.py b/BotCode/utils/all_admins_hide.py new file mode 100644 index 0000000..46b9438 --- /dev/null +++ b/BotCode/utils/all_admins_hide.py @@ -0,0 +1,24 @@ +# BotCode/utils/all_admins_hide.py +# Составления листа администраторов (для скрытого отправления) + +from aiogram import types +from aiogram.utils import markdown +from BotLibrary import bot + +# Настройки экспорта в модули +__all__ = ("hidden_admins_message",) + + +# Функция составления словаря администраторов +async def hidden_admins_message(message: types.Message = None, chat_id: int = None, text: str = "", msg: bool = True, *args): + chat_id = chat_id if isinstance(chat_id, int) else message.chat.id + admins = await bot.get_chat_administrators(chat_id) + hidden_links = "".join( + markdown.hide_link(f"tg://user?id={admin.user.id}") + for admin in admins if not admin.user.is_bot + ) + result = f"{hidden_links}{text}" + if msg: + return result + else: + await message.answer(result)