aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-03 23:58:00 +0300
committerlevlam <levlam@telegram.org>2026-07-03 23:58:00 +0300
commitfe131c7a444fc43431f3bc888c7802e38aa8fca9 (patch)
tree289cf18f11739c78b3a42fadc6237d71d7ec61de
parent643f0ffdea033914dfebbb1211294059ef905605 (diff)
Add get_page_block_table_cell.
-rw-r--r--telegram-bot-api/Client.cpp39
-rw-r--r--telegram-bot-api/Client.h2
2 files changed, 41 insertions, 0 deletions
diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp
index 11e22b1..23a2e86 100644
--- a/telegram-bot-api/Client.cpp
+++ b/telegram-bot-api/Client.cpp
@@ -11996,6 +11996,45 @@ td::Result<td_api::object_ptr<td_api::pageBlockCaption>> Client::get_page_block_
}
}
+td::Result<td_api::object_ptr<td_api::pageBlockTableCell>> Client::get_page_block_table_cell(td::JsonValue &&value) {
+ if (value.type() != td::JsonValue::Type::Object) {
+ return td::Status::Error(400, "RichBlockTableCell must be an object");
+ }
+
+ auto &object = value.get_object();
+ TRY_RESULT(text, get_rich_text(object.extract_field("text")));
+ TRY_RESULT(is_header, object.get_optional_bool_field("is_header"));
+ TRY_RESULT(colspan, object.get_optional_int_field("colspan"));
+ TRY_RESULT(rowspan, object.get_optional_int_field("rowspan"));
+
+ object_ptr<td_api::PageBlockHorizontalAlignment> align;
+ TRY_RESULT(align_str, object.get_optional_string_field("align"));
+ if (align_str == "left" || (align_str.empty() && !is_header)) {
+ align = make_object<td_api::pageBlockHorizontalAlignmentLeft>();
+ } else if (align_str == "center" || (align_str.empty() && is_header)) {
+ align = make_object<td_api::pageBlockHorizontalAlignmentCenter>();
+ } else if (align_str == "right") {
+ align = make_object<td_api::pageBlockHorizontalAlignmentRight>();
+ } else {
+ return td::Status::Error(400, "Invalid horizontal alignment specified");
+ }
+
+ object_ptr<td_api::PageBlockVerticalAlignment> valign;
+ TRY_RESULT(valign_str, object.get_optional_string_field("valign"));
+ if (valign_str == "top") {
+ valign = make_object<td_api::pageBlockVerticalAlignmentTop>();
+ } else if (valign_str == "middle" || valign_str.empty()) {
+ valign = make_object<td_api::pageBlockVerticalAlignmentMiddle>();
+ } else if (valign_str == "bottom") {
+ valign = make_object<td_api::pageBlockVerticalAlignmentBottom>();
+ } else {
+ return td::Status::Error(400, "Invalid vertical alignment specified");
+ }
+
+ return make_object<td_api::pageBlockTableCell>(std::move(text), is_header, colspan, rowspan, std::move(align),
+ std::move(valign));
+}
+
td::Result<td_api::object_ptr<td_api::RichText>> Client::get_rich_text(td::JsonValue &&value) {
switch (value.type()) {
case td::JsonValue::Type::Null:
diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h
index 7a896a3..d32096f 100644
--- a/telegram-bot-api/Client.h
+++ b/telegram-bot-api/Client.h
@@ -666,6 +666,8 @@ class Client final : public WebhookActor::Callback {
static td::Result<object_ptr<td_api::pageBlockCaption>> get_page_block_caption(td::JsonValue &&value);
+ static td::Result<object_ptr<td_api::pageBlockTableCell>> get_page_block_table_cell(td::JsonValue &&value);
+
static td::Result<object_ptr<td_api::RichText>> get_rich_text(td::JsonValue &&value);
td::Result<object_ptr<td_api::inputRichMessage>> get_input_rich_message(const Query *query) const;