mirror of
https://github.com/tdlib/telegram-bot-api
synced 2025-08-22 01:49:24 +00:00
Compare commits
13 Commits
6d1b62b51b
...
53e15345b0
Author | SHA1 | Date | |
---|---|---|---|
|
53e15345b0 | ||
|
282fdcc0e7 | ||
|
3719fdece3 | ||
|
21e04ed5df | ||
|
7d6ec7bccb | ||
|
faa458d041 | ||
|
d4323f5ac0 | ||
|
b65e207b71 | ||
|
e000e2610f | ||
|
86a7e2486b | ||
|
c443a14a23 | ||
|
bcc968d73c | ||
|
cb5ab75b55 |
@ -6,7 +6,7 @@ if (POLICY CMP0065)
|
|||||||
cmake_policy(SET CMP0065 NEW)
|
cmake_policy(SET CMP0065 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(TelegramBotApi VERSION 7.11 LANGUAGES CXX)
|
project(TelegramBotApi VERSION 8.0 LANGUAGES CXX)
|
||||||
|
|
||||||
if (POLICY CMP0069)
|
if (POLICY CMP0069)
|
||||||
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
||||||
|
2
td
2
td
@ -1 +1 @@
|
|||||||
Subproject commit 056963e48fa8d3f89556239c22d6ac843d3c8a5b
|
Subproject commit 66c4751742d2ca810033b289fc57ab4f83cfc833
|
@ -253,10 +253,14 @@ bool Client::init_methods() {
|
|||||||
methods_.emplace("createinvoicelink", &Client::process_create_invoice_link_query);
|
methods_.emplace("createinvoicelink", &Client::process_create_invoice_link_query);
|
||||||
methods_.emplace("getstartransactions", &Client::process_get_star_transactions_query);
|
methods_.emplace("getstartransactions", &Client::process_get_star_transactions_query);
|
||||||
methods_.emplace("refundstarpayment", &Client::process_refund_star_payment_query);
|
methods_.emplace("refundstarpayment", &Client::process_refund_star_payment_query);
|
||||||
|
methods_.emplace("edituserstarsubscription", &Client::process_edit_user_star_subscription_query);
|
||||||
|
methods_.emplace("getavailablegifts", &Client::process_get_available_gifts_query);
|
||||||
|
methods_.emplace("sendgift", &Client::process_send_gift_query);
|
||||||
methods_.emplace("setgamescore", &Client::process_set_game_score_query);
|
methods_.emplace("setgamescore", &Client::process_set_game_score_query);
|
||||||
methods_.emplace("getgamehighscores", &Client::process_get_game_high_scores_query);
|
methods_.emplace("getgamehighscores", &Client::process_get_game_high_scores_query);
|
||||||
methods_.emplace("answerwebappquery", &Client::process_answer_web_app_query_query);
|
methods_.emplace("answerwebappquery", &Client::process_answer_web_app_query_query);
|
||||||
methods_.emplace("answerinlinequery", &Client::process_answer_inline_query_query);
|
methods_.emplace("answerinlinequery", &Client::process_answer_inline_query_query);
|
||||||
|
methods_.emplace("savepreparedinlinemessage", &Client::process_save_prepared_inline_message_query);
|
||||||
methods_.emplace("answercallbackquery", &Client::process_answer_callback_query_query);
|
methods_.emplace("answercallbackquery", &Client::process_answer_callback_query_query);
|
||||||
methods_.emplace("answershippingquery", &Client::process_answer_shipping_query_query);
|
methods_.emplace("answershippingquery", &Client::process_answer_shipping_query_query);
|
||||||
methods_.emplace("answerprecheckoutquery", &Client::process_answer_pre_checkout_query_query);
|
methods_.emplace("answerprecheckoutquery", &Client::process_answer_pre_checkout_query_query);
|
||||||
@ -267,6 +271,7 @@ bool Client::init_methods() {
|
|||||||
methods_.emplace("editchatsubscriptioninvitelink", &Client::process_edit_chat_subscription_invite_link_query);
|
methods_.emplace("editchatsubscriptioninvitelink", &Client::process_edit_chat_subscription_invite_link_query);
|
||||||
methods_.emplace("revokechatinvitelink", &Client::process_revoke_chat_invite_link_query);
|
methods_.emplace("revokechatinvitelink", &Client::process_revoke_chat_invite_link_query);
|
||||||
methods_.emplace("getbusinessconnection", &Client::process_get_business_connection_query);
|
methods_.emplace("getbusinessconnection", &Client::process_get_business_connection_query);
|
||||||
|
methods_.emplace("setuseremojistatus", &Client::process_set_user_emoji_status_query);
|
||||||
methods_.emplace("getchat", &Client::process_get_chat_query);
|
methods_.emplace("getchat", &Client::process_get_chat_query);
|
||||||
methods_.emplace("setchatphoto", &Client::process_set_chat_photo_query);
|
methods_.emplace("setchatphoto", &Client::process_set_chat_photo_query);
|
||||||
methods_.emplace("deletechatphoto", &Client::process_delete_chat_photo_query);
|
methods_.emplace("deletechatphoto", &Client::process_delete_chat_photo_query);
|
||||||
@ -2084,6 +2089,15 @@ class Client::JsonSuccessfulPaymentBot final : public td::Jsonable {
|
|||||||
}
|
}
|
||||||
object("telegram_payment_charge_id", successful_payment_->telegram_payment_charge_id_);
|
object("telegram_payment_charge_id", successful_payment_->telegram_payment_charge_id_);
|
||||||
object("provider_payment_charge_id", successful_payment_->provider_payment_charge_id_);
|
object("provider_payment_charge_id", successful_payment_->provider_payment_charge_id_);
|
||||||
|
if (successful_payment_->is_recurring_) {
|
||||||
|
object("is_recurring", td::JsonTrue());
|
||||||
|
}
|
||||||
|
if (successful_payment_->is_first_recurring_) {
|
||||||
|
object("is_first_recurring", td::JsonTrue());
|
||||||
|
}
|
||||||
|
if (successful_payment_->subscription_until_date_ > 0) {
|
||||||
|
object("subscription_expiration_date", successful_payment_->subscription_until_date_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2644,17 +2658,17 @@ class Client::JsonInlineKeyboardButton final : public td::Jsonable {
|
|||||||
object("switch_inline_query_current_chat", type->query_);
|
object("switch_inline_query_current_chat", type->query_);
|
||||||
break;
|
break;
|
||||||
case td_api::targetChatChosen::ID: {
|
case td_api::targetChatChosen::ID: {
|
||||||
auto target_chat = static_cast<const td_api::targetChatChosen *>(type->target_chat_.get());
|
auto types = static_cast<const td_api::targetChatChosen *>(type->target_chat_.get())->types_.get();
|
||||||
if (target_chat->allow_user_chats_ && target_chat->allow_bot_chats_ && target_chat->allow_group_chats_ &&
|
if (types->allow_user_chats_ && types->allow_bot_chats_ && types->allow_group_chats_ &&
|
||||||
target_chat->allow_channel_chats_) {
|
types->allow_channel_chats_) {
|
||||||
object("switch_inline_query", type->query_);
|
object("switch_inline_query", type->query_);
|
||||||
} else {
|
} else {
|
||||||
object("switch_inline_query_chosen_chat", td::json_object([&](auto &o) {
|
object("switch_inline_query_chosen_chat", td::json_object([&](auto &o) {
|
||||||
o("query", type->query_);
|
o("query", type->query_);
|
||||||
o("allow_user_chats", td::JsonBool(target_chat->allow_user_chats_));
|
o("allow_user_chats", td::JsonBool(types->allow_user_chats_));
|
||||||
o("allow_bot_chats", td::JsonBool(target_chat->allow_bot_chats_));
|
o("allow_bot_chats", td::JsonBool(types->allow_bot_chats_));
|
||||||
o("allow_group_chats", td::JsonBool(target_chat->allow_group_chats_));
|
o("allow_group_chats", td::JsonBool(types->allow_group_chats_));
|
||||||
o("allow_channel_chats", td::JsonBool(target_chat->allow_channel_chats_));
|
o("allow_channel_chats", td::JsonBool(types->allow_channel_chats_));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4061,6 +4075,41 @@ class Client::JsonGameHighScore final : public td::Jsonable {
|
|||||||
const Client *client_;
|
const Client *client_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonGift final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
JsonGift(const td_api::gift *gift, const Client *client) : gift_(gift), client_(client) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("id", td::to_string(gift_->id_));
|
||||||
|
object("sticker", JsonSticker(gift_->sticker_.get(), client_));
|
||||||
|
object("star_count", gift_->star_count_);
|
||||||
|
if (gift_->total_count_ > 0) {
|
||||||
|
object("remaining_count", gift_->remaining_count_);
|
||||||
|
object("total_count", gift_->total_count_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::gift *gift_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Client::JsonGifts final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
JsonGifts(const td_api::gifts *gifts, const Client *client) : gifts_(gifts), client_(client) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("gifts",
|
||||||
|
td::json_array(gifts_->gifts_, [client = client_](auto &gift) { return JsonGift(gift.get(), client); }));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::gifts *gifts_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonMessageReactionUpdated final : public td::Jsonable {
|
class Client::JsonMessageReactionUpdated final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
JsonMessageReactionUpdated(const td_api::updateMessageReaction *update, const Client *client)
|
JsonMessageReactionUpdated(const td_api::updateMessageReaction *update, const Client *client)
|
||||||
@ -4226,6 +4275,21 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case td_api::botTransactionPurposeSubscription::ID: {
|
||||||
|
auto purpose = static_cast<const td_api::botTransactionPurposeSubscription *>(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_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (purpose->period_ > 0) {
|
||||||
|
object("subscription_period", purpose->period_);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -4240,10 +4304,24 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable {
|
|||||||
object("request_count", source->request_count_);
|
object("request_count", source->request_count_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case td_api::starTransactionPartnerUser::ID: {
|
||||||
|
auto source = static_cast<const td_api::starTransactionPartnerUser *>(source_);
|
||||||
|
if (source->purpose_->get_id() == td_api::userTransactionPurposeGiftSend::ID) {
|
||||||
|
object("type", "user");
|
||||||
|
object("user", JsonUser(source->user_id_, client_));
|
||||||
|
object(
|
||||||
|
"gift",
|
||||||
|
JsonGift(static_cast<const td_api::userTransactionPurposeGiftSend *>(source->purpose_.get())->gift_.get(),
|
||||||
|
client_));
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Receive " << to_string(*source_);
|
||||||
|
object("type", "other");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case td_api::starTransactionPartnerTelegram::ID:
|
case td_api::starTransactionPartnerTelegram::ID:
|
||||||
case td_api::starTransactionPartnerAppStore::ID:
|
case td_api::starTransactionPartnerAppStore::ID:
|
||||||
case td_api::starTransactionPartnerGooglePlay::ID:
|
case td_api::starTransactionPartnerGooglePlay::ID:
|
||||||
case td_api::starTransactionPartnerUser::ID:
|
|
||||||
case td_api::starTransactionPartnerBusiness::ID:
|
case td_api::starTransactionPartnerBusiness::ID:
|
||||||
case td_api::starTransactionPartnerChat::ID:
|
case td_api::starTransactionPartnerChat::ID:
|
||||||
LOG(ERROR) << "Receive " << to_string(*source_);
|
LOG(ERROR) << "Receive " << to_string(*source_);
|
||||||
@ -4407,6 +4485,20 @@ class Client::JsonSentWebAppMessage final : public td::Jsonable {
|
|||||||
const td_api::sentWebAppMessage *message_;
|
const td_api::sentWebAppMessage *message_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonPreparedInlineMessageId final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
explicit JsonPreparedInlineMessageId(const td_api::preparedInlineMessageId *message) : message_(message) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("id", message_->id_);
|
||||||
|
object("expiration_date", message_->expiration_date_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::preparedInlineMessageId *message_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::TdOnOkCallback final : public TdQueryCallback {
|
class Client::TdOnOkCallback final : public TdQueryCallback {
|
||||||
public:
|
public:
|
||||||
void on_result(object_ptr<td_api::Object> result) final {
|
void on_result(object_ptr<td_api::Object> result) final {
|
||||||
@ -5848,6 +5940,25 @@ class Client::TdOnAnswerWebAppQueryCallback final : public TdQueryCallback {
|
|||||||
PromisedQueryPtr query_;
|
PromisedQueryPtr query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::TdOnSavePreparedInlineMessageCallback final : public TdQueryCallback {
|
||||||
|
public:
|
||||||
|
explicit TdOnSavePreparedInlineMessageCallback(PromisedQueryPtr query) : query_(std::move(query)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(object_ptr<td_api::Object> result) final {
|
||||||
|
if (result->get_id() == td_api::error::ID) {
|
||||||
|
return fail_query_with_error(std::move(query_), move_object_as<td_api::error>(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK(result->get_id() == td_api::preparedInlineMessageId::ID);
|
||||||
|
auto message = move_object_as<td_api::preparedInlineMessageId>(result);
|
||||||
|
answer_query(JsonPreparedInlineMessageId(message.get()), std::move(query_));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PromisedQueryPtr query_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::TdOnGetUserChatBoostsCallback final : public TdQueryCallback {
|
class Client::TdOnGetUserChatBoostsCallback final : public TdQueryCallback {
|
||||||
public:
|
public:
|
||||||
TdOnGetUserChatBoostsCallback(Client *client, PromisedQueryPtr query) : client_(client), query_(std::move(query)) {
|
TdOnGetUserChatBoostsCallback(Client *client, PromisedQueryPtr query) : client_(client), query_(std::move(query)) {
|
||||||
@ -5868,6 +5979,28 @@ class Client::TdOnGetUserChatBoostsCallback final : public TdQueryCallback {
|
|||||||
PromisedQueryPtr query_;
|
PromisedQueryPtr query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::TdOnGetGiftsCallback final : public TdQueryCallback {
|
||||||
|
public:
|
||||||
|
TdOnGetGiftsCallback(const Client *client, PromisedQueryPtr query) : client_(client), query_(std::move(query)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(object_ptr<td_api::Object> result) final {
|
||||||
|
if (result->get_id() == td_api::error::ID) {
|
||||||
|
return fail_query_with_error(std::move(query_), move_object_as<td_api::error>(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK(result->get_id() == td_api::gifts::ID);
|
||||||
|
auto gifts = move_object_as<td_api::gifts>(result);
|
||||||
|
td::remove_if(gifts->gifts_,
|
||||||
|
[](const auto &gift) { return gift->total_count_ > 0 && gift->remaining_count_ == 0; });
|
||||||
|
answer_query(JsonGifts(gifts.get(), client_), std::move(query_));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const Client *client_;
|
||||||
|
PromisedQueryPtr query_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::TdOnReturnFileCallback final : public TdQueryCallback {
|
class Client::TdOnReturnFileCallback final : public TdQueryCallback {
|
||||||
public:
|
public:
|
||||||
TdOnReturnFileCallback(const Client *client, PromisedQueryPtr query) : client_(client), query_(std::move(query)) {
|
TdOnReturnFileCallback(const Client *client, PromisedQueryPtr query) : client_(client), query_(std::move(query)) {
|
||||||
@ -7554,7 +7687,7 @@ td::Result<Client::InputReplyParameters> Client::get_reply_parameters(td::JsonVa
|
|||||||
result.reply_in_chat_id = std::move(chat_id);
|
result.reply_in_chat_id = std::move(chat_id);
|
||||||
result.reply_to_message_id = as_tdlib_message_id(td::max(message_id, 0));
|
result.reply_to_message_id = as_tdlib_message_id(td::max(message_id, 0));
|
||||||
result.allow_sending_without_reply = allow_sending_without_reply;
|
result.allow_sending_without_reply = allow_sending_without_reply;
|
||||||
result.quote = td_api::make_object<td_api::inputTextQuote>(std::move(quote), quote_position);
|
result.quote = make_object<td_api::inputTextQuote>(std::move(quote), quote_position);
|
||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7700,7 +7833,8 @@ td::Result<td_api::object_ptr<td_api::inlineKeyboardButton>> Client::get_inline_
|
|||||||
TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query"));
|
TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query"));
|
||||||
return make_object<td_api::inlineKeyboardButton>(
|
return make_object<td_api::inlineKeyboardButton>(
|
||||||
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(
|
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(
|
||||||
switch_inline_query, td_api::make_object<td_api::targetChatChosen>(true, true, true, true)));
|
switch_inline_query,
|
||||||
|
make_object<td_api::targetChatChosen>(make_object<td_api::targetChatTypes>(true, true, true, true))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.has_field("switch_inline_query_chosen_chat")) {
|
if (object.has_field("switch_inline_query_chosen_chat")) {
|
||||||
@ -7715,15 +7849,15 @@ td::Result<td_api::object_ptr<td_api::inlineKeyboardButton>> Client::get_inline_
|
|||||||
TRY_RESULT(allow_channel_chats, switch_inline_query_object.get_optional_bool_field("allow_channel_chats"));
|
TRY_RESULT(allow_channel_chats, switch_inline_query_object.get_optional_bool_field("allow_channel_chats"));
|
||||||
return make_object<td_api::inlineKeyboardButton>(
|
return make_object<td_api::inlineKeyboardButton>(
|
||||||
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(
|
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(
|
||||||
query, td_api::make_object<td_api::targetChatChosen>(allow_user_chats, allow_bot_chats,
|
query, make_object<td_api::targetChatChosen>(make_object<td_api::targetChatTypes>(
|
||||||
allow_group_chats, allow_channel_chats)));
|
allow_user_chats, allow_bot_chats, allow_group_chats, allow_channel_chats))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.has_field("switch_inline_query_current_chat")) {
|
if (object.has_field("switch_inline_query_current_chat")) {
|
||||||
TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query_current_chat"));
|
TRY_RESULT(switch_inline_query, object.get_required_string_field("switch_inline_query_current_chat"));
|
||||||
return make_object<td_api::inlineKeyboardButton>(
|
return make_object<td_api::inlineKeyboardButton>(
|
||||||
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(
|
text, make_object<td_api::inlineKeyboardButtonTypeSwitchInline>(switch_inline_query,
|
||||||
switch_inline_query, td_api::make_object<td_api::targetChatCurrent>()));
|
make_object<td_api::targetChatCurrent>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object.has_field("login_url")) {
|
if (object.has_field("login_url")) {
|
||||||
@ -8205,7 +8339,7 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
|||||||
TRY_RESULT(is_flexible, object.get_optional_bool_field("is_flexible"));
|
TRY_RESULT(is_flexible, object.get_optional_bool_field("is_flexible"));
|
||||||
|
|
||||||
return make_object<td_api::inputMessageInvoice>(
|
return make_object<td_api::inputMessageInvoice>(
|
||||||
make_object<td_api::invoice>(currency, std::move(prices), max_tip_amount, std::move(suggested_tip_amounts),
|
make_object<td_api::invoice>(currency, std::move(prices), 0, max_tip_amount, std::move(suggested_tip_amounts),
|
||||||
td::string(), td::string(), false, need_name, need_phone_number,
|
td::string(), td::string(), false, need_name, need_phone_number,
|
||||||
need_email_address, need_shipping_address, send_phone_number_to_provider,
|
need_email_address, need_shipping_address, send_phone_number_to_provider,
|
||||||
send_email_address_to_provider, is_flexible),
|
send_email_address_to_provider, is_flexible),
|
||||||
@ -9854,12 +9988,13 @@ td::Result<td_api::object_ptr<td_api::inputMessageInvoice>> Client::get_input_me
|
|||||||
TRY_RESULT(paid_media_caption, get_formatted_text(query->arg("paid_media_caption").str(),
|
TRY_RESULT(paid_media_caption, get_formatted_text(query->arg("paid_media_caption").str(),
|
||||||
query->arg("paid_media_caption_parse_mode").str(),
|
query->arg("paid_media_caption_parse_mode").str(),
|
||||||
get_input_entities(query, "paid_media_caption_entities")));
|
get_input_entities(query, "paid_media_caption_entities")));
|
||||||
|
int32 subscription_period = get_integer_arg(query, "subscription_period", 0, 0);
|
||||||
|
|
||||||
return make_object<td_api::inputMessageInvoice>(
|
return make_object<td_api::inputMessageInvoice>(
|
||||||
make_object<td_api::invoice>(currency.str(), std::move(prices), max_tip_amount, std::move(suggested_tip_amounts),
|
make_object<td_api::invoice>(currency.str(), std::move(prices), subscription_period, max_tip_amount,
|
||||||
td::string(), td::string(), false, need_name, need_phone_number, need_email_address,
|
std::move(suggested_tip_amounts), td::string(), td::string(), false, need_name,
|
||||||
need_shipping_address, send_phone_number_to_provider, send_email_address_to_provider,
|
need_phone_number, need_email_address, need_shipping_address,
|
||||||
is_flexible),
|
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(),
|
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),
|
provider_token.str(), provider_data.str(), start_parameter.str(), std::move(paid_media),
|
||||||
std::move(paid_media_caption));
|
std::move(paid_media_caption));
|
||||||
@ -11147,7 +11282,18 @@ td::Status Client::process_delete_messages_query(PromisedQueryPtr &query) {
|
|||||||
|
|
||||||
td::Status Client::process_create_invoice_link_query(PromisedQueryPtr &query) {
|
td::Status Client::process_create_invoice_link_query(PromisedQueryPtr &query) {
|
||||||
TRY_RESULT(input_message_invoice, get_input_message_invoice(query.get()));
|
TRY_RESULT(input_message_invoice, get_input_message_invoice(query.get()));
|
||||||
send_request(make_object<td_api::createInvoiceLink>(std::move(input_message_invoice)),
|
auto business_connection_id = query->arg("business_connection_id").str();
|
||||||
|
if (!business_connection_id.empty()) {
|
||||||
|
check_business_connection(business_connection_id, std::move(query),
|
||||||
|
[this, input_message_invoice = std::move(input_message_invoice)](
|
||||||
|
const BusinessConnection *business_connection, PromisedQueryPtr query) mutable {
|
||||||
|
send_request(make_object<td_api::createInvoiceLink>(business_connection->id_,
|
||||||
|
std::move(input_message_invoice)),
|
||||||
|
td::make_unique<TdOnCreateInvoiceLinkCallback>(std::move(query)));
|
||||||
|
});
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
send_request(make_object<td_api::createInvoiceLink>(td::string(), std::move(input_message_invoice)),
|
||||||
td::make_unique<TdOnCreateInvoiceLinkCallback>(std::move(query)));
|
td::make_unique<TdOnCreateInvoiceLinkCallback>(std::move(query)));
|
||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
@ -11173,6 +11319,38 @@ td::Status Client::process_refund_star_payment_query(PromisedQueryPtr &query) {
|
|||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_edit_user_star_subscription_query(PromisedQueryPtr &query) {
|
||||||
|
TRY_RESULT(user_id, get_user_id(query.get()));
|
||||||
|
auto telegram_payment_charge_id = query->arg("telegram_payment_charge_id");
|
||||||
|
auto is_canceled = to_bool(query->arg("is_canceled"));
|
||||||
|
check_user_no_fail(
|
||||||
|
user_id, std::move(query),
|
||||||
|
[this, user_id, telegram_payment_charge_id = telegram_payment_charge_id.str(),
|
||||||
|
is_canceled](PromisedQueryPtr query) {
|
||||||
|
send_request(make_object<td_api::editUserStarSubscription>(user_id, telegram_payment_charge_id, is_canceled),
|
||||||
|
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
|
||||||
|
});
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_get_available_gifts_query(PromisedQueryPtr &query) {
|
||||||
|
send_request(make_object<td_api::getAvailableGifts>(), td::make_unique<TdOnGetGiftsCallback>(this, std::move(query)));
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_send_gift_query(PromisedQueryPtr &query) {
|
||||||
|
auto gift_id = td::to_integer<int64>(query->arg("gift_id"));
|
||||||
|
TRY_RESULT(user_id, get_user_id(query.get()));
|
||||||
|
TRY_RESULT(text, get_formatted_text(query->arg("text").str(), query->arg("text_parse_mode").str(),
|
||||||
|
get_input_entities(query.get(), "text_entities")));
|
||||||
|
check_user(user_id, std::move(query),
|
||||||
|
[this, gift_id, user_id, text = std::move(text)](PromisedQueryPtr query) mutable {
|
||||||
|
send_request(make_object<td_api::sendGift>(gift_id, user_id, std::move(text), false),
|
||||||
|
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
|
||||||
|
});
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
td::Status Client::process_set_game_score_query(PromisedQueryPtr &query) {
|
td::Status Client::process_set_game_score_query(PromisedQueryPtr &query) {
|
||||||
auto chat_id = query->arg("chat_id");
|
auto chat_id = query->arg("chat_id");
|
||||||
auto message_id = get_message_id(query.get());
|
auto message_id = get_message_id(query.get());
|
||||||
@ -11280,6 +11458,30 @@ td::Status Client::process_answer_inline_query_query(PromisedQueryPtr &query) {
|
|||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_save_prepared_inline_message_query(PromisedQueryPtr &query) {
|
||||||
|
TRY_RESULT(user_id, get_user_id(query.get()));
|
||||||
|
TRY_RESULT(result, get_inline_query_result(query.get(), bot_user_ids_));
|
||||||
|
auto allow_user_chats = to_bool(query->arg("allow_user_chats"));
|
||||||
|
auto allow_bot_chats = to_bool(query->arg("allow_bot_chats"));
|
||||||
|
auto allow_group_chats = to_bool(query->arg("allow_group_chats"));
|
||||||
|
auto allow_channel_chats = to_bool(query->arg("allow_channel_chats"));
|
||||||
|
auto types =
|
||||||
|
make_object<td_api::targetChatTypes>(allow_user_chats, allow_bot_chats, allow_group_chats, allow_channel_chats);
|
||||||
|
|
||||||
|
td::vector<object_ptr<td_api::InputInlineQueryResult>> results;
|
||||||
|
results.push_back(std::move(result));
|
||||||
|
|
||||||
|
resolve_inline_query_results_bot_usernames(
|
||||||
|
std::move(results), std::move(query),
|
||||||
|
[this, user_id, types = std::move(types)](td::vector<object_ptr<td_api::InputInlineQueryResult>> results,
|
||||||
|
PromisedQueryPtr query) mutable {
|
||||||
|
CHECK(results.size() == 1);
|
||||||
|
send_request(make_object<td_api::savePreparedInlineMessage>(user_id, std::move(results[0]), std::move(types)),
|
||||||
|
td::make_unique<TdOnSavePreparedInlineMessageCallback>(std::move(query)));
|
||||||
|
});
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
td::Status Client::process_answer_callback_query_query(PromisedQueryPtr &query) {
|
td::Status Client::process_answer_callback_query_query(PromisedQueryPtr &query) {
|
||||||
auto callback_query_id = td::to_integer<int64>(query->arg("callback_query_id"));
|
auto callback_query_id = td::to_integer<int64>(query->arg("callback_query_id"));
|
||||||
td::string text = query->arg("text").str();
|
td::string text = query->arg("text").str();
|
||||||
@ -11416,6 +11618,23 @@ td::Status Client::process_get_business_connection_query(PromisedQueryPtr &query
|
|||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::Status Client::process_set_user_emoji_status_query(PromisedQueryPtr &query) {
|
||||||
|
TRY_RESULT(user_id, get_user_id(query.get()));
|
||||||
|
auto emoji_status_custom_emoji_id = td::to_integer<int64>(query->arg("emoji_status_custom_emoji_id"));
|
||||||
|
auto emoji_status_expiration_date = td::to_integer<int32>(query->arg("emoji_status_expiration_date"));
|
||||||
|
check_user(
|
||||||
|
user_id, std::move(query),
|
||||||
|
[this, user_id, emoji_status_custom_emoji_id, emoji_status_expiration_date](PromisedQueryPtr query) mutable {
|
||||||
|
send_request(make_object<td_api::setUserEmojiStatus>(
|
||||||
|
user_id, emoji_status_custom_emoji_id == 0
|
||||||
|
? nullptr
|
||||||
|
: make_object<td_api::emojiStatus>(emoji_status_custom_emoji_id,
|
||||||
|
emoji_status_expiration_date)),
|
||||||
|
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
|
||||||
|
});
|
||||||
|
return td::Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
td::Status Client::process_get_chat_query(PromisedQueryPtr &query) {
|
td::Status Client::process_get_chat_query(PromisedQueryPtr &query) {
|
||||||
auto chat_id = query->arg("chat_id");
|
auto chat_id = query->arg("chat_id");
|
||||||
|
|
||||||
@ -14080,9 +14299,10 @@ td::int64 Client::get_same_chat_reply_to_message_id(const object_ptr<td_api::mes
|
|||||||
->old_background_message_id_;
|
->old_background_message_id_;
|
||||||
case td_api::messageGiveawayCompleted::ID:
|
case td_api::messageGiveawayCompleted::ID:
|
||||||
return static_cast<const td_api::messageGiveawayCompleted *>(message->content_.get())->giveaway_message_id_;
|
return static_cast<const td_api::messageGiveawayCompleted *>(message->content_.get())->giveaway_message_id_;
|
||||||
case td_api::messagePaymentSuccessful::ID:
|
case td_api::messagePaymentSuccessful::ID: {
|
||||||
UNREACHABLE();
|
const auto *content = static_cast<const td_api::messagePaymentSuccessful *>(message->content_.get());
|
||||||
return static_cast<int64>(0);
|
return content->invoice_chat_id_ == message->chat_id_ ? content->invoice_message_id_ : static_cast<int64>(0);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return static_cast<int64>(0);
|
return static_cast<int64>(0);
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,8 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonForumTopicEdited;
|
class JsonForumTopicEdited;
|
||||||
class JsonForumTopicInfo;
|
class JsonForumTopicInfo;
|
||||||
class JsonGameHighScore;
|
class JsonGameHighScore;
|
||||||
|
class JsonGift;
|
||||||
|
class JsonGifts;
|
||||||
class JsonMessageReactionUpdated;
|
class JsonMessageReactionUpdated;
|
||||||
class JsonMessageReactionCountUpdated;
|
class JsonMessageReactionCountUpdated;
|
||||||
class JsonBusinessConnection;
|
class JsonBusinessConnection;
|
||||||
@ -209,6 +211,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonWebhookInfo;
|
class JsonWebhookInfo;
|
||||||
class JsonStickerSet;
|
class JsonStickerSet;
|
||||||
class JsonSentWebAppMessage;
|
class JsonSentWebAppMessage;
|
||||||
|
class JsonPreparedInlineMessageId;
|
||||||
class JsonCustomJson;
|
class JsonCustomJson;
|
||||||
|
|
||||||
class TdOnOkCallback;
|
class TdOnOkCallback;
|
||||||
@ -247,12 +250,14 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class TdOnGetSupergroupMembersCallback;
|
class TdOnGetSupergroupMembersCallback;
|
||||||
class TdOnGetSupergroupMemberCountCallback;
|
class TdOnGetSupergroupMemberCountCallback;
|
||||||
class TdOnGetUserChatBoostsCallback;
|
class TdOnGetUserChatBoostsCallback;
|
||||||
|
class TdOnGetGiftsCallback;
|
||||||
class TdOnCreateInvoiceLinkCallback;
|
class TdOnCreateInvoiceLinkCallback;
|
||||||
class TdOnGetStarTransactionsQueryCallback;
|
class TdOnGetStarTransactionsQueryCallback;
|
||||||
class TdOnReplacePrimaryChatInviteLinkCallback;
|
class TdOnReplacePrimaryChatInviteLinkCallback;
|
||||||
class TdOnGetChatInviteLinkCallback;
|
class TdOnGetChatInviteLinkCallback;
|
||||||
class TdOnGetGameHighScoresCallback;
|
class TdOnGetGameHighScoresCallback;
|
||||||
class TdOnAnswerWebAppQueryCallback;
|
class TdOnAnswerWebAppQueryCallback;
|
||||||
|
class TdOnSavePreparedInlineMessageCallback;
|
||||||
class TdOnReturnFileCallback;
|
class TdOnReturnFileCallback;
|
||||||
class TdOnReturnStickerSetCallback;
|
class TdOnReturnStickerSetCallback;
|
||||||
class TdOnGetStickerSetPromiseCallback;
|
class TdOnGetStickerSetPromiseCallback;
|
||||||
@ -681,10 +686,14 @@ class Client final : public WebhookActor::Callback {
|
|||||||
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_star_transactions_query(PromisedQueryPtr &query);
|
td::Status process_get_star_transactions_query(PromisedQueryPtr &query);
|
||||||
td::Status process_refund_star_payment_query(PromisedQueryPtr &query);
|
td::Status process_refund_star_payment_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_edit_user_star_subscription_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_get_available_gifts_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_send_gift_query(PromisedQueryPtr &query);
|
||||||
td::Status process_set_game_score_query(PromisedQueryPtr &query);
|
td::Status process_set_game_score_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_game_high_scores_query(PromisedQueryPtr &query);
|
td::Status process_get_game_high_scores_query(PromisedQueryPtr &query);
|
||||||
td::Status process_answer_web_app_query_query(PromisedQueryPtr &query);
|
td::Status process_answer_web_app_query_query(PromisedQueryPtr &query);
|
||||||
td::Status process_answer_inline_query_query(PromisedQueryPtr &query);
|
td::Status process_answer_inline_query_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_save_prepared_inline_message_query(PromisedQueryPtr &query);
|
||||||
td::Status process_answer_callback_query_query(PromisedQueryPtr &query);
|
td::Status process_answer_callback_query_query(PromisedQueryPtr &query);
|
||||||
td::Status process_answer_shipping_query_query(PromisedQueryPtr &query);
|
td::Status process_answer_shipping_query_query(PromisedQueryPtr &query);
|
||||||
td::Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query);
|
td::Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query);
|
||||||
@ -695,6 +704,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
td::Status process_edit_chat_subscription_invite_link_query(PromisedQueryPtr &query);
|
td::Status process_edit_chat_subscription_invite_link_query(PromisedQueryPtr &query);
|
||||||
td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query);
|
td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_business_connection_query(PromisedQueryPtr &query);
|
td::Status process_get_business_connection_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_set_user_emoji_status_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_chat_query(PromisedQueryPtr &query);
|
td::Status process_get_chat_query(PromisedQueryPtr &query);
|
||||||
td::Status process_set_chat_photo_query(PromisedQueryPtr &query);
|
td::Status process_set_chat_photo_query(PromisedQueryPtr &query);
|
||||||
td::Status process_delete_chat_photo_query(PromisedQueryPtr &query);
|
td::Status process_delete_chat_photo_query(PromisedQueryPtr &query);
|
||||||
|
@ -165,7 +165,7 @@ int main(int argc, char *argv[]) {
|
|||||||
auto start_time = td::Time::now();
|
auto start_time = td::Time::now();
|
||||||
auto shared_data = std::make_shared<SharedData>();
|
auto shared_data = std::make_shared<SharedData>();
|
||||||
auto parameters = std::make_unique<ClientParameters>();
|
auto parameters = std::make_unique<ClientParameters>();
|
||||||
parameters->version_ = "7.11";
|
parameters->version_ = "8.0";
|
||||||
parameters->shared_data_ = shared_data;
|
parameters->shared_data_ = shared_data;
|
||||||
parameters->start_time_ = start_time;
|
parameters->start_time_ = start_time;
|
||||||
auto net_query_stats = td::create_net_query_stats();
|
auto net_query_stats = td::create_net_query_stats();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user