Files
neuro-reply-bot-reworked/handlers/message_handlers/reply_to_user.py
2024-02-15 16:58:37 +03:00

19 lines
896 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from aiogram import types
from handlers.filters.reply_to_user import ReplyToUser
from .handler import MessageHandlerABC
class ReplyToUserCommand(MessageHandlerABC):
"""Send reply to user from admins"""
filter = ReplyToUser()
async def _command(self, message: types.Message):
if message.reply_to_message.forward_from is None:
await message.reply('Пользователь стесняшка и не разрешает отвечать на его сообщения...')
else:
try:
await self.bot.send_message(message.reply_to_message.forward_from.id, f'Вам ответил админ:\n{message.text}', entities=message.entities)
await message.reply('Ваше сообщение было отправлено!')
except Exception as e:
await message.reply(f'Ошибка! "{e}"')