Skip to content

Commit c9ebca6

Browse files
authored
Merge pull request #264 from llnulldisk/master
Update to Bot API 6.5
2 parents 4356f74 + 3734bcc commit c9ebca6

17 files changed

Lines changed: 493 additions & 51 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.4
12+
- [x] Telegram Bot API 6.5
1313

1414

1515
## Sample

include/tgbot/Api.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ friend class Bot;
770770
* @brief Use this method to get basic information about a file and prepare it for downloading.
771771
*
772772
* For the moment, bots can download files of up to 20MB in size.
773-
* The file can then be downloaded via Api::downloadFile, where filePath is taken from the response.
773+
* The file can then be downloaded via Api::downloadFile or via the link https://api.telegram.org/file/bot<token>/<filePath>, where filePath is taken from the response.
774774
* It is guaranteed that the filePath will be valid for at least 1 hour.
775775
* When the link expires, a new one can be requested by calling Api::getFile again.
776776
*
@@ -823,20 +823,22 @@ friend class Bot;
823823
/**
824824
* @brief Use this method to restrict a user in a supergroup.
825825
*
826-
* The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights.
826+
* The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights.
827827
* Pass True for all permissions to lift restrictions from a user.
828828
*
829829
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
830830
* @param userId Unique identifier of the target user
831831
* @param permissions A JSON-serialized object for new user permissions
832832
* @param untilDate Optional. Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever
833+
* @param useIndependentChatPermissions Optional. Pass True if chat permissions are set independently. Otherwise, the canSendOtherMessages and canAddWebPagPreviews permissions will imply the canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, and canSendVoiceNotes permissions; the canSendPolls permission will imply the canSendMessages permission.
833834
*
834835
* @return Returns True on success.
835836
*/
836837
bool restrictChatMember(boost::variant<std::int64_t, std::string> chatId,
837838
std::int64_t userId,
838839
ChatPermissions::Ptr permissions,
839-
std::int64_t untilDate = 0) const;
840+
std::int64_t untilDate = 0,
841+
bool useIndependentChatPermissions = false) const;
840842

841843
/**
842844
* @brief Use this method to promote or demote a user in a supergroup or a channel.
@@ -852,7 +854,7 @@ friend class Bot;
852854
* @param canDeleteMessages Optional. Pass True if the administrator can delete messages of other users
853855
* @param canInviteUsers Optional. Pass True if the administrator can invite new users to the chat
854856
* @param canPinMessages Optional. Pass True if the administrator can pin messages, supergroups only
855-
* @param canPromoteMembers Optional. Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
857+
* @param canPromoteMembers Optional. Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)
856858
* @param isAnonymous Optional. Pass True if the administrator's presence in the chat is hidden
857859
* @param canManageChat Optional. Pass 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. Implied by any other administrator privilege
858860
* @param canManageVideoChats Optional. Pass True if the administrator can manage video chats
@@ -923,11 +925,13 @@ friend class Bot;
923925
*
924926
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
925927
* @param permissions A JSON-serialized object for new default chat permissions
928+
* @param useIndependentChatPermissions Optional. Pass True if chat permissions are set independently. Otherwise, the canSendOtherMessages and canAddWebPagPreviews permissions will imply the canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, and canSendVoiceNotes permissions; the canSendPolls permission will imply the canSendMessages permission.
926929
*
927930
* @return Returns True on success.
928931
*/
929932
bool setChatPermissions(boost::variant<std::int64_t, std::string> chatId,
930-
ChatPermissions::Ptr permissions) const;
933+
ChatPermissions::Ptr permissions,
934+
bool useIndependentChatPermissions = false) const;
931935

