A
A
AlexaAioGram2021-07-12 16:05:46
Python
AlexaAioGram, 2021-07-12 16:05:46

Why isn't a keyboard message sent by id?

@dp.message_handler(state=oprosnik.Q7, content_types=ContentTypes.TEXT)
async def vopros6(message: Message, state: FSMContext):
    kted = message.text
    if message.text.lower() not in kted:
        return
    gg = message.from_user.id
    await bot.send_message(chat_id=ADMIN, text=f'Опыт в сфере игр: {italic(kted)} ({gg}\n)',
                           parse_mode=ParseMode.MARKDOWN, reply_markup=item_all)

    await message.answer('✨Вы заполнили анкету, ждите ответа от модерации✨')
    await oprosnik.Q8.set()

    @dp.message_handler(state=oprosnik.Q8)
    async def qweqw(message: Message):
        if 'Принять заявку✅' in message.text:
            await message.bot.send_message(chat_id=gg, text='Вы приняты ✅', reply_markup=all_accept)
        elif 'Отклонить заявку' in message.text:
            await message.answer('Вам отклонили заявку')
            await oprosnik.Q9


Why is text and keyboard not passed to chat_id=gg?
Please solve, I've been toiling for more than 2 hours

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-07-12
@AlexaAioGram

2 hours is not enough)
do you have the qweqw function included in the vipros6 function ? if so, does it work at all when sending a message to the bot? As far as I understand it shouldn't.
And if you made a typo when composing the question, then the gg variable is simply not defined in this function. Store the value in state.
Try moving in this direction:

@dp.message_handler(state=oprosnik.Q7, content_types=ContentTypes.TEXT)
async def vopros6(message: Message, state: FSMContext):
    kted = message.text
    if message.text.lower() not in kted:
        return

    await state.update_data(gg=message.from_user.id)
    await bot.send_message(chat_id=ADMIN, text=f'Опыт в сфере игр: {italic(kted)} ({gg}\n)',
                           parse_mode=ParseMode.MARKDOWN, reply_markup=item_all)

    await message.answer('✨Вы заполнили анкету, ждите ответа от модерации✨')
    await oprosnik.Q8.set()

@dp.message_handler(state=oprosnik.Q8)
async def qweqw(message: Message, state: FSMContext):
    user_data = await state.get_data()
    gg = user_data['gg']
    if 'Принять заявку✅' in message.text:
        await message.bot.send_message(chat_id=gg, text='Вы приняты ✅', reply_markup=all_accept)
    elif 'Отклонить заявку' in message.text:
        await message.answer('Вам отклонили заявку')
        await oprosnik.Q9

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question