diff --git a/handlers/admin_commands.py b/handlers/admin_commands.py index e3f3352..50fac78 100644 --- a/handlers/admin_commands.py +++ b/handlers/admin_commands.py @@ -1,6 +1,7 @@ from aiogram import Bot from handlers.handler import Handler +from handlers.message_handlers.delete_command import DeleteCommand from handlers.message_handlers.edit_command import EditCommand from handlers.message_handlers.info_command import InfoCommand from handlers.message_handlers.newpost_command import (NewPostCommand, @@ -32,5 +33,6 @@ class AdminCommands(Handler): self.add_handlers([ NewPostCommand, NewPostSoloCommand, + DeleteCommand, ReplyToUserCommand ]) diff --git a/handlers/message_handlers/delete_command.py b/handlers/message_handlers/delete_command.py new file mode 100644 index 0000000..c045a62 --- /dev/null +++ b/handlers/message_handlers/delete_command.py @@ -0,0 +1,21 @@ +from aiogram.filters import Command +from aiogram.types import Message + +from neuroapi import neuroapi + +from .handler import MessageHandlerABC + + +class DeleteCommand(MessageHandlerABC): + filter = Command('delete') + async def _command(self, message: Message): + text = message.text.split() + if len(text)!=2: + await message.answer('Неверное количество аргументов') + return + try: + await neuroapi.post.delete_by_order(text[1]) + except Exception as e: + await message.answer(f'Ошибка {e}') + return + await message.answer('Пост удален') \ No newline at end of file