Advertisement
Guest User

Untitled

a guest
Mar 11th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #!/usr/bin/python2
  2. # -*- coding: utf-8 -*-
  3. import vk_api
  4. from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
  5.  
  6.  
  7. def main():
  8.     """ Пример использования bots longpoll
  9.        https://vk.com/dev/bots_longpoll
  10.    """
  11.  
  12.     vk_session = vk_api.VkApi(token='тойкен')
  13.  
  14.     longpoll = VkBotLongPoll(vk_session, '161827083')
  15.  
  16.     for event in longpoll.listen():
  17.  
  18.         if event.type == VkBotEventType.MESSAGE_NEW:
  19.             print('New message:')
  20.  
  21.             print('To me: ', end='')
  22.  
  23.             print(event.obj.from_id)
  24.  
  25.             print('Text:', event.obj.text)
  26.             print()
  27.  
  28.  
  29. if __name__ == '__main__':
  30.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement