mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 21:49:42 +03:00
Delete command
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from aiogram import Bot
|
from aiogram import Bot
|
||||||
|
|
||||||
from handlers.handler import Handler
|
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.edit_command import EditCommand
|
||||||
from handlers.message_handlers.info_command import InfoCommand
|
from handlers.message_handlers.info_command import InfoCommand
|
||||||
from handlers.message_handlers.newpost_command import (NewPostCommand,
|
from handlers.message_handlers.newpost_command import (NewPostCommand,
|
||||||
@@ -32,5 +33,6 @@ class AdminCommands(Handler):
|
|||||||
self.add_handlers([
|
self.add_handlers([
|
||||||
NewPostCommand,
|
NewPostCommand,
|
||||||
NewPostSoloCommand,
|
NewPostSoloCommand,
|
||||||
|
DeleteCommand,
|
||||||
ReplyToUserCommand
|
ReplyToUserCommand
|
||||||
])
|
])
|
||||||
|
|||||||
21
handlers/message_handlers/delete_command.py
Normal file
21
handlers/message_handlers/delete_command.py
Normal file
@@ -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('Пост удален')
|
||||||
Reference in New Issue
Block a user