tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
MessageOrigin.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
14 MessageOrigin() = default;
15 explicit MessageOrigin(const nl::json& json) {
17 }
18 virtual ~MessageOrigin() = default;
19
21 std::string type;
22
24 std::time_t date{};
25
28 virtual nl::json toJson() const {
29 nl::json json = nl::json::object();
32 return json;
33 }
34
36 virtual void fromJson(const nl::json& json) {
37 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
38 OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
39 }
40 };
41
46 type = "user";
47 }
48 explicit MessageOriginUser(const nl::json& json) {
50 }
51
54
55 nl::json toJson() const override {
56 nl::json json = MessageOrigin::toJson();
58 return json;
59 }
60
61 void fromJson(const nl::json& json) override {
63 OBJECT_DESERIALIZE_FIELD_PTR(json, "sender_user", senderUser, false);
64 }
65 };
66
67
72 type = "hidden_user";
73 }
77
79 std::string senderUserName;
80
81 nl::json toJson() const override {
82 nl::json json = MessageOrigin::toJson();
83 OBJECT_SERIALIZE_FIELD(json, "sender_user_name", senderUserName);
84 return json;
85 }
86
87 void fromJson(const nl::json& json) override {
89 OBJECT_DESERIALIZE_FIELD(json, "sender_user_name", senderUserName, "", false);
90 }
91 };
92
93
98 type = "chat";
99 }
100 explicit MessageOriginChat(const nl::json& json) {
102 }
103
106
108 std::string authorSignature;
109
110 nl::json toJson() const override {
111 nl::json json = MessageOrigin::toJson();
113 OBJECT_SERIALIZE_FIELD(json, "author_signature", authorSignature);
114 return json;
115 }
116
117 void fromJson(const nl::json& json) override {
119 OBJECT_DESERIALIZE_FIELD_PTR(json, "sender_chat", senderChat, false);
120 OBJECT_DESERIALIZE_FIELD(json, "author_signature", authorSignature, "", true);
121 }
122 };
123
128 type = "channel";
129 }
130 explicit MessageOriginChannel(const nl::json& json) {
132 }
133
136
138 std::int32_t messageId{};
139
141 std::string authorSignature;
142
143 nl::json toJson() const override {
144 nl::json json = MessageOrigin::toJson();
146 OBJECT_SERIALIZE_FIELD(json, "message_id", messageId);
147 OBJECT_SERIALIZE_FIELD(json, "author_signature", authorSignature);
148 return json;
149 }
150
151 void fromJson(const nl::json& json) override {
153 OBJECT_DESERIALIZE_FIELD_PTR(json, "chat", chat, false);
154 OBJECT_DESERIALIZE_FIELD(json, "message_id", messageId, 0, false);
155 OBJECT_DESERIALIZE_FIELD(json, "author_signature", authorSignature, "", true);
156 }
157 };
158}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#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:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
The message was originally sent to a channel chat. https://core.telegram.org/bots/api#messageoriginch...
Ptr< Chat > chat
Channel chat to which the message was originally sent.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string authorSignature
Optional. Signature of the original post author.
std::int32_t messageId
Unique message identifier inside the chat.
nl::json toJson() const override
Serializes this object to JSON.
MessageOriginChannel(const nl::json &json)
The message was originally sent on behalf of a chat to a group chat. https://core....
Ptr< Chat > senderChat
Chat that sent the message originally.
MessageOriginChat(const nl::json &json)
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string authorSignature
Optional. For messages originally sent by an anonymous chat administrator, original message author si...
The message was originally sent by an unknown user. https://core.telegram.org/bots/api#messageoriginh...
nl::json toJson() const override
Serializes this object to JSON.
MessageOriginHiddenUser(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string senderUserName
Name of the user that sent the message originally.
This object describes the origin of a message. It can be one of:
std::string type
Type of the message origin, one of "user", "hidden_user", "chat" or "channel".
std::time_t date
Date the message was sent originally in Unix time.
virtual ~MessageOrigin()=default
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
virtual nl::json toJson() const
Serializes this object to JSON.
MessageOrigin(const nl::json &json)
The message was originally sent by a known user. https://core.telegram.org/bots/api#messageoriginuser...
nl::json toJson() const override
Serializes this object to JSON.
Ptr< User > senderUser
User that sent the message originally.
MessageOriginUser(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.