diff --git a/handlers/admin_commands.py b/handlers/admin_commands.py index cfc67f7..c18d882 100644 --- a/handlers/admin_commands.py +++ b/handlers/admin_commands.py @@ -76,6 +76,20 @@ class AdminCommands(Handler): "_", "\_").replace('.', '\.').replace(',', '\,').replace('!', '\!').replace('-', '\-').replace(':', '\:').replace('+', '\+'), parse_mode='markdownv2') await message.answer(res2, entities=posts_entities) + #TODO: Сделать изменение Message Entities + @self.router.message(Command('edit')) + async def edit_post_by_order_num(message: types.Message): + command = message.text.split(' ', 2) + print(command) + if len(command)<3: + await message.reply('Недостаточно аргементов!') + return + try: + await neuroapi.post.edit_text_by_order_num(command[1], command[2]) + await message.reply(f'Текст поста успешно изменен на: {command[2]}') + except Exception as e: + await message.reply(f'Ошибка: {e}') + """ TODO: Изменение постов сделать нормально, не через редактирование сообщений @self.router.message(ChangePosts()) diff --git a/neuroapi/_methods/post.py b/neuroapi/_methods/post.py index b9e3a84..7c91add 100644 --- a/neuroapi/_methods/post.py +++ b/neuroapi/_methods/post.py @@ -72,6 +72,13 @@ class Post(ApiMethod): raise Exception(data['message']) return neuroTypes.Post.from_dict(data) + async def edit_text_by_order_num(self, order: str, text: str): + response = requests.post(self.api_url + f"/post/edit-post-by-order-num/{order}", data={"text": text}) + data = response.json() + if 'statusCode' in data: + raise Exception(data['message']) + 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()