diff options
| author | levlam <levlam@telegram.org> | 2026-06-08 20:56:30 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-06-08 20:56:30 +0300 |
| commit | 2310208a697c294f312293f350ed5d01911efd0c (patch) | |
| tree | aff22fd7dd96946bcb086eb9b90ee6644b599faa | |
| parent | 405547b130f1e4acf36afef0eb766074323be7d9 (diff) | |
Add sendRichMessage.
| -rw-r--r-- | telegram-bot-api/Client.cpp | 17 | ||||
| -rw-r--r-- | telegram-bot-api/Client.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 5692f3f..f85e762 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -233,6 +233,7 @@ bool Client::init_methods() { methods_.emplace("getuserprofilephotos", &Client::process_get_user_profile_photos_query); methods_.emplace("getuserprofileaudios", &Client::process_get_user_profile_audios_query); methods_.emplace("sendmessage", &Client::process_send_message_query); + methods_.emplace("sendrichmessage", &Client::process_send_rich_message_query); methods_.emplace("sendanimation", &Client::process_send_animation_query); methods_.emplace("sendaudio", &Client::process_send_audio_query); methods_.emplace("senddice", &Client::process_send_dice_query); @@ -13056,6 +13057,22 @@ td::Status Client::process_send_message_query(PromisedQueryPtr &query) { return td::Status::OK(); } +td::Status Client::process_send_rich_message_query(PromisedQueryPtr &query) { + auto r_chat_id = td::to_integer_safe<int64>(query->arg("chat_id")); + if (r_chat_id.is_ok()) { + // fast path + auto it = yet_unsent_message_count_.find(r_chat_id.ok()); + if (it != yet_unsent_message_count_.end() && it->second >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) { + fail_query_flood_limit_exceeded(std::move(query)); + return td::Status::OK(); + } + } + + TRY_RESULT(rich_message, get_input_rich_message(query.get())); + do_send_message(make_object<td_api::inputMessageRichMessage>(std::move(rich_message), false), std::move(query)); + return td::Status::OK(); +} + td::Status Client::process_send_animation_query(PromisedQueryPtr &query) { auto animation = get_input_file(query.get(), "animation"); if (animation == nullptr) { diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 7391c18..1921959 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -798,6 +798,7 @@ class Client final : public WebhookActor::Callback { td::Status process_get_user_profile_photos_query(PromisedQueryPtr &query); td::Status process_get_user_profile_audios_query(PromisedQueryPtr &query); td::Status process_send_message_query(PromisedQueryPtr &query); + td::Status process_send_rich_message_query(PromisedQueryPtr &query); td::Status process_send_animation_query(PromisedQueryPtr &query); td::Status process_send_audio_query(PromisedQueryPtr &query); td::Status process_send_dice_query(PromisedQueryPtr &query); |
