From caa1ae44367e65c8db7dde3607fa23af1259a454 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Nov 2023 16:39:36 +0400 Subject: [PATCH] Fix inline bots with secondary usernames. --- Telegram/SourceFiles/chat_helpers/message_field.cpp | 5 +---- Telegram/SourceFiles/history/history_widget.cpp | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 9c5b37751..475e87cb3 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -493,10 +493,7 @@ InlineBotQuery ParseInlineBotQuery( result.lookingUpBot = true; } } - if (result.lookingUpBot) { - result.query = QString(); - return result; - } else if (result.bot + if (result.bot && (!result.bot->isBot() || result.bot->botInfo->inlinePlaceholder.isEmpty())) { result.bot = nullptr; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index de130e3c1..0935f0865 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1393,9 +1393,7 @@ void HistoryWidget::updateInlineBotQuery() { _inlineBotResolveRequestId = _api.request(MTPcontacts_ResolveUsername( MTP_string(username) )).done([=](const MTPcontacts_ResolvedPeer &result) { - Expects(result.type() == mtpc_contacts_resolvedPeer); - - const auto &data = result.c_contacts_resolvedPeer(); + const auto &data = result.data(); const auto resolvedBot = [&]() -> UserData* { if (const auto user = session().data().processUsers( data.vusers())) { @@ -5198,7 +5196,7 @@ void HistoryWidget::updateFieldPlaceholder() { if (!_editMsgId && _inlineBot && !_inlineLookingUpBot) { _field->setPlaceholder( rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)), - _inlineBot->username().size() + 2); + _inlineBotUsername.size() + 2); return; }