tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Chat.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct Chat {
8 Chat() = default;
9 explicit Chat(const nl::json& json);
10 virtual ~Chat() = default;
11
16 std::int64_t id{};
17
19 enum class Type : std::uint8_t {
20 Private = 0,
21 Group,
24 };
26 static std::optional<std::string> TypeToString(const Type type) noexcept;
28 static std::optional<Type> StringToType(const std::string& str) noexcept;
29
32
34 std::string title;
35
37 std::string username;
38
40 std::string firstName;
41
43 std::string lastName;
44
47 bool isForum{};
48
52
55 [[nodiscard]] virtual nl::json toJson() const;
56
58 virtual void fromJson(const nl::json& json);
59
60 private:
61 void _fromJson(const nl::json& json);
62 };
63}
This object represents a chat. https://core.telegram.org/bots/api#chat.
Definition Chat.hpp:7
static std::optional< std::string > TypeToString(const Type type) noexcept
Converts enum Type to a string.
std::string username
Optional. Username, for private chats, supergroups and channels if available.
Definition Chat.hpp:37
virtual ~Chat()=default
Type
Enum of possible types of Type.
Definition Chat.hpp:19
static std::optional< Type > StringToType(const std::string &str) noexcept
Converts string to an enum Type.
bool isForum
Optional. True, if the supergroup chat is a forum (has topics enabled) https://telegram....
Definition Chat.hpp:47
bool isDirectMessages
Optional. True, if the supergroup chat is a forum (has topics enabled) https://telegram....
Definition Chat.hpp:51
std::string lastName
Optional. Last name of the other party in a private chat.
Definition Chat.hpp:43
Chat(const nl::json &json)
Type type
Type of chat, can be either “private”, “group”, “supergroup” or “channel”
Definition Chat.hpp:31
std::string firstName
Optional. First name of the other party in a private chat.
Definition Chat.hpp:40
std::string title
Optional. Title, for supergroups, channels and group chats.
Definition Chat.hpp:34
Chat()=default
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
virtual nl::json toJson() const
Serializes this object to JSON.