ADDED: module for work with api

This commit is contained in:
2023-11-22 20:48:27 +05:00
parent d286da698e
commit ce940f7646
8 changed files with 124 additions and 0 deletions

14
neuroapi/image.py Normal file
View File

@@ -0,0 +1,14 @@
from aiohttp import ClientSession
from .api_method import ApiMethod
class Image(ApiMethod):
async def add(self, post_id: str, file_id: str, has_spoiler: bool, message_id: int):
payload = {'post_id': post_id, 'file_id': file_id,
'has_spoiler': has_spoiler, 'message_id': message_id}
async with ClientSession() as session:
response = await session.post(
self.api_url+'/image/add', data=payload)
data = await response.json()
if 'statusCode' in data:
raise Exception(data['message'])