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)