Advertisement
Olegos

Action in vk_api

Jun 16th, 2021
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import vk_api
  2. from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
  3.  
  4.  
  5.  
  6. vk_session = vk_api.VkApi(token='токен')
  7. vk = vk_session.get_api()
  8. longpoll = VkBotLongPoll(vk_session, vk.groups.getById()[0]['id'])
  9.  
  10. for event in longpoll.listen():
  11.     print(event.raw)
  12.     if event.type == VkBotEventType.MESSAGE_NEW:
  13.         if event.object.get('action'):
  14.             vk.messages.send(message='Привет', peer_id=event.peer_id, random_id=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement