From 3c3e8401db5243029b0888233bd78b4d40ec5005 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 15 Oct 2025 19:57:18 +0200 Subject: [PATCH] Message / Inline Buttons: Show mini-app icon for t.me links --- src/components/middle/message/InlineButtons.tsx | 14 ++++++++++---- src/global/actions/api/bots.ts | 10 ++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/middle/message/InlineButtons.tsx b/src/components/middle/message/InlineButtons.tsx index e7925800f..a9949165f 100644 --- a/src/components/middle/message/InlineButtons.tsx +++ b/src/components/middle/message/InlineButtons.tsx @@ -4,7 +4,7 @@ import { memo, useMemo } from '../../../lib/teact/teact'; import type { ApiKeyboardButton, ApiMessage } from '../../../api/types'; import type { ActionPayloads } from '../../../global/types'; -import { RE_TME_LINK } from '../../../config'; +import { RE_TME_LINK, TME_LINK_PREFIX } from '../../../config'; import renderKeyboardButtonText from '../composer/helpers/renderKeyboardButtonText'; import useOldLang from '../../../hooks/useOldLang'; @@ -26,10 +26,15 @@ const InlineButtons: FC = ({ message, onClick }) => { const { type } = button; switch (type) { case 'url': { - if (!RE_TME_LINK.test(button.url)) { + const { url } = button; + + if (url.startsWith(TME_LINK_PREFIX) && url.includes('?startapp')) { + return ; + } else if (!RE_TME_LINK.test(url)) { return ; } - break; + + return; } case 'urlAuth': return ; @@ -55,7 +60,8 @@ const InlineButtons: FC = ({ message, onClick }) => { } break; } - return undefined; + + return; }; const buttonTexts = useMemo(() => { diff --git a/src/global/actions/api/bots.ts b/src/global/actions/api/bots.ts index b5c9d0a1e..60ebe5941 100644 --- a/src/global/actions/api/bots.ts +++ b/src/global/actions/api/bots.ts @@ -108,23 +108,28 @@ addActionHandler('clickBotInlineButton', (global, actions, payload): ActionRetur case 'command': actions.sendBotCommand({ command: button.text, tabId }); break; + case 'url': { const { url } = button; actions.openUrl({ url, tabId, linkContext: { type: 'message', chatId, messageId, threadId } }); break; } + case 'copy': { copyTextToClipboard(button.copyText); actions.showNotification({ message: oldTranslate('ExactTextCopied', button.copyText), tabId }); break; } + case 'callback': { void answerCallbackButton(global, actions, chat, messageId, threadId, button.data, undefined, tabId); break; } + case 'requestPoll': actions.openPollModal({ isQuiz: button.isQuiz, tabId }); break; + case 'requestPhone': { const user = global.currentUserId ? selectUser(global, global.currentUserId) : undefined; if (!user) { @@ -141,6 +146,7 @@ addActionHandler('clickBotInlineButton', (global, actions, payload): ActionRetur }); break; } + case 'receipt': { const { receiptMessageId } = button; actions.getReceipt({ @@ -148,6 +154,7 @@ addActionHandler('clickBotInlineButton', (global, actions, payload): ActionRetur }); break; } + case 'buy': { actions.openInvoice({ type: 'message', @@ -157,10 +164,12 @@ addActionHandler('clickBotInlineButton', (global, actions, payload): ActionRetur }); break; } + case 'game': { void answerCallbackButton(global, actions, chat, messageId, threadId, undefined, true, tabId); break; } + case 'switchBotInline': { const { query, isSamePeer } = button; actions.switchBotInline({ @@ -207,6 +216,7 @@ addActionHandler('clickBotInlineButton', (global, actions, payload): ActionRetur }); break; } + case 'urlAuth': { const { url } = button; actions.requestBotUrlAuth({