Here is a part of my code:
permissions = await client.get_permissions(event.chat_id, user.id)
InsertNewUserInDB(user.id, user.username, permissions.is_admin, permissions.is_muted, permissions.is_banned)
There is many func's in Documentation and I easily can check if user is admin or is banned. But how can I easily get property that user is muted or restricted? Because I can edit permissions by func await edit_permissions(... send_messages: bool = True...)→ Updates
Method for editing permission description
Permissions that you can get through method "get_par...permissions"
I solves this by adding aiogram in my solution. For starting the bot, you should add it at the start of main.py file:
from aiogram import Bot, Dispatcher
from aiogram.types import ChatMemberRestricted, ChatMemberBanned
bot = Bot(token=config('API_TOKEN'))
dp = Dispatcher()
and then in handler, you should use:
for user in users:
if user.username == None:
user.username = str(user.id)
permissions = await client.get_permissions(event.chat_id, user.id)
member = await bot.get_chat_member(event.chat_id, user.id)
is_admin = permissions.is_admin
is_muted = isinstance(member, ChatMemberRestricted)
is_banned = isinstance(member, ChatMemberBanned)