Skip to content

Commit

Permalink
Improved fetch_admins() function
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterGroosha committed May 10, 2022
1 parent 7afda10 commit 609fd52
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bot/before_start.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from typing import Dict
from typing import Dict, List, Union

from aiogram import Bot
from aiogram.types import ChatMemberAdministrator
from aiogram.types import ChatMemberAdministrator, ChatMemberOwner

from bot.config_reader import config


async def fetch_admins(bot: Bot) -> Dict:
result = {}
admins: List[Union[ChatMemberOwner, ChatMemberAdministrator]]
admins = await bot.get_chat_administrators(config.group_main)
for admin in admins:
if admin.status == "creator":
if isinstance(admin, ChatMemberOwner):
result[admin.user.id] = {"can_restrict_members": True}
else:
result[admin.user.id] = {"can_restrict_members": admin.can_restrict_members}
Expand Down

0 comments on commit 609fd52

Please sign in to comment.