R
R
RINAMI2021-07-19 14:24:31
Python
RINAMI, 2021-07-19 14:24:31

Why is checking for administrator not working properly?

There is the following piece of code that acts as a check for an administrator in a conversation:

ConvItms = vk.method("messages.getConversationMembers",{"peer_id": 2000000000 + id, "group_id": 'мой айди'})["items"]
      for Member in ConvItms:
        if Member["is_admin"]:
            try:
                vk.method("messages.removeChatUser", {'chat_id': id, 'user_id': renmes.split(' ')[1]})
                kicked = renmes.split(' ')[1]
                chatsender(id, 'Глава Клана Амир Ринамов исключил' + ' ' + '@id' + kicked + '\n'
                                                 '❓По причине: Нарушение 2.1-2.5 пунктов правил❓')
            except:
                forwardsender(id, '❌Rinami-sama, участник отсутствует в беседе❌')
        else:
             chatsender(id, '❌Ты не Rinami-sama❌')
        break

Only now when I display the result using print, it shows True for a participant who does not have administrator rights.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2021-07-19
@RINAMI

Member["is_admin"] here can be just the String True or False, and not a Boolean value,
you need to do print(type(Member["is_admin"])) and after analyzing this, write the condition correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question