@VAPORHOUSE

Почему бот на aiogram не реагирует на сообщение в группе?

Здравствуйте. У меня следующая проблема, работает все, кроме 3 хендлера, сообщение приходит в группу, но когда я реплеем отвечаю на него, ничего не происходит, делал print в этом хендлере, сообщение не доходит, в чем проблема?

class Support(StatesGroup):
    Question = State()
    Answer = State()

async def cmd_help(message: types.Message):
    await message.answer("Какой у вас вопрос?")
    await Support.Question.set()
    
async def process_question(message: types.Message, state: FSMContext):
    question = message.text
    user_id = message.from_user.id
    question_with_hashtag = f"{question} #id{user_id}"
    await bot.send_message(chat_id=-1001952596331, text=question_with_hashtag)
    async with state.proxy() as data:
        data['Answer'] = question_with_hashtag
    async with state.proxy() as data:
        printwithhashtag = data['Answer']
    print(printwithhashtag)
    await Support.Answer.set()
      
async def process_answer(message: types.Message, state: FSMContext):
    txt = message.text
    async with state.proxy() as data:
        questionwithhashtag = data['Answer'] 
    await state.finish()
    user_id = int(questionwithhashtag.split('#id')[1])
    print(user_id)
    await bot.send_message(chat_id=user_id, text=txt)
    await state.finish()

dp.register_message_handler(cmd_help, commands="help", state="*")
dp.register_message_handler(process_question, state=Support.Question)
dp.register_message_handler(process_answer, chat_type=[ChatType.GROUP, ChatType.SUPERGROUP], is_reply=True, state=Support.Answer)
  • Вопрос задан
  • 381 просмотр
Пригласить эксперта
Ответы на вопрос 1
@lamanoff
class Support(StatesGroup):
    Question = State()
    Answer = State()


async def cmd_help(message: types.Message):
    await message.answer("Какой у вас вопрос?")
    await Support.Question.set()


async def process_question(message: types.Message, state: FSMContext):
    question = message.text
    user_id = message.chat.id
    question_with_hashtag = f"{question} #id{user_id}"
    await bot.send_message(chat_id=user_id, text=question_with_hashtag)
    async with state.proxy() as data:
        data['Answer'] = question_with_hashtag
    async with state.proxy() as data:
        printwithhashtag = data['Answer']
    print(printwithhashtag)
    await Support.Answer.set()


async def process_answer(message: types.Message, state: FSMContext):
    txt = message.text
    async with state.proxy() as data:
        questionwithhashtag = data['Answer']
    await state.finish()
    user_id = int(questionwithhashtag.split('#id')[1])
    print(user_id)
    await bot.send_message(chat_id=user_id, text=txt)
    await state.finish()
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы