1 #ifndef CPPGRAM_CHAT_HPP 2 #define CPPGRAM_CHAT_HPP 4 #include <experimental/optional> 33 std::experimental::optional<std::string>
title,
43 Chat( Json::Value &json_chat )
44 : id( json_chat[
"id"].asInt64() )
46 if ( !json_chat[
"title"].isNull() )
48 title.emplace( json_chat[
"title"].asString() );
51 if ( !json_chat[
"username"].isNull() )
53 username.emplace( json_chat[
"username"].asString() );
56 if ( !json_chat[
"first_name"].isNull() )
58 first_name.emplace( json_chat[
"first_name"].asString() );
61 if ( !json_chat[
"last_name"].isNull() )
63 last_name.emplace( json_chat[
"last_name"].asString() );
66 if ( !json_chat[
"type"].isNull() )
68 std::vector<std::string> type_strings = {
"private",
"group",
"supergroup",
"channel"};
70 std::string chat_type = json_chat[
"type"].asString();
71 while ( i > 0 && chat_type.compare( type_strings[i] ) != 0 )
76 type =
static_cast<EChat>( i );
EChat type
Type of chat.
Definition: chat.hpp:30
int_fast64_t id
Unique identifier for this chat.
Definition: chat.hpp:27
EChat
Type of the chat.
Definition: enums.hpp:11
std::experimental::optional< std::string > title
Optional. Title, for supergroups, channels and group chats
Definition: chat.hpp:33
std::experimental::optional< std::string > first_name
Optional. First name of the other party in a private chat
Definition: chat.hpp:33
std::experimental::optional< std::string > username
Optional. Username, for private chats, supergroups and channels if available
Definition: chat.hpp:33
main namespace for Cppgram
std::experimental::optional< std::string > last_name
Optional. Last name of the other party in a private chat
Definition: chat.hpp:33
Chat object.
Definition: chat.hpp:21