Hey! I have menu as keyboard with button 'Items'. I want to render list of items, when user press 'Items' button on menu. For now, I tried this:
bot.start((ctx) => {
console.log('Новый пользователь:', '@' + ctx.from.username, '(' + ctx.from.id + ')')
return ctx.reply('Привет! Хочешь взять в краткосрочную аренду помещение?', Markup.keyboard([
['Items']
])
.extra()
)
})
bot.hears('Items', async ({answerInlineQuery}) => {
let res = await axios.get('spaces')
let data = res.data.spaces.map((space) => {
const orderBtn = Markup.callbackButton('Заказать', 'order.' + space.id)
return {
type: 'article',
id: space.id,
title: space.title,
description: `(${space.area_m}) : ${space.full_address}`,
input_message_content: { message_text: 'Lol', parse_mode: 'Markdown' },
reply_markup: Markup.inlineKeyboard([orderBtn]),
}
})
if (res.data.status) {
return answerInlineQuery(data)
}
})
But it returns an error:
Error: Telegraf: "answerInlineQuery" isn't available for "message::text"
keyboard press produces not an inline query but just a text message that you need to process. It should be in ctx.update.message. And I think you should use ctx.reply to reply with a message.
Most helpful comment
keyboardpress produces not an inline query but just a text message that you need to process. It should be inctx.update.message. And I think you should usectx.replyto reply with a message.