mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-02 16:42:56 +01:00
Rebase: Add Client::check_reply_parameters.
This commit is contained in:
parent
49df33acd7
commit
1084ebd5c8
@ -5840,8 +5840,12 @@ void Client::check_message(td::Slice chat_id_str, int64 message_id, bool allow_e
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
void Client::check_message_thread(int64 chat_id, int64 message_thread_id, int64 reply_to_message_id,
|
void Client::check_reply_parameters(td::Slice chat_id_str, int64 reply_to_message_id, bool allow_sending_without_reply,
|
||||||
PromisedQueryPtr query, OnSuccess on_success) {
|
int64 message_thread_id, PromisedQueryPtr query, OnSuccess on_success) {
|
||||||
|
check_message(chat_id_str, reply_to_message_id, reply_to_message_id <= 0 || allow_sending_without_reply,
|
||||||
|
AccessRights::Write, "message to reply", std::move(query),
|
||||||
|
[this, message_thread_id, on_success = std::move(on_success)](int64 chat_id, int64 reply_to_message_id,
|
||||||
|
PromisedQueryPtr query) mutable {
|
||||||
if (message_thread_id <= 0) {
|
if (message_thread_id <= 0) {
|
||||||
return on_success(chat_id, 0, reply_to_message_id, std::move(query));
|
return on_success(chat_id, 0, reply_to_message_id, std::move(query));
|
||||||
}
|
}
|
||||||
@ -5860,7 +5864,9 @@ void Client::check_message_thread(int64 chat_id, int64 message_thread_id, int64
|
|||||||
|
|
||||||
send_request(make_object<td_api::getMessage>(chat_id, message_thread_id),
|
send_request(make_object<td_api::getMessage>(chat_id, message_thread_id),
|
||||||
td::make_unique<TdOnCheckMessageThreadCallback<OnSuccess>>(
|
td::make_unique<TdOnCheckMessageThreadCallback<OnSuccess>>(
|
||||||
this, chat_id, message_thread_id, reply_to_message_id, std::move(query), std::move(on_success)));
|
this, chat_id, message_thread_id, reply_to_message_id, std::move(query),
|
||||||
|
std::move(on_success)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
@ -9693,14 +9699,11 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
|||||||
[this, chat_id = chat_id.str(), message_thread_id, reply_to_message_id, allow_sending_without_reply, disable_notification,
|
[this, chat_id = chat_id.str(), message_thread_id, reply_to_message_id, allow_sending_without_reply, disable_notification,
|
||||||
protect_content, input_message_contents = std::move(input_message_contents), send_at = std::move(send_at)](
|
protect_content, input_message_contents = std::move(input_message_contents), send_at = std::move(send_at)](
|
||||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||||
auto on_success = [this, message_thread_id, disable_notification, protect_content,
|
auto on_success = [this, disable_notification, protect_content,
|
||||||
input_message_contents = std::move(input_message_contents),
|
input_message_contents = std::move(input_message_contents),
|
||||||
reply_markup = std::move(reply_markup), send_at = std::move(send_at)](int64 chat_id, int64 reply_to_message_id,
|
send_at = std::move(send_at),
|
||||||
PromisedQueryPtr query) mutable {
|
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||||
auto on_message_thread_checked = [this, disable_notification, protect_content,
|
int64 reply_to_message_id,
|
||||||
input_message_contents = std::move(input_message_contents),
|
|
||||||
reply_markup = std::move(reply_markup), send_at = std::move(send_at)](
|
|
||||||
int64 chat_id, int64 message_thread_id, int64 reply_to_message_id,
|
|
||||||
PromisedQueryPtr query) mutable {
|
PromisedQueryPtr query) mutable {
|
||||||
auto &count = yet_unsent_message_count_[chat_id];
|
auto &count = yet_unsent_message_count_[chat_id];
|
||||||
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
||||||
@ -9712,14 +9715,11 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
|||||||
send_request(
|
send_request(
|
||||||
make_object<td_api::sendMessageAlbum>(
|
make_object<td_api::sendMessageAlbum>(
|
||||||
chat_id, message_thread_id, get_input_message_reply_to(reply_to_message_id),
|
chat_id, message_thread_id, get_input_message_reply_to(reply_to_message_id),
|
||||||
get_message_send_options(disable_notification, protect_content, std::move(send_at)), std::move(input_message_contents)),
|
get_message_send_options(disable_notification, protect_content), std::move(send_at), std::move(input_message_contents)),
|
||||||
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
||||||
};
|
};
|
||||||
check_message_thread(chat_id, message_thread_id, reply_to_message_id, std::move(query),
|
check_reply_parameters(chat_id, reply_to_message_id, allow_sending_without_reply, message_thread_id,
|
||||||
std::move(on_message_thread_checked));
|
std::move(query), std::move(on_success));
|
||||||
};
|
|
||||||
check_message(chat_id, reply_to_message_id, reply_to_message_id <= 0 || allow_sending_without_reply,
|
|
||||||
AccessRights::Write, "message to reply", std::move(query), std::move(on_success));
|
|
||||||
});
|
});
|
||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
}
|
}
|
||||||
@ -11952,31 +11952,26 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
|||||||
[this, chat_id = chat_id.str(), message_thread_id, reply_to_message_id, allow_sending_without_reply, disable_notification,
|
[this, chat_id = chat_id.str(), message_thread_id, reply_to_message_id, allow_sending_without_reply, disable_notification,
|
||||||
protect_content, input_message_content = std::move(input_message_content), send_at = std::move(send_at)](
|
protect_content, input_message_content = std::move(input_message_content), send_at = std::move(send_at)](
|
||||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||||
auto on_success = [this, message_thread_id, disable_notification, protect_content,
|
auto on_success = [this, disable_notification, protect_content,
|
||||||
input_message_content = std::move(input_message_content),
|
input_message_content = std::move(input_message_content),
|
||||||
reply_markup = std::move(reply_markup), send_at = std::move(send_at)](int64 chat_id, int64 reply_to_message_id,
|
send_at = std::move(send_at),
|
||||||
|
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||||
|
int64 reply_to_message_id,
|
||||||
PromisedQueryPtr query) mutable {
|
PromisedQueryPtr query) mutable {
|
||||||
auto on_message_thread_checked =
|
|
||||||
[this, disable_notification, protect_content, input_message_content = std::move(input_message_content),
|
|
||||||
reply_markup = std::move(reply_markup), send_at = std::move(send_at)](int64 chat_id, int64 message_thread_id,
|
|
||||||
int64 reply_to_message_id, PromisedQueryPtr query) mutable {
|
|
||||||
auto &count = yet_unsent_message_count_[chat_id];
|
auto &count = yet_unsent_message_count_[chat_id];
|
||||||
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
||||||
return fail_query_flood_limit_exceeded(std::move(query));
|
return fail_query_flood_limit_exceeded(std::move(query));
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
send_request(
|
send_request(make_object<td_api::sendMessage>(chat_id, message_thread_id,
|
||||||
make_object<td_api::sendMessage>(chat_id, message_thread_id, get_input_message_reply_to(reply_to_message_id),
|
get_input_message_reply_to(reply_to_message_id),
|
||||||
get_message_send_options(disable_notification, protect_content, std::move(send_at)),
|
get_message_send_options(disable_notification, protect_content), std::move(send_at)),
|
||||||
std::move(reply_markup), std::move(input_message_content)),
|
std::move(reply_markup), std::move(input_message_content)),
|
||||||
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
||||||
};
|
};
|
||||||
check_message_thread(chat_id, message_thread_id, reply_to_message_id, std::move(query),
|
check_reply_parameters(chat_id, reply_to_message_id, allow_sending_without_reply, message_thread_id,
|
||||||
std::move(on_message_thread_checked));
|
std::move(query), std::move(on_success));
|
||||||
};
|
|
||||||
check_message(chat_id, reply_to_message_id, reply_to_message_id <= 0 || allow_sending_without_reply,
|
|
||||||
AccessRights::Write, "message to reply", std::move(query), std::move(on_success));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,8 +349,8 @@ class Client final : public WebhookActor::Callback {
|
|||||||
td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
void check_message_thread(int64 chat_id, int64 message_thread_id, int64 reply_to_message_id, PromisedQueryPtr query,
|
void check_reply_parameters(td::Slice chat_id_str, int64 reply_to_message_id, bool allow_sending_without_reply,
|
||||||
OnSuccess on_success);
|
int64 message_thread_id, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
void resolve_sticker_set(const td::string &sticker_set_name, PromisedQueryPtr query, OnSuccess on_success);
|
void resolve_sticker_set(const td::string &sticker_set_name, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
Loading…
Reference in New Issue
Block a user