mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 21:49:42 +03:00
Method for post/post
This commit is contained in:
@@ -178,9 +178,9 @@ class AdminCommands(Handler):
|
|||||||
|
|
||||||
@self.router.message(Command('post'))
|
@self.router.message(Command('post'))
|
||||||
async def post(message: types.Message):
|
async def post(message: types.Message):
|
||||||
posts = await neuroapi.post.get_will_post()
|
try:
|
||||||
if (posts):
|
post = await neuroapi.post.get_post_to_post()
|
||||||
post = await neuroapi.post.get(str(posts[0].uuid))
|
if (post):
|
||||||
images = MediaGroupBuilder(caption=post.text)
|
images = MediaGroupBuilder(caption=post.text)
|
||||||
image: neuroTypes.Image
|
image: neuroTypes.Image
|
||||||
for image in sorted(post.images, key=lambda x: x.message_id):
|
for image in sorted(post.images, key=lambda x: x.message_id):
|
||||||
@@ -189,6 +189,8 @@ class AdminCommands(Handler):
|
|||||||
await message.answer_media_group(images.build())
|
await message.answer_media_group(images.build())
|
||||||
else:
|
else:
|
||||||
await message.answer('Нет постов')
|
await message.answer('Нет постов')
|
||||||
|
except Exception as e:
|
||||||
|
await message.answer(f'Ошибка {e}')
|
||||||
|
|
||||||
@self.router.message(NewSoloPostFilter())
|
@self.router.message(NewSoloPostFilter())
|
||||||
async def post_solo(message: types.Message):
|
async def post_solo(message: types.Message):
|
||||||
|
|||||||
@@ -59,3 +59,13 @@ class Post(ApiMethod):
|
|||||||
if 'statusCode' in data:
|
if 'statusCode' in data:
|
||||||
raise Exception(data['message'])
|
raise Exception(data['message'])
|
||||||
return neuroTypes.Post.from_dict(data)
|
return neuroTypes.Post.from_dict(data)
|
||||||
|
|
||||||
|
async def get_post_to_post(self):
|
||||||
|
response = requests.get(self.api_url+f"/post/post")
|
||||||
|
data = response.json()
|
||||||
|
if 'statusCode' in data:
|
||||||
|
if response.status_code==404:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
raise Exception(data['message'])
|
||||||
|
return neuroTypes.Post.from_dict(data)
|
||||||
Reference in New Issue
Block a user