S
S
Snowdevil2021-06-22 15:57:57
Python
Snowdevil, 2021-06-22 15:57:57

How to make a kick from a conversation by a bot?

How to make it so that the admin could highlight a message and kick the user out of the conversation?

import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
import time

vk_session = vk_api.VkApi(token = '1adbd73f02bcfa805971facdaf137eff4b7c97af0edd3be7b409643e9c706c5f')
longpoll = VkLongPoll(vk_session)

def sender(id, text):
    vk_session.method('messages.send', {'chat_id' : id, 'message' : text, 'random_id' : 0})

for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW:
        if event.to_me:
            if event.from_chat:
                
                msg = event.text.lower()
                id = event.chat_id

                if msg == 'привет':
                    sender(id, 'Привет!')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question