Answer the question
In order to leave comments, you need to log in
How to make a kick command in VK api?
I need to make a kick command for a bot in VK. You can throw off a piece of code, which shows how this is all done, I have already read the documentation. The command should work like this: /kick id
.
Answer the question
In order to leave comments, you need to log in
by reply to a message
if event.object.text == "кик":
vk.method("messages.removeChatUser", {
"chat_id": event.object.peer_id - 2000000000,
"member_id": event.obj.reply_message['from_id']})
def get_user(pattern: str) -> int:
if "[id" in pattern:
return int(pattern.split("|")[0].replace("[id", ""))
if "vk.com/" in pattern:
domen = pattern.split("/")[-1]
print(domen)
return vk.method("users.get", {"user_ids": domen})[0]["id"]
text = event.obj["text"].split(' ')
if (len(text) == 2) and text[0] == "кик":
vk.method("messages.removeChatUser", {"chat_id": event.chat_id, "member_id": get_user(text[1])})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question