Simple Async VKLibrary faster than vk_api
Project description
vkbee
Simple Async VKLibrary faster than vk_api
import aiohttp
import asyncio
import longpoll
import api
import time
async def main(loop):
token = "paste your token here"
vk = api.VkApi(token, loop=loop)
vk_poll = longpoll.BotLongpoll(vk, "group id paste here")
start_time = time.time()
event_count = 0
async for event in vk_poll.events():
data = {
'random_id': 0,
'peer_id': event['object']['message']['peer_id'],
'message': 'Pre-alpha check longpoll'
}
if event['object']['message']['peer_id'] < 2000000000:
if event['type'] == 'message_new':
asyncio.create_task(game.enter(event))
print('user')
print(event['object']['message']['peer_id'])
asyncio.create_task(vk.call('messages.send', data=data))
else:
print('chat')
event_count += 1
work_time = time.time() - start_time
print(f'All Events - {event_count}')
print(f'Work Time - {work_time}')
avr_time = work_time / event_count
speed = event_count / work_time
print(f'Events in Second - {speed}')
print(f'Average Time - {avr_time}')
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vkbee-0.3.tar.gz
(2.8 kB
view hashes)
Built Distribution
vkbee-0.3-py3-none-any.whl
(8.6 kB
view hashes)