From d76c948b0638770b941a1496d6f70060c68d2007 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 27 Aug 2021 21:08:39 +0300 Subject: [PATCH] Bots: Support opening URLs from bot responses --- src/modules/actions/api/bots.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/actions/api/bots.ts b/src/modules/actions/api/bots.ts index 1341603f..c6e1fe3d 100644 --- a/src/modules/actions/api/bots.ts +++ b/src/modules/actions/api/bots.ts @@ -243,7 +243,7 @@ async function searchInlineBot({ chatId, query, offset, -} : { +}: { username: string; inlineBotData: InlineBotSettings; chatId: number; @@ -313,15 +313,18 @@ async function answerCallbackButton(chat: ApiChat, messageId: number, data: stri data, }); - if (!result || !result.message) { + if (!result) { return; } - const { message, alert: isError } = result; + const { showDialog, showNotification, toggleSafeLinkModal } = getDispatch(); + const { message, alert: isError, url } = result; if (isError) { - getDispatch().showDialog({ data: { message } }); - } else { - getDispatch().showNotification({ message }); + showDialog({ data: { message: message || 'Error' } }); + } else if (message) { + showNotification({ message }); + } else if (url) { + toggleSafeLinkModal({ url }); } }