932936
/**
933937
* @brief Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked.
@@ -1157,7 +1161,7 @@ friend class Bot;
11571161
/**
11581162
* @brief Use this method to get information about a member of a chat.
11591163
*
1160-
* The method is guaranteed to work for other users, only if the bot is an administrator in the chat.
1164+
* The method is only guaranteed to work for other users if the bot is an administrator in the chat.
11611165
*
11621166
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
11631167
* @param userId Unique identifier of the target user
@@ -1207,7 +1211,7 @@ friend class Bot;
12071211
*
12081212
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
12091213
* @param name Topic name, 1-128 characters
1210-
* @param iconColor Optional. Color of the topic icon in RGB format. Currently, must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F
1214+
* @param iconColor Optional. Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)
12111215
* @param iconCustomEmojiId Optional. Unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers.
12121216
*
12131217
* @return Returns information about the created topic as a ForumTopic object.

include/tgbot/TgTypeParser.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "tgbot/types/ForumTopicReopened.h"
3333
#include "tgbot/types/GeneralForumTopicHidden.h"
3434
#include "tgbot/types/GeneralForumTopicUnhidden.h"
35+
#include "tgbot/types/UserShared.h"
36+
#include "tgbot/types/ChatShared.h"
3537
#include "tgbot/types/WriteAccessAllowed.h"
3638
#include "tgbot/types/VideoChatScheduled.h"
3739
#include "tgbot/types/VideoChatStarted.h"
@@ -42,6 +44,8 @@
4244
#include "tgbot/types/WebAppInfo.h"
4345
#include "tgbot/types/ReplyKeyboardMarkup.h"
4446
#include "tgbot/types/KeyboardButton.h"
47+
#include "tgbot/types/KeyboardButtonRequestUser.h"
48+
#include "tgbot/types/KeyboardButtonRequestChat.h"
4549
#include "tgbot/types/KeyboardButtonPollType.h"
4650
#include "tgbot/types/ReplyKeyboardRemove.h"
4751
#include "tgbot/types/InlineKeyboardMarkup.h"
@@ -252,6 +256,12 @@ class TGBOT_API TgTypeParser {
252256
GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const;
253257
std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const;
254258

259+
UserShared::Ptr parseJsonAndGetUserShared(const boost::property_tree::ptree& data) const;
260+
std::string parseUserShared(const UserShared::Ptr& object) const;
261+
262+
ChatShared::Ptr parseJsonAndGetChatShared(const boost::property_tree::ptree& data) const;
263+
std::string parseChatShared(const ChatShared::Ptr& object) const;
264+
255265
WriteAccessAllowed::Ptr parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const;
256266
std::string parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& object) const;
257267

@@ -282,6 +292,12 @@ class TGBOT_API TgTypeParser {
282292
KeyboardButton::Ptr parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const;
283293
std::string parseKeyboardButton(const KeyboardButton::Ptr& object) const;
284294

295+
KeyboardButtonRequestUser::Ptr parseJsonAndGetKeyboardButtonRequestUser(const boost::property_tree::ptree& data) const;
296+
std::string parseKeyboardButtonRequestUser(const KeyboardButtonRequestUser::Ptr& object) const;
297+
298+
KeyboardButtonRequestChat::Ptr parseJsonAndGetKeyboardButtonRequestChat(const boost::property_tree::ptree& data) const;
299+
std::string parseKeyboardButtonRequestChat(const KeyboardButtonRequestChat::Ptr& object) const;
300+
285301
KeyboardButtonPollType::Ptr parseJsonAndGetKeyboardButtonPollType(const boost::property_tree::ptree& data) const;
286302
std::string parseKeyboardButtonPollType(const KeyboardButtonPollType::Ptr& object) const;
287303

include/tgbot/types/ChatAdministratorRights.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ChatAdministratorRights {
4242
bool canRestrictMembers;
4343

4444
/**
45-
* @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
45+
* @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)
4646
*/
4747
bool canPromoteMembers;
4848

include/tgbot/types/ChatJoinRequest.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef TGBOT_CPP_CHATJOINREQUEST_H
2-
#define TGBOT_CPP_CHATJOINREQUEST_H
1+
#ifndef TGBOT_CHATJOINREQUEST_H
2+
#define TGBOT_CHATJOINREQUEST_H
33

44
#include "tgbot/types/Chat.h"
55
#include "tgbot/types/User.h"
@@ -31,6 +31,16 @@ class ChatJoinRequest {
3131
*/
3232
User::Ptr from;
3333

34+
/**
35+
* @brief Identifier of a private chat with the user who sent the join request.
36+
*
37+
* The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user.
38+
*
39+
* This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
40+
* But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
41+
*/
42+
std::int64_t userChatId;
43+
3444
/**
3545
* @brief Date the request was sent in Unix time
3646
*/
@@ -48,4 +58,4 @@ class ChatJoinRequest {
4858
};
4959
}
5060

51-
#endif //TGBOT_CPP_CHATJOINREQUEST_H
61+
#endif //TGBOT_CHATJOINREQUEST_H

