mirror of
https://github.com/PaiGramTeam/telegram-bot-api.git
synced 2024-11-22 06:57:51 +00:00
Update TDLib and support allow_paid_broadcast option for message sending.
This commit is contained in:
parent
a9a3e7ba21
commit
ffb88dd220
2
td
2
td
@ -1 +1 @@
|
||||
Subproject commit d321984b75fccdb76239529e8aadcf7f80b0e35a
|
||||
Subproject commit 38560e87afd54f3840531fe25e12ce34a7eb279f
|
@ -6130,7 +6130,7 @@ void Client::send(PromisedQueryPtr query) {
|
||||
td::Time::now() > parameters_->start_time_ + 60) {
|
||||
BotStatActor *stat = stat_actor_.get_actor_unsafe();
|
||||
auto update_per_minute = static_cast<int64>(stat->get_minute_update_count(td::Time::now()) * 60);
|
||||
if (stat->get_active_request_count() > 500 + update_per_minute) {
|
||||
if (stat->get_active_request_count() > 1000 + update_per_minute) {
|
||||
LOG(INFO) << "Fail a query, because there are too many active queries: " << *query;
|
||||
return fail_query_flood_limit_exceeded(std::move(query));
|
||||
}
|
||||
@ -8209,9 +8209,11 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification,
|
||||
bool protect_content, int64 effect_id) {
|
||||
return make_object<td_api::messageSendOptions>(disable_notification, false, protect_content, false, nullptr,
|
||||
effect_id, 0, false);
|
||||
bool protect_content,
|
||||
bool allow_paid_broadcast,
|
||||
int64 effect_id) {
|
||||
return make_object<td_api::messageSendOptions>(disable_notification, false, protect_content, allow_paid_broadcast,
|
||||
false, nullptr, effect_id, 0, false);
|
||||
}
|
||||
|
||||
td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> Client::get_inline_query_results_button(
|
||||
@ -10676,10 +10678,11 @@ td::Status Client::process_copy_messages_query(PromisedQueryPtr &query) {
|
||||
auto message_count = message_ids.size();
|
||||
count += static_cast<int32>(message_count);
|
||||
|
||||
send_request(make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, 0), true, remove_caption),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
send_request(
|
||||
make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0), true, remove_caption),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
});
|
||||
};
|
||||
check_reply_parameters(chat_id, InputReplyParameters(), message_thread_id, std::move(query), std::move(on_success));
|
||||
@ -10732,7 +10735,7 @@ td::Status Client::process_forward_messages_query(PromisedQueryPtr &query) {
|
||||
|
||||
send_request(make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, 0), false, false),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0), false, false),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
});
|
||||
};
|
||||
@ -10748,6 +10751,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
auto business_connection_id = query->arg("business_connection_id");
|
||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto allow_paid_broadcast = to_bool(query->arg("allow_paid_broadcast"));
|
||||
auto effect_id = td::to_integer<int64>(query->arg("message_effect_id"));
|
||||
// TRY_RESULT(reply_markup, get_reply_markup(query.get(), bot_user_ids_));
|
||||
auto reply_markup = nullptr;
|
||||
@ -10756,9 +10760,9 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
resolve_reply_markup_bot_usernames(
|
||||
std::move(reply_markup), std::move(query),
|
||||
[this, chat_id_str = chat_id.str(), message_thread_id, business_connection_id = business_connection_id.str(),
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, effect_id,
|
||||
input_message_contents = std::move(input_message_contents)](object_ptr<td_api::ReplyMarkup> reply_markup,
|
||||
PromisedQueryPtr query) mutable {
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, input_message_contents = std::move(input_message_contents)](
|
||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||
if (!business_connection_id.empty()) {
|
||||
return check_business_connection_chat_id(
|
||||
business_connection_id, chat_id_str, std::move(query),
|
||||
@ -10774,7 +10778,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
});
|
||||
}
|
||||
|
||||
auto on_success = [this, disable_notification, protect_content, effect_id,
|
||||
auto on_success = [this, disable_notification, protect_content, allow_paid_broadcast, effect_id,
|
||||
input_message_contents = std::move(input_message_contents),
|
||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||
CheckedReplyParameters reply_parameters,
|
||||
@ -10786,11 +10790,12 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
auto message_count = input_message_contents.size();
|
||||
count += static_cast<int32>(message_count);
|
||||
|
||||
send_request(make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, effect_id),
|
||||
std::move(input_message_contents)),
|
||||
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
||||
send_request(
|
||||
make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast, effect_id),
|
||||
std::move(input_message_contents)),
|
||||
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
||||
};
|
||||
check_reply_parameters(chat_id_str, std::move(reply_parameters), message_thread_id, std::move(query),
|
||||
std::move(on_success));
|
||||
@ -12739,6 +12744,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
auto reply_parameters = r_reply_parameters.move_as_ok();
|
||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto allow_paid_broadcast = to_bool(query->arg("allow_paid_broadcast"));
|
||||
auto effect_id = td::to_integer<int64>(query->arg("message_effect_id"));
|
||||
auto r_reply_markup = get_reply_markup(query.get(), bot_user_ids_);
|
||||
if (r_reply_markup.is_error()) {
|
||||
@ -12749,9 +12755,9 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
resolve_reply_markup_bot_usernames(
|
||||
std::move(reply_markup), std::move(query),
|
||||
[this, chat_id_str = chat_id.str(), message_thread_id, business_connection_id = business_connection_id.str(),
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, effect_id,
|
||||
input_message_content = std::move(input_message_content)](object_ptr<td_api::ReplyMarkup> reply_markup,
|
||||
PromisedQueryPtr query) mutable {
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, input_message_content = std::move(input_message_content)](
|
||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||
if (!business_connection_id.empty()) {
|
||||
return check_business_connection_chat_id(
|
||||
business_connection_id, chat_id_str, std::move(query),
|
||||
@ -12767,7 +12773,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
});
|
||||
}
|
||||
|
||||
auto on_success = [this, disable_notification, protect_content, effect_id,
|
||||
auto on_success = [this, disable_notification, protect_content, allow_paid_broadcast, effect_id,
|
||||
input_message_content = std::move(input_message_content),
|
||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||
CheckedReplyParameters reply_parameters,
|
||||
@ -12778,11 +12784,12 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
}
|
||||
count++;
|
||||
|
||||
send_request(make_object<td_api::sendMessage>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, effect_id),
|
||||
std::move(reply_markup), std::move(input_message_content)),
|
||||
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
||||
send_request(
|
||||
make_object<td_api::sendMessage>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast, effect_id),
|
||||
std::move(reply_markup), std::move(input_message_content)),
|
||||
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
||||
};
|
||||
check_reply_parameters(chat_id_str, std::move(reply_parameters), message_thread_id, std::move(query),
|
||||
std::move(on_success));
|
||||
|
@ -590,7 +590,8 @@ class Client final : public WebhookActor::Callback {
|
||||
td::Result<object_ptr<td_api::inputMessageInvoice>> get_input_message_invoice(const Query *query) const;
|
||||
|
||||
static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification,
|
||||
bool protect_content, int64 effect_id);
|
||||
bool protect_content,
|
||||
bool allow_paid_broadcast, int64 effect_id);
|
||||
|
||||
static td::Result<td::vector<object_ptr<td_api::formattedText>>> get_poll_options(const Query *query);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user