Answer the question
In order to leave comments, you need to log in
Problem with VK_API\LONGPOLL. How to make an input?
In general, the request is easy, but not for me. There is code for long polle.
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
vk = vk_api.VkApi(token="toktoken")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, id)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
if event.object.text.lower() == "!kick ":
vk.method('messages.removeChatUser', {'chat_id': chat_id, 'user_id': member_id, 'member_id': member_id})
Answer the question
In order to leave comments, you need to log in
Well, note 1:
What you have == is an equals sign, but for your task you need something else
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
vk = vk_api.VkApi(token="toktoken")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, id)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
if "!kick " in event.object.text.lower(): #сюда надо бы добавить проверку кто это пишет, например если админ - выполнять или пропустить
user = event.object.text.lower().split(" ")[1] #И после этой строки получать всё необходимое для кика пользователя
vk.method('messages.removeChatUser', {'chat_id': chat_id, 'user_id': member_id, 'member_id': member_id})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question