V
V
Viplayer2019-05-30 16:56:46
Python
Viplayer, 2019-05-30 16:56:46

How to kick a user from a conversation with a python bot?

The VK documentation has a "messages.removeChatUser" method for kicking the user, but you need to know the conversation ID, how to find out for the bot?

if body.lower() == "кик":
                vk.method("messages.removeChatUser", {"chat_id": chat_id, "user_id": user_id, "random_id": random.randint(1, 2147483647)})

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
kolomiec_artiom, 2019-05-30
@kolomiec_artiom

Good afternoon!
In order to find the desired conversation - use "messages.getConversations". There will be a list of conversations with all the parameters from which you can get the desired ID using the name of the conversation
In order to delete a person on command - just add a similar
condition -something action

A
andrey_levushkin, 2019-07-12
@andrey_levushkin

conversation id is the peer_id parameter and is calculated by the method 2000000000 + the sequence number of the conversation creation

N
nnikolyaa, 2020-06-26
@nnikolyaa

My question is, what does random.randint do at the end of the request?

E
Evgeny Akimov, 2020-07-05
@Zenddos

random is needed to generate a unique key, as in creating a message

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question