OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Check is user admin in group or supergroup in telegram, by using get_chat_administrators&

  • Thread starter Thread starter Евгений
  • Start date Start date
Е

Евгений

Guest
I need to get list of group admins and check message.from_user.id in that list

Code:
@router3.message(Command('ban'))
async def ban_command(message: Message):
    admins = await bot.get_chat_administrators(chat_id=message.chat.id)
    if message.from_user.id in admins:
        await bot.ban_chat_member(user_id=message.reply_to_message.from_user.id)
    else:
        await message.answer("нет прав")

it's does not work, and all time i have else answer

what's methods can i use to do it?
<p>I need to get list of group admins and check message.from_user.id in that list</p>
<pre><code>@router3.message(Command('ban'))
async def ban_command(message: Message):
admins = await bot.get_chat_administrators(chat_id=message.chat.id)
if message.from_user.id in admins:
await bot.ban_chat_member(user_id=message.reply_to_message.from_user.id)
else:
await message.answer("нет прав")
</code></pre>
<p>it's does not work, and all time i have else answer</p>
<p>what's methods can i use to do it?</p>
 

Latest posts

Top