I use vklongpoll from vk_api.longpool
Authorization with a token in the community
vk = vk_api.vkapi (token = token)
LongPoll = VklongPoll (VK)
Def Main_loop (Self) - & gt; None:
FOR EVENT IN SELF.LONGPOLL.LISTEN ():
# How to make a check on the exit from the conversation
# And then squeeze through removechatuser as I understand
How to catch this event and piss one who came out of the conversation?
Answer 1, Authority 100%
To begin with, it is worth saying that you use the wrong module. You need vk_api.bot_longpoll
.
Travele out a person out from the conversation by checking the message for the Action
key with the type chat_kick_user
.
Example (Python 3.8 +
):
from vk_api import vkapi
from vk_api.bot_longpoll import vkbotlongpoll, vkboteventtype
Access_Token = '' # Substitute your!
Group_id = # Substitute your!
vk_session = vkapi (token = access_token)
vk = vk_session.get_api ()
LongPoll = VKBOTLONGPOLL (VK_SESSION, GROUP_ID)
DEF Main ():
For event in longpoll.listen ():
If event.Type == vkboteventtype.Message_New and (Action: = event.obj ['Message']. Get ('action')):
If Action ['Type'] == 'Chat_Kick_user':
vk.messages.removechatUser (
Chat_id = event.chat_id,
user_id = action ['Member_ID'],
)
if __name__ == '__main__':
Main ()
Do not forget that the bot must issue a conversation administrator: