From 55fd1c30af57593e15367a28c1ddf502f4c3db25 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 24 May 2019 14:48:10 +0300 Subject: [PATCH] Keep reply_markup in some forwarded messages. GitOrigin-RevId: 8059cf0b071edb6ac62eff5d77749080d48916c3 --- td/telegram/MessagesManager.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 99ee5dc6..aeda6e94 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18104,6 +18104,35 @@ Result> MessagesManager::forward_messages(DialogId to_dialog_i m->via_bot_user_id = forwarded_message->sender_user_id; } } + if (!to_secret && forwarded_message->reply_markup != nullptr && + forwarded_message->reply_markup->type == ReplyMarkup::Type::InlineKeyboard) { + bool need_reply_markup = true; + for (auto &row : forwarded_message->reply_markup->inline_keyboard) { + for (auto &button : row) { + if (button.type == InlineKeyboardButton::Type::Url || button.type == InlineKeyboardButton::Type::UrlAuth) { + // ok + continue; + } + if (m->via_bot_user_id.is_valid() && (button.type == InlineKeyboardButton::Type::SwitchInline || + button.type == InlineKeyboardButton::Type::SwitchInlineCurrentDialog)) { + // ok + continue; + } + + need_reply_markup = false; + } + } + if (need_reply_markup) { + m->reply_markup = make_unique(*forwarded_message->reply_markup); + for (auto &row : m->reply_markup->inline_keyboard) { + for (auto &button : row) { + if (button.type == InlineKeyboardButton::Type::SwitchInlineCurrentDialog) { + button.type = InlineKeyboardButton::Type::SwitchInline; + } + } + } + } + } result[i] = m->message_id; forwarded_messages.push_back(m);