Olegos

Vk kick

Aug 13th, 2021 (edited)
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import vk_api
  2. import vk
  3. from vk_api.longpoll import VkLongPoll, VkEventType
  4.  
  5.  
  6. token = ''
  7.  
  8. vk_auth_token = vk_api.VkApi(token=token)
  9. longpoll = VkLongPoll(vk_auth_token)
  10. session = vk.Session(access_token=token)
  11. call = vk.API(session, v = "5.777")
  12.  
  13. my_id = call.users.get()[0]['id']
  14.  
  15. for event in longpoll.listen():
  16. try:
  17. if event.type == VkEventType.MESSAGE_NEW:
  18.  
  19. target_id = event.raw[6].get('mentions')
  20. from_id = int(event.raw[6].get('from'))
  21.  
  22. if from_id == my_id and target_id:
  23.  
  24. if event.text.startswith('.кик') :
  25. call.messages.send(peer_id=event.peer_id, message=f"кик нахой @id{target_id[0]}", disable_mentions=1, random_id=0)
  26. call.messages.removeChatUser(chat_id=event.peer_id-2000000000, member_id=target_id[0])
  27.  
  28. elif event.text.startswith('.верни'):
  29. call.messages.send(peer_id=event.peer_id, message=f"верни нахой @id{target_id[0]}", disable_mentions=1, random_id=0)
  30. call.messages.addChatUser(chat_id=event.peer_id-2000000000, user_id=target_id[0])
  31.  
  32. except Exception as error:
  33. print(error)
  34.  
Add Comment
Please, Sign In to add comment