I am trying to write a code for a bot using pyrogram, where it should process a command only from admins or owners. This is my code
@app.on_message(filters.chat(TARGET) & filters.command("start"))
async def start(client, message):
# Check if the sender is the owner or admin of the chat
chat_member_info = await client.get_chat_member(TARGET, message.from_user.id)
chat_member_info_status = chat_member_info.status
#checkpoint 1
await message.reply_text(f'You are {chat_member_info_status}')
if chat_member_info_status == 'ChatMemberStatus.OWNER' or chat_member_info_status == 'ChatMemberStatus.ADMINISTRATOR':
# Do A
)
else:
# Do B
Bot returns me 'You are ChatMemberStatus.OWNER' in my checkpoint 1 but for some reason, 'if' function never works and it program goes to 'Do B' every time...
Will appreciate any help, I am very new to pyrogram. thanks!
Tried to check first_name as a test instead and it works fine.
ChatMemberStatus.OWNERis an ENUM, you're using it as a string.You'll need something like: