1 #ifndef CPPGRAM_MESSAGE_HPP 2 #define CPPGRAM_MESSAGE_HPP 4 #include <experimental/optional> 12 #include "contact.hpp" 13 #include "document.hpp" 15 #include "location.hpp" 16 #include "message_entity.hpp" 17 #include "message_entity.hpp" 18 #include "sticker.hpp" 45 std::experimental::optional<User>
from;
69 std::experimental::optional<uint_fast32_t>
edit_date;
73 std::experimental::optional<std::string>
text;
79 std::experimental::optional<Audio>
audio;
82 std::experimental::optional<Document>
document;
84 std::experimental::optional<Game> game;
90 std::experimental::optional<Sticker>
sticker;
93 std::experimental::optional<Video>
video;
96 std::experimental::optional<Voice>
voice;
99 std::experimental::optional<Contact>
contact;
105 std::experimental::optional<Venue>
venue;
108 std::experimental::optional<std::string>
caption;
138 migrate_from_chat_id;
144 Message( Json::Value &json_message )
145 : message_id( json_message[
"message_id"].asUInt() )
146 , date( json_message[
"date"].asUInt() )
147 , chat( json_message[
"chat"] )
149 if ( !json_message[
"from"].isNull() )
151 from.emplace(
User( json_message[
"from"] ) );
154 if ( !json_message[
"forward_from"].isNull() )
156 forward_from.emplace(
User( json_message[
"forward_from"] ) );
157 forward_from_chat.emplace(
Chat( json_message[
"forward_from_chat"] ) );
158 forward_date.emplace( json_message[
"forward_date"].asUInt() );
161 if ( !json_message[
"reply_to_message"].isNull() )
164 = std::make_shared<Message>(
Message( json_message[
"reply_to_message"] ) );
168 reply_to_message =
nullptr;
171 if ( !json_message[
"edit_date"].isNull() )
173 edit_date.emplace( json_message[
"edit_date"].asUInt() );
176 if ( !json_message[
"text"].isNull() )
178 text.emplace( json_message[
"text"].asString() );
181 entities.reserve( json_message[
"entities"].size() );
182 if ( !json_message[
"entities"].isNull() )
184 for ( Json::Value &json_entity : json_message[
"entities"] )
190 if ( !json_message[
"audio"].isNull() )
192 audio.emplace(
Audio( json_message[
"audio"] ) );
194 else if ( !json_message[
"document"].isNull() )
196 document.emplace(
Document( json_message[
"document"] ) );
198 else if ( !json_message[
"game"].isNull() )
200 game.emplace(
Game( json_message[
"game"] ) );
202 else if ( !json_message[
"photo"].isNull() )
204 photo.reserve( json_message[
"photo"].size() );
205 for ( Json::Value &json_photo : json_message[
"photo"] )
207 photo.emplace_back(
PhotoSize( json_photo ) );
210 else if ( !json_message[
"sticker"].isNull() )
212 sticker.emplace(
Sticker( json_message[
"sticker"] ) );
214 else if ( !json_message[
"video"].isNull() )
216 video.emplace(
Video( json_message[
"video"] ) );
218 else if ( !json_message[
"voice"].isNull() )
220 voice.emplace(
Voice( json_message[
"voice"] ) );
222 else if ( !json_message[
"contact"].isNull() )
224 contact.emplace(
Contact( json_message[
"contact"] ) );
226 else if ( !json_message[
"location"].isNull() )
228 location.emplace(
Location( json_message[
"location"] ) );
230 else if ( !json_message[
"venue"].isNull() )
232 venue.emplace(
Venue( json_message[
"venue"] ) );
235 if ( !json_message[
"caption"].isNull() )
237 caption = json_message[
"caption"].asString();
240 if ( !json_message[
"new_chat_member"].isNull() )
242 new_chat_member.emplace(
User( json_message[
"new_chat_member"] ) );
246 if ( !json_message[
"left_chat_member"].isNull() )
248 left_chat_member.emplace(
User( json_message[
"left_chat_member"] ) );
251 if ( !json_message[
"new_chat_photo"].empty() )
253 new_chat_photo.reserve( json_message[
"new_chat_photo"].size() );
254 for ( Json::Value &json_photo : json_message[
"new_chat_photo"] )
256 new_chat_photo.push_back(
PhotoSize( json_photo ) );
260 if ( !json_message[
"delete_chat_photo"].isNull() )
264 else if ( !json_message[
"group_chat_created"].isNull() )
269 else if ( !json_message[
"supergroup_chat_created"].isNull() )
273 else if ( !json_message[
"channel_chat_created"].isNull() )
278 if ( !json_message[
"migrate_to_chat_id"].isNull() )
280 migrate_to_chat_id.emplace( json_message[
"migrate_to_chat_id"].asInt64() );
283 if ( !json_message[
"migrate_from_chat_id"].isNull() )
285 migrate_from_chat_id.emplace( json_message[
"migrate_from_chat_id"].asInt64() );
288 if ( !json_message[
"pinned_message"].isNull() )
290 pinned_message = std::make_shared<Message>(
Message( json_message[
"pinned_message"] ) );
std::experimental::optional< Contact > contact
Optional. Message is a shared contact, information about the contact
Definition: message.hpp:99
EServiceMessage
Service message received.
Definition: enums.hpp:101
std::experimental::optional< std::string > caption
Optional. Caption for the document, photo or video, 0-200 characters
Definition: message.hpp:108
uint_fast32_t date
Date the message was sent in Unix time.
Definition: message.hpp:48
Definition: enums.hpp:110
std::experimental::optional< User > forward_from
Optional. For forwarded messages, sender of the original message
Definition: message.hpp:54
std::vector< PhotoSize > new_chat_photo
Optional. A chat photo was change to this value.
Definition: message.hpp:122
std::shared_ptr< Message > reply_to_message
Optional. For replies, the original message. Note that the Message object in this field will not cont...
Definition: message.hpp:66
uint_fast32_t message_id
Unique message identifier.
Definition: message.hpp:42
A message send by user.
Definition: message.hpp:36
std::experimental::optional< Location > location
Optional. Message is a shared location, information about the location
Definition: message.hpp:102
This object represents a venue.
Definition: venue.hpp:21
std::experimental::optional< Sticker > sticker
Optional. Message is a sticker, information about the sticker
Definition: message.hpp:90
std::experimental::optional< Document > document
Optional. Message is a general file, information about the file
Definition: message.hpp:82
std::experimental::optional< std::string > new_chat_title
Optional. A chat title was changed to this value.
Definition: message.hpp:119
std::experimental::optional< Video > video
Optional. Message is a video, information about the video
Definition: message.hpp:93
std::experimental::optional< User > left_chat_member
Optional. A member was removed from the group, information about them (this member may be the bot its...
Definition: message.hpp:116
std::experimental::optional< uint_fast64_t > migrate_to_chat_id
Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
Definition: message.hpp:131
std::experimental::optional< User > new_chat_member
Optional. A new member was added to the group, information about them (this member may be the bot its...
Definition: message.hpp:112
std::experimental::optional< Venue > venue
Optional. Message is a venue, information about the venue
Definition: message.hpp:105
std::experimental::optional< std::string > text
Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters.
Definition: message.hpp:73
A photo or thumbnail.
Definition: photo_size.hpp:20
A video sent by user.
Definition: video.hpp:21
Entity in the message.
Definition: message_entity.hpp:24
std::vector< MessageEntity > entities
Optional. For text messages, an array of messageEntinty
Definition: message.hpp:76
A sticker.
Definition: sticker.hpp:21
std::experimental::optional< uint_fast32_t > forward_date
Optional. For forwarded messages, date the original message was sent in Unix time ...
Definition: message.hpp:62
std::experimental::optional< Audio > audio
Optional. Message is an audio file, information about the file
Definition: message.hpp:79
Definition: enums.hpp:107
std::experimental::optional< uint_fast32_t > edit_date
Optional. Date the message was last edited in Unix time
Definition: message.hpp:69
Definition: enums.hpp:116
This object represents a game.
Definition: game.hpp:18
std::experimental::optional< Chat > forward_from_chat
Optional. For messages forwarded from a channel, information about the original channel ...
Definition: message.hpp:58
std::experimental::optional< User > from
Optional. Sender, can be empty for messages sent to channels
Definition: message.hpp:45
EServiceMessage service_message
Service message.
Definition: message.hpp:125
Definition: enums.hpp:121
A location send by a user.
Definition: location.hpp:19
A document send by a user.
Definition: document.hpp:22
std::shared_ptr< Message > pinned_message
Optional. Specified message was pinned. Note that the Message object in this field will not contain f...
Definition: message.hpp:142
main namespace for Cppgram
Chat chat
Conversation the message belongs to.
Definition: message.hpp:51
Chat object.
Definition: chat.hpp:21
std::vector< PhotoSize > photo
Optional. Message is a photo, available sizes of the photo
Definition: message.hpp:87
Audio message sent by a user.
Definition: audio.hpp:20
std::experimental::optional< Voice > voice
Optional. Message is a voice message, information about the file
Definition: message.hpp:96
User object.
Definition: user.hpp:20