tgbotxx  1.1.6.9
Telegram Bot C++ Library
ForumTopic.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct ForumTopic {
8  ForumTopic() = default;
9  explicit ForumTopic(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::int32_t messageThreadId{};
15 
17  std::string name;
18 
20  std::int32_t iconColor{};
21 
23  std::int32_t iconCustomEmojiId{};
24 
27  nl::json toJson() const {
28  nl::json json = nl::json::object();
29  OBJECT_SERIALIZE_FIELD(json, "message_thread_id", messageThreadId);
30  OBJECT_SERIALIZE_FIELD(json, "name", name);
31  OBJECT_SERIALIZE_FIELD(json, "icon_color", iconColor);
32  OBJECT_SERIALIZE_FIELD(json, "icon_custom_emoji_id", iconCustomEmojiId);
33  return json;
34  }
35 
37  void fromJson(const nl::json& json) {
38  OBJECT_DESERIALIZE_FIELD(json, "message_thread_id", messageThreadId, 0, false);
39  OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
40  OBJECT_DESERIALIZE_FIELD(json, "icon_color", iconColor, 0x000000, false);
41  OBJECT_DESERIALIZE_FIELD(json, "icon_custom_emoji_id", iconCustomEmojiId, 0, true);
42  }
43  };
44 }
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition: Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition: Object.hpp:44
Definition: Api.hpp:14
This object represents a forum topic. https://core.telegram.org/bots/api#forumtopic.
Definition: ForumTopic.hpp:7
ForumTopic(const nl::json &json)
Definition: ForumTopic.hpp:9
std::int32_t iconCustomEmojiId
Optional. Unique identifier of the custom emoji shown as the topic icon.
Definition: ForumTopic.hpp:23
std::int32_t messageThreadId
Unique identifier of the forum topic.
Definition: ForumTopic.hpp:14
std::int32_t iconColor
Color of the topic icon in RGB format.
Definition: ForumTopic.hpp:20
nl::json toJson() const
Serializes this object to JSON.
Definition: ForumTopic.hpp:27
std::string name
Name of the topic.
Definition: ForumTopic.hpp:17
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: ForumTopic.hpp:37