diff --git a/td b/td index 056963e..66c4751 160000 --- a/td +++ b/td @@ -1 +1 @@ -Subproject commit 056963e48fa8d3f89556239c22d6ac843d3c8a5b +Subproject commit 66c4751742d2ca810033b289fc57ab4f83cfc833 diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 45564f2..e671d99 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -2644,17 +2644,17 @@ class Client::JsonInlineKeyboardButton final : public td::Jsonable { object("switch_inline_query_current_chat", type->query_); break; case td_api::targetChatChosen::ID: { - auto target_chat = static_cast(type->target_chat_.get()); - if (target_chat->allow_user_chats_ && target_chat->allow_bot_chats_ && target_chat->allow_group_chats_ && - target_chat->allow_channel_chats_) { + auto types = static_cast(type->target_chat_.get())->types_.get(); + if (types->allow_user_chats_ && types->allow_bot_chats_ && types->allow_group_chats_ && + types->allow_channel_chats_) { object("switch_inline_query", type->query_); } else { object("switch_inline_query_chosen_chat", td::json_object([&](auto &o) { o("query", type->query_); - o("allow_user_chats", td::JsonBool(target_chat->allow_user_chats_)); - o("allow_bot_chats", td::JsonBool(target_chat->allow_bot_chats_)); - o("allow_group_chats", td::JsonBool(target_chat->allow_group_chats_)); - o("allow_channel_chats", td::JsonBool(target_chat->allow_channel_chats_)); + o("allow_user_chats", td::JsonBool(types->allow_user_chats_)); + o("allow_bot_chats", td::JsonBool(types->allow_bot_chats_)); + o("allow_group_chats", td::JsonBool(types->allow_group_chats_)); + o("allow_channel_chats", td::JsonBool(types->allow_channel_chats_)); })); } break; @@ -4226,6 +4226,18 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable { } break; } + case td_api::botTransactionPurposeSubscription::ID: { + auto purpose = static_cast(source_user->purpose_.get()); + if (!purpose->invoice_payload_.empty()) { + if (!td::check_utf8(purpose->invoice_payload_)) { + LOG(WARNING) << "Receive non-UTF-8 invoice payload"; + object("invoice_payload", td::JsonRawString(purpose->invoice_payload_)); + } else { + object("invoice_payload", purpose->invoice_payload_); + } + } + break; + } default: UNREACHABLE(); } @@ -7554,7 +7566,7 @@ td::Result Client::get_reply_parameters(td::JsonVa result.reply_in_chat_id = std::move(chat_id); result.reply_to_message_id = as_tdlib_message_id(td::max(message_id, 0)); result.allow_sending_without_reply = allow_sending_without_reply; - result.quote = td_api::make_object(std::move(quote), quote_position); + result.quote = make_object(std::move(quote), quote_position); return std::move(result); } @@ -7700,7 +7712,8 @@ td::Result> Client::get_inline_ TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query")); return make_object( text, make_object( - switch_inline_query, td_api::make_object(true, true, true, true))); + switch_inline_query, + make_object(make_object(true, true, true, true)))); } if (object.has_field("switch_inline_query_chosen_chat")) { @@ -7715,15 +7728,15 @@ td::Result> Client::get_inline_ TRY_RESULT(allow_channel_chats, switch_inline_query_object.get_optional_bool_field("allow_channel_chats")); return make_object( text, make_object( - query, td_api::make_object(allow_user_chats, allow_bot_chats, - allow_group_chats, allow_channel_chats))); + query, make_object(make_object( + allow_user_chats, allow_bot_chats, allow_group_chats, allow_channel_chats)))); } if (object.has_field("switch_inline_query_current_chat")) { TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query_current_chat")); return make_object( - text, make_object( - switch_inline_query, td_api::make_object())); + text, make_object(switch_inline_query, + make_object())); } if (object.has_field("login_url")) { @@ -8205,7 +8218,7 @@ td::Result> Client::get_input_me TRY_RESULT(is_flexible, object.get_optional_bool_field("is_flexible")); return make_object( - make_object(currency, std::move(prices), max_tip_amount, std::move(suggested_tip_amounts), + make_object(currency, std::move(prices), 0, max_tip_amount, std::move(suggested_tip_amounts), td::string(), td::string(), false, need_name, need_phone_number, need_email_address, need_shipping_address, send_phone_number_to_provider, send_email_address_to_provider, is_flexible), @@ -9856,10 +9869,10 @@ td::Result> Client::get_input_me get_input_entities(query, "paid_media_caption_entities"))); return make_object( - make_object(currency.str(), std::move(prices), max_tip_amount, std::move(suggested_tip_amounts), - td::string(), td::string(), false, need_name, need_phone_number, need_email_address, - need_shipping_address, send_phone_number_to_provider, send_email_address_to_provider, - is_flexible), + make_object(currency.str(), std::move(prices), 0, max_tip_amount, + std::move(suggested_tip_amounts), td::string(), td::string(), false, need_name, + need_phone_number, need_email_address, need_shipping_address, + send_phone_number_to_provider, send_email_address_to_provider, is_flexible), title.str(), description.str(), photo_url.str(), photo_size, photo_width, photo_height, payload.str(), provider_token.str(), provider_data.str(), start_parameter.str(), std::move(paid_media), std::move(paid_media_caption)); @@ -11147,7 +11160,7 @@ td::Status Client::process_delete_messages_query(PromisedQueryPtr &query) { td::Status Client::process_create_invoice_link_query(PromisedQueryPtr &query) { TRY_RESULT(input_message_invoice, get_input_message_invoice(query.get())); - send_request(make_object(std::move(input_message_invoice)), + send_request(make_object(td::string(), std::move(input_message_invoice)), td::make_unique(std::move(query))); return td::Status::OK(); } @@ -14080,9 +14093,10 @@ td::int64 Client::get_same_chat_reply_to_message_id(const object_ptrold_background_message_id_; case td_api::messageGiveawayCompleted::ID: return static_cast(message->content_.get())->giveaway_message_id_; - case td_api::messagePaymentSuccessful::ID: - UNREACHABLE(); - return static_cast(0); + case td_api::messagePaymentSuccessful::ID: { + const auto *content = static_cast(message->content_.get()); + return content->invoice_chat_id_ == message->chat_id_ ? content->invoice_message_id_ : static_cast(0); + } default: return static_cast(0); }