Answer the question
In order to leave comments, you need to log in
How to determine if a user is a VKontakte chat administrator?
For good programmers and those who worked with vk_api, a simple problem
Hello. I have my own VK bot in Python. I want to make several commands to administer the conversation. They should only be available to chat admins and the creator of the conversation.
But there are 2 problems.
How to determine if a person is an administrator?
And how to determine if my bot's group is an administrator.
Since I'm not a true programmer yet, I can't figure out how to do this, for example.
Tell me how to do this, for example, through the getConversationMembers method.
So far, this command only works for id specified in the code.
This is how the code looks like:
if 'кик' in response:
count_command += 1
if event.obj.from_id == 'Ну тут типа мой id' or event.obj.from_id == 'Ну тут типа мой id' or event.obj.from_id == 'Ну тут типа мой id':
try:
if event.obj.fwd_messages != []:
i = event.obj.fwd_messages[0]["from_id"]
elif event.obj.reply_message:
i = event.obj.reply_message["from_id"]
else:
while not response.startswith('['):
response = response.lstrip(response[0])
response = response.strip('[]')
response = response[::-1]
while not response.startswith('|'):
response = response.lstrip(response[0])
response = response.strip('|id')
i = int(response[::-1])
if i != 'Ну тут типа мой id' and i != 'Ну тут типа мой id':
session_api.messages.removeChatUser(chat_id = event.obj.peer_id - 2000000000, member_id = i)
else:
send_message(vk_session, 'peer_id',event.obj.peer_id, message= 'Ты батюшку решил кикнуть?')
continue
except:
send_message(vk_session, 'peer_id',event.obj.peer_id, message= error_msg, attachment = error_p)
continue
else:
send_message(vk_session, 'peer_id',event.obj.peer_id, message= access_error)
continue
continue
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question