Skip to content

Commit 746f848

Browse files
authored
Merge pull request #240 from llnulldisk/master
Update to Bot API 6.3
2 parents 78d036f + 89fba68 commit 746f848

15 files changed

Lines changed: 842 additions & 198 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
99

1010
## State
1111

12-
- [x] Bot API 3.0 ~ 6.2
12+
- [x] Bot API 3.0 ~ 6.3
1313

1414

1515
## Sample

include/tgbot/Api.h

Lines changed: 213 additions & 78 deletions
Large diffs are not rendered by default.

include/tgbot/TgTypeParser.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "tgbot/types/WebAppData.h"
2727
#include "tgbot/types/ProximityAlertTriggered.h"
2828
#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
29+
#include "tgbot/types/ForumTopicCreated.h"
30+
#include "tgbot/types/ForumTopicClosed.h"
31+
#include "tgbot/types/ForumTopicReopened.h"
2932
#include "tgbot/types/VideoChatScheduled.h"
3033
#include "tgbot/types/VideoChatStarted.h"
3134
#include "tgbot/types/VideoChatEnded.h"
@@ -56,6 +59,7 @@
5659
#include "tgbot/types/ChatJoinRequest.h"
5760
#include "tgbot/types/ChatPermissions.h"
5861
#include "tgbot/types/ChatLocation.h"
62+
#include "tgbot/types/ForumTopic.h"
5963
#include "tgbot/types/BotCommand.h"
6064
#include "tgbot/types/BotCommandScope.h"
6165
#include "tgbot/types/BotCommandScopeDefault.h"
@@ -226,6 +230,15 @@ class TGBOT_API TgTypeParser {
226230
MessageAutoDeleteTimerChanged::Ptr parseJsonAndGetMessageAutoDeleteTimerChanged(const boost::property_tree::ptree& data) const;
227231
std::string parseMessageAutoDeleteTimerChanged(const MessageAutoDeleteTimerChanged::Ptr& object) const;
228232

233+
ForumTopicCreated::Ptr parseJsonAndGetForumTopicCreated(const boost::property_tree::ptree& data) const;
234+
std::string parseForumTopicCreated(const ForumTopicCreated::Ptr& object) const;
235+
236+
ForumTopicClosed::Ptr parseJsonAndGetForumTopicClosed(const boost::property_tree::ptree& data) const;
237+
std::string parseForumTopicClosed(const ForumTopicClosed::Ptr& object) const;
238+
239+
ForumTopicReopened::Ptr parseJsonAndGetForumTopicReopened(const boost::property_tree::ptree& data) const;
240+
std::string parseForumTopicReopened(const ForumTopicReopened::Ptr& object) const;
241+
229242
VideoChatScheduled::Ptr parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const;
230243
std::string parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const;
231244

@@ -316,6 +329,9 @@ class TGBOT_API TgTypeParser {
316329
ChatLocation::Ptr parseJsonAndGetChatLocation(const boost::property_tree::ptree& data) const;
317330
std::string parseChatLocation(const ChatLocation::Ptr& object) const;
318331

332+
ForumTopic::Ptr parseJsonAndGetForumTopic(const boost::property_tree::ptree& data) const;
333+
std::string parseForumTopic(const ForumTopic::Ptr& object) const;
334+
319335
BotCommand::Ptr parseJsonAndGetBotCommand(const boost::property_tree::ptree& data) const;
320336
std::string parseBotCommand(const BotCommand::Ptr& object) const;
321337

include/tgbot/types/Chat.h

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <cstdint>
99
#include <memory>
1010
#include <string>
11+
#include <vector>
1112

1213
namespace TgBot {
1314

@@ -33,8 +34,8 @@ class Chat {
3334
/**
3435
* @brief Unique identifier for this chat.
3536
*
36-
* This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
37-
* But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
37+
* This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
38+
* But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
3839
*/
3940
std::int64_t id;
4041

@@ -63,107 +64,142 @@ class Chat {
6364
*/
6465
std::string lastName;
6566

67+
/**
68+
* @brief Optional. True, if the supergroup chat is a forum (has topics enabled)
69+
*/
70+
bool isForum;
71+
6672
/**
6773
* @brief Optional. Chat photo.
74+
*
6875
* Returned only in Api::getChat.
6976
*/
7077
ChatPhoto::Ptr photo;
7178

79+
/**
80+
* @brief Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels.
81+
*
82+
* Returned only in Api::getChat.
83+
*/
84+
std::vector<std::string> activeUsernames;
85+
86+
/**
87+
* @brief Optional. Custom emoji identifier of emoji status of the other party in a private chat.
88+
*
89+
* Returned only in Api::getChat.
90+
*/
91+
std::string emojiStatusCustomEmojiId;
92+
7293
/**
7394
* @brief Optional. Bio of the other party in a private chat.
95+
*
7496
* Returned only in Api::getChat.
7597
*/
7698
std::string bio;
7799

78100
/**
79101
* @brief Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user.
102+
*
80103
* Returned only in Api::getChat.
81104
*/
82105
bool hasPrivateForwards;
83106

84107
/**
85108
* @brief Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
109+
*
86110
* Returned only in Api::getChat.
87111
*/
88112
bool hasRestrictedVoiceAndVideoMessages;
89113

90114
/**
91115
* @brief Optional. True, if users need to join the supergroup before they can send messages.
116+
*
92117
* Returned only in Api::getChat.
93118
*/
94119
bool joinToSendMessages;
95120

96121
/**
97122
* @brief Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators.
123+
*
98124
* Returned only in Api::getChat.
99125
*/
100126
bool joinByRequest;
101127

102128
/**
103129
* @brief Optional. Description, for groups, supergroups and channel chats.
130+
*
104131
* Returned only in Api::getChat.
105132
*/
106133
std::string description;
107134

108135
/**
109136
* @brief Optional. Primary invite link, for groups, supergroups and channel chats.
137+
*
110138
* Returned only in Api::getChat.
111139
*/
112140
std::string inviteLink;
113141

114142
/**
115143
* @brief Optional. The most recent pinned message (by sending date).
144+
*
116145
* Returned only in Api::getChat.
117146
*/
118147
std::shared_ptr<Message> pinnedMessage;
119148

120149
/**
121150
* @brief Optional. Default chat member permissions, for groups and supergroups.
151+
*
122152
* Returned only in Api::getChat.
123153
*/
124154
ChatPermissions::Ptr permissions;
125155

126156
/**
127157
* @brief Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds.
158+
*
128159
* Returned only in Api::getChat.
129160
*/
130161
std::int32_t slowModeDelay;
131162

132163
/**
133164
* @brief Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds.
165+
*
134166
* Returned only in Api::getChat.
135167
*/
136168
std::int32_t messageAutoDeleteTime;
137169

138170
/**
139171
* @brief Optional. True, if messages from the chat can't be forwarded to other chats.
172+
*
140173
* Returned only in Api::getChat.
141174
*/
142175
bool hasProtectedContent;
143176

144177
/**
145178
* @brief Optional. For supergroups, name of group sticker set.
179+
*
146180
* Returned only in Api::getChat.
147181
*/
148182
std::string stickerSetName;
149183

150184
/**
151185
* @brief Optional. True, if the bot can change the group sticker set.
186+
*
152187
* Returned only in Api::getChat.
153188
*/
154189
bool canSetStickerSet;
155190

156191
/**
157192
* @brief Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats.
158-
* Returned only in Api::getChat.
159193
*
160194
* This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
161195
* But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
196+
* Returned only in Api::getChat.
162197
*/
163198
std::int64_t linkedChatId;
164199

165200
/**
166201
* @brief Optional. For supergroups, the location to which the supergroup is connected.
202+
*
167203
* Returned only in Api::getChat.
168204
*/
169205
ChatLocation::Ptr location;

include/tgbot/types/ChatAdministratorRights.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ChatAdministratorRights {
2121

2222
/**
2323
* @brief True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
24+
*
2425
* Implied by any other administrator privilege
2526
*/
2627
bool canManageChat;
@@ -69,6 +70,11 @@ class ChatAdministratorRights {
6970
* @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only
7071
*/
7172
bool canPinMessages;
73+
74+
/**
75+
* @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
76+
*/
77+
bool canManageTopics;
7278
};
7379
}
7480

include/tgbot/types/ChatMemberAdministrator.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ChatMemberAdministrator : public ChatMember {
3535

3636
/**
3737
* @brief True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode.
38+
*
3839
* Implied by any other administrator privilege
3940
*/
4041
bool canManageChat;
@@ -45,7 +46,7 @@ class ChatMemberAdministrator : public ChatMember {
4546
bool canDeleteMessages;
4647

4748
/**
48-
* @brief rue, if the administrator can manage video chats
49+
* @brief True, if the administrator can manage video chats
4950
*/
5051
bool canManageVideoChats;
5152

@@ -84,6 +85,11 @@ class ChatMemberAdministrator : public ChatMember {
8485
*/
8586
bool canPinMessages;
8687

88+
/**
89+
* @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
90+
*/
91+
bool canManageTopics;
92+
8793
/**
8894
* @brief Optional. Custom title for this user
8995
*/

include/tgbot/types/ChatMemberRestricted.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace TgBot {
1010

1111
/**
1212
* @brief Represents a chat member that is under certain restrictions in the chat.
13+
*
1314
* Supergroups only.
1415
*
1516
* @ingroup types
@@ -40,10 +41,15 @@ class ChatMemberRestricted : public ChatMember {
4041
bool canInviteUsers;
4142

4243
/**
43-
* @brief True, if the user is allowed to pin messages; groups and supergroups only
44+
* @brief True, if the user is allowed to pin messages
4445
*/
4546
bool canPinMessages;
4647

48+
/**
49+
* @brief True, if the user is allowed to create forum topics
50+
*/
51+
bool canManageTopics;
52+
4753
/**
4854
* @brief True, if the user is allowed to send text messages, contacts, locations and venues
4955
*/
@@ -70,7 +76,9 @@ class ChatMemberRestricted : public ChatMember {
7076
bool canAddWebPagePreviews;
7177

7278
/**
73-
* @brief Date when restrictions will be lifted for this user; unix time
79+
* @brief Date when restrictions will be lifted for this user; unix time.
80+
*
81+
* If 0, then the user is restricted forever
7482
*/
7583
std::uint32_t untilDate;
7684
};

0 commit comments

Comments
 (0)