From 15f1cf79da059ce5dc29807d22e0cfc29a22a328 Mon Sep 17 00:00:00 2001 From: GiovaniFZ Date: Fri, 6 Sep 2024 23:58:39 -0300 Subject: [PATCH] refactor: Mention user on inline_keyboard when user search for a device --- commands/gsmarena.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/gsmarena.js b/commands/gsmarena.js index 08e3149..2b01784 100644 --- a/commands/gsmarena.js +++ b/commands/gsmarena.js @@ -10,6 +10,7 @@ const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(is const axios = require('axios'); const { parse } = require('node-html-parser'); const { Markup } = require('telegraf'); +const { inlineKeyboard } = require('telegraf/markup'); class PhoneSearchResult { constructor(name, url) { @@ -201,10 +202,16 @@ module.exports = (bot) => { return Markup.button.callback(result.name, `details:${result.url}:${ctx.from.id}`); }); - ctx.reply(`${userName}, Select a device:`, Markup.inlineKeyboard(buttons, { columns: 2 }), { + const testUser = `${userName}, Select a device:`; + const options = { parse_mode: 'HTML', - disable_web_page_preview: true - }); + disable_web_page_preview: true, + reply_markup: { + inline_keyboard: results.map(result => [{ text: result.name, callback_data: result.url }]) + } + }; + ctx.reply(testUser, options); + }); bot.action(/details:(.+):(.+)/, async (ctx) => {