Home python python vk_api. How to catch a man's event from a conversation and...

python vk_api. How to catch a man’s event from a conversation and piss him?




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:
      # 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 ()
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:

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions