mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 21:49:42 +03:00
Refactoring: handlers now implemented as classes. Module structure
This commit is contained in:
21
handlers/message_handlers/newpost_command.py
Normal file
21
handlers/message_handlers/newpost_command.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from aiogram import types
|
||||
|
||||
import neuroapi.types as neuroTypes
|
||||
from handlers.filters.new_post import NewPostFilter, NewSoloPostFilter
|
||||
from neuroapi import neuroapi
|
||||
|
||||
from .handler import MessageHandlerABC
|
||||
|
||||
|
||||
class NewPostCommand(MessageHandlerABC):
|
||||
filter = NewPostFilter()
|
||||
async def _command(self, message: types.Message):
|
||||
post: neuroTypes.Post = await neuroapi.post.get_by_media_group_id(message.media_group_id)
|
||||
await neuroapi.image.add(str(post.uuid), message.photo[-1].file_id, message.has_media_spoiler, message.message_id)
|
||||
|
||||
class NewPostSoloCommand(MessageHandlerABC):
|
||||
filter = NewSoloPostFilter()
|
||||
async def _command(self, message: types.Message):
|
||||
post: neuroTypes.Post = await neuroapi.post.new(message.caption.replace('/newpost ', ''), message.from_user.id, message_entities=message.caption_entities)
|
||||
await neuroapi.image.add(str(post.uuid), message.photo[-1].file_id, message.has_media_spoiler, message.message_id)
|
||||
await message.answer('Пост успешно добавлен!')
|
||||
Reference in New Issue
Block a user