File "C:\Users\admin\Desktop\bots_longpoll.py", line 44, in _lp_check
async with session.post(self.server, data=lp_data) as resp:
TypeError: Constructor parameter should be str
import aiohttp
import asyncio
class LongPoll:
def __init__(self, session, wait=25):
self.token = session[0]
self.grp_id = session[1]
self.v = session[-1]
self.wait = wait
self.url = 'https://api.vk.com/method/'
self.ts = None
self.server = None
self.key = None
self.__update_data()
async def __update_data(self, updts=True):
api_data = {
'access_token': self.token,
'v': self.v,
'group_id': self.grp_id
}
async with aiohttp.ClientSession() as session:
async with session.post(f"{self.url}groups.getLongPollServer?", data=api_data) as resp:
r = await resp.json()
self.server = r['response']['server']
self.key = r['response']['key']
if updts:
self.ts = r['response']['ts']
async def _lp_check(self):
lp_data = {
'act': 'a_check',
'key': self.key,
'wait': self.wait,
'mode': 2,
'ts': self.ts
}
async with aiohttp.ClientSession() as session:
async with session.post(self.server, data=lp_data) as resp:
r = await resp.json()
return r['updates']