include/tgbot/types/ChatMemberAdministrator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ChatMemberAdministrator : public ChatMember {
5656
bool canRestrictMembers;
5757

5858
/**
59-
* @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
59+
* @brief True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)
6060
*/
6161
bool canPromoteMembers;
6262

include/tgbot/types/ChatMemberRestricted.h

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,39 @@ class ChatMemberRestricted : public ChatMember {
3131
bool isMember;
3232

3333
/**
34-
* @brief True, if the user is allowed to change the chat title, photo and other settings
34+
* @brief True, if the user is allowed to send text messages, contacts, invoices, locations and venues
3535
*/
36-
bool canChangeInfo;
36+
bool canSendMessages;
3737

3838
/**
39-
* @brief True, if the user is allowed to invite new users to the chat
39+
* @brief True, if the user is allowed to send audios
4040
*/
41-
bool canInviteUsers;
41+
bool canSendAudios;
4242

4343
/**
44-
* @brief True, if the user is allowed to pin messages
44+
* @brief True, if the user is allowed to send documents
4545
*/
46-
bool canPinMessages;
46+
bool canSendDocuments;
4747

4848
/**
49-
* @brief True, if the user is allowed to create forum topics
49+
* @brief True, if the user is allowed to send photos
5050
*/
51-
bool canManageTopics;
51+
bool canSendPhotos;
5252

5353
/**
54-
* @brief True, if the user is allowed to send text messages, contacts, locations and venues
54+
* @brief True, if the user is allowed to send videos
5555
*/
56-
bool canSendMessages;
56+
bool canSendVideos;
57+
58+
/**
59+
* @brief True, if the user is allowed to send video notes
60+
*/
61+
bool canSendVideoNotes;
5762

5863
/**
59-
* @brief True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
64+
* @brief True, if the user is allowed to send voice notes
6065
*/
61-
bool canSendMediaMessages;
66+
bool canSendVoiceNotes;
6267

6368
/**
6469
* @brief True, if the user is allowed to send polls
@@ -75,6 +80,26 @@ class ChatMemberRestricted : public ChatMember {
7580
*/
7681
bool canAddWebPagePreviews;
7782

83+
/**
84+
* @brief True, if the user is allowed to change the chat title, photo and other settings
85+
*/
86+
bool canChangeInfo;
87+
88+
/**
89+
* @brief True, if the user is allowed to invite new users to the chat
90+
*/
91+
bool canInviteUsers;
92+
93+
/**
94+
* @brief True, if the user is allowed to pin messages
95+
*/
96+
bool canPinMessages;
97+
98+
/**
99+
* @brief True, if the user is allowed to create forum topics
100+
*/
101+
bool canManageTopics;
102+
78103
/**
79104
* @brief Date when restrictions will be lifted for this user; unix time.
80105
*

include/tgbot/types/ChatPermissions.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,39 @@ class ChatPermissions {
1616
typedef std::shared_ptr<ChatPermissions> Ptr;
1717

1818
/**
19-
* @brief Optional. True, if the user is allowed to send text messages, contacts, locations and venues
19+
* @brief Optional. True, if the user is allowed to send text messages, contacts, invoices, locations and venues
2020
*/
2121
bool canSendMessages;
2222

2323
/**
24-
* @brief Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies canSendMessages
24+
* @brief Optional. True, if the user is allowed to send audios
2525
*/
26-
bool canSendMediaMessages;
26+
bool canSendAudios;
27+
28+
/**
29+
* @brief Optional. True, if the user is allowed to send documents
30+
*/
31+
bool canSendDocuments;
32+
33+
/**
34+
* @brief Optional. True, if the user is allowed to send photos
35+
*/
36+
bool canSendPhotos;
37+
38+
/**
39+
* @brief Optional. True, if the user is allowed to send videos
40+
*/
41+
bool canSendVideos;
42+
43+
/**
44+
* @brief Optional. True, if the user is allowed to send video notes
45+
*/
46+
bool canSendVideoNotes;
47+
48+
/**
49+
* @brief Optional. True, if the user is allowed to send voice notes
50+
*/
51+
bool canSendVoiceNotes;
2752

2853
/**
2954
* @brief Optional. True, if the user is allowed to send polls, implies canSendMessages

include/tgbot/types/ChatShared.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef TGBOT_CHATSHARED_H
2+
#define TGBOT_CHATSHARED_H
3+
4+
#include <cstdint>
5+
#include <memory>
6+
7+
namespace TgBot {
8+
9+
/**
10+
* @brief This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button.
11+
*
12+
* @ingroup types
13+
*/
14+
class ChatShared {
15+
16+
public:
17+
typedef std::shared_ptr<ChatShared> Ptr;
18+
19+
/**
20+
* @brief Identifier of the request
21+
*/
22+
std::int32_t requestId;
23+
24+
/**
25+
* @brief Identifier of the shared chat.
26+
*
27+
* The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
28+
*
29+
* This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
30+
* But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
31+
*/
32+
std::int64_t userId;
33+
};
34+
}
35+
36+
#endif //TGBOT_CHATSHARED_H

include/tgbot/types/File.h

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

1010
/**
1111
* @brief This object represents a file ready to be downloaded.
12-
* The file can be downloaded via Api::downloadFile.
12+
* The file can be downloaded via Api::downloadFile or via the link https://api.telegram.org/file/bot<token>/<filePath>.
1313
* It is guaranteed that the File::filePath will be valid for at least 1 hour.
1414
* When the File::filePath expires, a new one can be requested by calling Api::getFile.
1515
*
@@ -43,7 +43,7 @@ class File {
4343

4444
/**
4545
* @brief Optional. File path.
46-
* Use Api::downloadFile to get the file.
46+
* Use Api::downloadFile or https://api.telegram.org/file/bot<token>/<filePath> to get the file.
4747
*/
4848
std::string filePath;
4949
};

0 commit comments

Comments
 (0)