mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-11-27 14:36:52 +01:00
Add the ability to send messages with protected content.
This commit is contained in:
parent
8e637b482a
commit
6ec2104b81
@ -5249,8 +5249,9 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification) {
|
td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification,
|
||||||
return make_object<td_api::messageSendOptions>(disable_notification, false, false, nullptr);
|
bool protect_content) {
|
||||||
|
return make_object<td_api::messageSendOptions>(disable_notification, false, protect_content, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Result<td::vector<td_api::object_ptr<td_api::InputInlineQueryResult>>> Client::get_inline_query_results(
|
td::Result<td::vector<td_api::object_ptr<td_api::InputInlineQueryResult>>> Client::get_inline_query_results(
|
||||||
@ -6846,6 +6847,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
|||||||
auto reply_to_message_id = get_message_id(query.get(), "reply_to_message_id");
|
auto reply_to_message_id = get_message_id(query.get(), "reply_to_message_id");
|
||||||
auto allow_sending_without_reply = to_bool(query->arg("allow_sending_without_reply"));
|
auto allow_sending_without_reply = to_bool(query->arg("allow_sending_without_reply"));
|
||||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||||
|
auto protect_content = to_bool(query->arg("protect_content"));
|
||||||
// TRY_RESULT(reply_markup, get_reply_markup(query.get()));
|
// TRY_RESULT(reply_markup, get_reply_markup(query.get()));
|
||||||
auto reply_markup = nullptr;
|
auto reply_markup = nullptr;
|
||||||
TRY_RESULT(input_message_contents, get_input_message_contents(query.get(), "media"));
|
TRY_RESULT(input_message_contents, get_input_message_contents(query.get(), "media"));
|
||||||
@ -6853,9 +6855,10 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
|||||||
resolve_reply_markup_bot_usernames(
|
resolve_reply_markup_bot_usernames(
|
||||||
std::move(reply_markup), std::move(query),
|
std::move(reply_markup), std::move(query),
|
||||||
[this, chat_id = chat_id.str(), reply_to_message_id, allow_sending_without_reply, disable_notification,
|
[this, chat_id = chat_id.str(), reply_to_message_id, allow_sending_without_reply, disable_notification,
|
||||||
input_message_contents = std::move(input_message_contents)](object_ptr<td_api::ReplyMarkup> reply_markup,
|
protect_content, input_message_contents = std::move(input_message_contents)](
|
||||||
PromisedQueryPtr query) mutable {
|
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||||
auto on_success = [this, disable_notification, input_message_contents = std::move(input_message_contents),
|
auto on_success = [this, disable_notification, protect_content,
|
||||||
|
input_message_contents = std::move(input_message_contents),
|
||||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 reply_to_message_id,
|
reply_markup = std::move(reply_markup)](int64 chat_id, int64 reply_to_message_id,
|
||||||
PromisedQueryPtr query) mutable {
|
PromisedQueryPtr query) mutable {
|
||||||
auto it = yet_unsent_message_count_.find(chat_id);
|
auto it = yet_unsent_message_count_.find(chat_id);
|
||||||
@ -6863,8 +6866,9 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
|||||||
return query->set_retry_after_error(60);
|
return query->set_retry_after_error(60);
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(make_object<td_api::sendMessageAlbum>(chat_id, 0, reply_to_message_id,
|
send_request(
|
||||||
get_message_send_options(disable_notification),
|
make_object<td_api::sendMessageAlbum>(chat_id, 0, reply_to_message_id,
|
||||||
|
get_message_send_options(disable_notification, protect_content),
|
||||||
std::move(input_message_contents)),
|
std::move(input_message_contents)),
|
||||||
std::make_unique<TdOnSendMessageAlbumCallback>(this, std::move(query)));
|
std::make_unique<TdOnSendMessageAlbumCallback>(this, std::move(query)));
|
||||||
};
|
};
|
||||||
@ -8184,6 +8188,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
|||||||
auto reply_to_message_id = get_message_id(query.get(), "reply_to_message_id");
|
auto reply_to_message_id = get_message_id(query.get(), "reply_to_message_id");
|
||||||
auto allow_sending_without_reply = to_bool(query->arg("allow_sending_without_reply"));
|
auto allow_sending_without_reply = to_bool(query->arg("allow_sending_without_reply"));
|
||||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||||
|
auto protect_content = to_bool(query->arg("protect_content"));
|
||||||
auto r_reply_markup = get_reply_markup(query.get());
|
auto r_reply_markup = get_reply_markup(query.get());
|
||||||
if (r_reply_markup.is_error()) {
|
if (r_reply_markup.is_error()) {
|
||||||
return fail_query_with_error(std::move(query), 400, r_reply_markup.error().message());
|
return fail_query_with_error(std::move(query), 400, r_reply_markup.error().message());
|
||||||
@ -8193,9 +8198,10 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
|||||||
resolve_reply_markup_bot_usernames(
|
resolve_reply_markup_bot_usernames(
|
||||||
std::move(reply_markup), std::move(query),
|
std::move(reply_markup), std::move(query),
|
||||||
[this, chat_id = chat_id.str(), reply_to_message_id, allow_sending_without_reply, disable_notification,
|
[this, chat_id = chat_id.str(), reply_to_message_id, allow_sending_without_reply, disable_notification,
|
||||||
input_message_content = std::move(input_message_content)](object_ptr<td_api::ReplyMarkup> reply_markup,
|
protect_content, input_message_content = std::move(input_message_content)](
|
||||||
PromisedQueryPtr query) mutable {
|
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||||
auto on_success = [this, disable_notification, input_message_content = std::move(input_message_content),
|
auto on_success = [this, disable_notification, protect_content,
|
||||||
|
input_message_content = std::move(input_message_content),
|
||||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 reply_to_message_id,
|
reply_markup = std::move(reply_markup)](int64 chat_id, int64 reply_to_message_id,
|
||||||
PromisedQueryPtr query) mutable {
|
PromisedQueryPtr query) mutable {
|
||||||
auto it = yet_unsent_message_count_.find(chat_id);
|
auto it = yet_unsent_message_count_.find(chat_id);
|
||||||
@ -8204,7 +8210,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_request(make_object<td_api::sendMessage>(chat_id, 0, reply_to_message_id,
|
send_request(make_object<td_api::sendMessage>(chat_id, 0, reply_to_message_id,
|
||||||
get_message_send_options(disable_notification),
|
get_message_send_options(disable_notification, protect_content),
|
||||||
std::move(reply_markup), std::move(input_message_content)),
|
std::move(reply_markup), std::move(input_message_content)),
|
||||||
std::make_unique<TdOnSendMessageCallback>(this, std::move(query)));
|
std::make_unique<TdOnSendMessageCallback>(this, std::move(query)));
|
||||||
};
|
};
|
||||||
|
@ -412,7 +412,8 @@ class Client : public WebhookActor::Callback {
|
|||||||
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
|
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
|
||||||
const Query *query, td::JsonValue &&value) const;
|
const Query *query, td::JsonValue &&value) const;
|
||||||
|
|
||||||
static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification);
|
static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification,
|
||||||
|
bool protect_content);
|
||||||
|
|
||||||
static td::Result<td::vector<td::string>> get_poll_options(const Query *query);
|
static td::Result<td::vector<td::string>> get_poll_options(const Query *query);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user