Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- # -*- coding: utf-8 -*-
- import vk_api
- from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
- def main():
- """ Пример использования bots longpoll
- https://vk.com/dev/bots_longpoll
- """
- vk_session = vk_api.VkApi(token='тойкен')
- longpoll = VkBotLongPoll(vk_session, '161827083')
- for event in longpoll.listen():
- if event.type == VkBotEventType.MESSAGE_NEW:
- print('New message:')
- print('To me: ', end='')
- print(event.obj.from_id)
- print('Text:', event.obj.text)
- print()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement