Skip to content

Commit 8f49832

Browse files
authored
Merge pull request #250 from llnulldisk/master
Update to Bot API 6.4
2 parents 2544005 + c3ba72e commit 8f49832

16 files changed

Lines changed: 455 additions & 48 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.3
12+
- [x] Bot API 3.0 ~ 6.4
1313

1414

1515
## Sample

include/tgbot/Api.h

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ friend class Bot;
258258
* @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found
259259
* @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
260260
* @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
261+
* @param hasSpoiler Optional. Pass True if the photo needs to be covered with a spoiler animation
261262
*
262263
* @return On success, the sent Message is returned.
263264
*/
@@ -271,7 +272,8 @@ friend class Bot;
271272
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
272273
bool allowSendingWithoutReply = false,
273274
bool protectContent = false,
274-
std::int32_t messageThreadId = 0) const;
275+
std::int32_t messageThreadId = 0,
276+
bool hasSpoiler = false) const;
275277

276278
/**
277279
* @brief Use this method to send audio files, if you want Telegram clients to display them in the music player.
@@ -371,6 +373,7 @@ friend class Bot;
371373
* @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found
372374
* @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
373375
* @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
376+
* @param hasSpoiler Optional. Pass True if the video needs to be covered with a spoiler animation
374377
*
375378
* @return On success, the sent Message is returned.
376379
*/
@@ -389,7 +392,8 @@ friend class Bot;
389392
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
390393
bool allowSendingWithoutReply = false,
391394
bool protectContent = false,
392-
std::int32_t messageThreadId = 0) const;
395+
std::int32_t messageThreadId = 0,
396+
bool hasSpoiler = false) const;
393397

394398
/**
395399
* @brief Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
@@ -411,6 +415,7 @@ friend class Bot;
411415
* @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found
412416
* @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
413417
* @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
418+
* @param hasSpoiler Optional. Pass True if the animation needs to be covered with a spoiler animation
414419
*
415420
* @return On success, the sent Message is returned.
416421
*/
@@ -428,7 +433,8 @@ friend class Bot;
428433
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
429434
bool allowSendingWithoutReply = false,
430435
bool protectContent = false,
431-
std::int32_t messageThreadId = 0) const;
436+
std::int32_t messageThreadId = 0,
437+
bool hasSpoiler = false) const;
432438

433439
/**
434440
* @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
@@ -732,18 +738,20 @@ friend class Bot;
732738
* The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
733739
*
734740
* Example: The ImageBot needs some time to process a request and upload the image.
735-
* Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo.
741+
* Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use Api::sendChatAction with action = upload_photo.
736742
* The user will see a “sending photo” status for the bot.
737743
*
738744
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
739745
*
740746
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
741747
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
748+
* @param messageThreadId Optional. Unique identifier for the target message thread; supergroups only
742749
*
743-
* @return True on success.
750+
* @return Returns True on success.
744751
*/
745752
bool sendChatAction(std::int64_t chatId,
746-
const std::string& action) const;
753+
const std::string& action,
754+
std::int32_t messageThreadId = 0) const;
747755

748756
/**
749757
* @brief Use this method to get a list of profile pictures for a user.
@@ -1149,6 +1157,8 @@ friend class Bot;
11491157
/**
11501158
* @brief Use this method to get information about a member of a chat.
11511159
*
1160+
* The method is guaranteed to work for other users, only if the bot is an administrator in the chat.
1161+
*
11521162
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
11531163
* @param userId Unique identifier of the target user
11541164
*
@@ -1214,15 +1224,15 @@ friend class Bot;
12141224
*
12151225
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
12161226
* @param messageThreadId Unique identifier for the target message thread of the forum topic
1217-
* @param name New topic name, 1-128 characters
1218-
* @param iconCustomEmojiId New unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers
1227+
* @param name Optional. New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept
1228+
* @param iconCustomEmojiId Optional. New unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept
12191229
*
12201230
* @return Returns True on success.
12211231
*/
12221232
bool editForumTopic(boost::variant<std::int64_t, std::string> chatId,
12231233
std::int32_t messageThreadId,
1224-
const std::string& name,
1225-
const std::string& iconCustomEmojiId) const;
1234+
const std::string& name = "",
1235+
boost::variant<std::int8_t, std::string> iconCustomEmojiId = 0) const;
12261236

12271237
/**
12281238
* @brief Use this method to close an open topic in a forum supergroup chat.
@@ -1276,6 +1286,65 @@ friend class Bot;
12761286
bool unpinAllForumTopicMessages(boost::variant<std::int64_t, std::string> chatId,
12771287
std::int32_t messageThreadId) const;
12781288

1289+
/**
1290+
* @brief Use this method to edit the name of the 'General' topic in a forum supergroup chat.
1291+
*
1292+
* The bot must be an administrator in the chat for this to work and must have canManageTopics administrator rights.
1293+
*
1294+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1295+
* @param name New topic name, 1-128 characters
1296+
*
1297+
* @return Returns True on success.
1298+
*/
1299+
bool editGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId,
1300+
std::string name) const;
1301+
1302+
/**
1303+
* @brief Use this method to close an open 'General' topic in a forum supergroup chat.
1304+
*
1305+
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
1306+
*
1307+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1308+
*
1309+
* @return Returns True on success.
1310+
*/
1311+
bool closeGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;
1312+
1313+
/**
1314+
* @brief Use this method to reopen a closed 'General' topic in a forum supergroup chat.
1315+
*
1316+
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
1317+
* The topic will be automatically unhidden if it was hidden.
1318+
*
1319+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1320+
*
1321+
* @return Returns True on success.
1322+
*/
1323+
bool reopenGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;
1324+
1325+
/**
1326+
* @brief Use this method to hide the 'General' topic in a forum supergroup chat.
1327+
*
1328+
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
1329+
* The topic will be automatically closed if it was open.
1330+
*
1331+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1332+
*
1333+
* @return Returns True on success.
1334+
*/
1335+
bool hideGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;
1336+
1337+
/**
1338+
* @brief Use this method to unhide the 'General' topic in a forum supergroup chat.
1339+
*
1340+
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
1341+
*
1342+
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1343+
*
1344+
* @return Returns True on success.
1345+
*/
1346+
bool unhideGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;
1347+
12791348
/**
12801349
* @brief Use this method to send answers to callback queries sent from inline keyboards.
12811350
*

include/tgbot/TgTypeParser.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
2929
#include "tgbot/types/ForumTopicCreated.h"
3030
#include "tgbot/types/ForumTopicClosed.h"
31+
#include "tgbot/types/ForumTopicEdited.h"
3132
#include "tgbot/types/ForumTopicReopened.h"
33+
#include "tgbot/types/GeneralForumTopicHidden.h"
34+
#include "tgbot/types/GeneralForumTopicUnhidden.h"
35+
#include "tgbot/types/WriteAccessAllowed.h"
3236
#include "tgbot/types/VideoChatScheduled.h"
3337
#include "tgbot/types/VideoChatStarted.h"
3438
#include "tgbot/types/VideoChatEnded.h"
@@ -236,9 +240,21 @@ class TGBOT_API TgTypeParser {
236240
ForumTopicClosed::Ptr parseJsonAndGetForumTopicClosed(const boost::property_tree::ptree& data) const;
237241
std::string parseForumTopicClosed(const ForumTopicClosed::Ptr& object) const;
238242

243+
ForumTopicEdited::Ptr parseJsonAndGetForumTopicEdited(const boost::property_tree::ptree& data) const;
244+
std::string parseForumTopicEdited(const ForumTopicEdited::Ptr& object) const;
245+
239246
ForumTopicReopened::Ptr parseJsonAndGetForumTopicReopened(const boost::property_tree::ptree& data) const;
240247
std::string parseForumTopicReopened(const ForumTopicReopened::Ptr& object) const;
241248

249+
GeneralForumTopicHidden::Ptr parseJsonAndGetGeneralForumTopicHidden(const boost::property_tree::ptree& data) const;
250+
std::string parseGeneralForumTopicHidden(const GeneralForumTopicHidden::Ptr& object) const;
251+
252+
GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const;
253+
std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const;
254+
255+
WriteAccessAllowed::Ptr parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const;
256+
std::string parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& object) const;
257+
242258
VideoChatScheduled::Ptr parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const;
243259
std::string parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const;
244260

include/tgbot/types/Chat.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ class Chat {
167167
*/
168168
std::int32_t messageAutoDeleteTime;
169169

170+
/**
171+
* @brief Optional. True, if aggressive anti-spam checks are enabled in the supergroup.
172+
*
173+
* The field is only available to chat administrators.
174+
* Returned only in Api::getChat.
175+
*/
176+
bool hasAggressiveAntiSpamEnabled;
177+
178+
/**
179+
* @brief Optional. True, if non-administrators can only get the list of bots and administrators in the chat.
180+
*
181+
* Returned only in Api::getChat.
182+
*/
183+
bool hasHiddenMembers;
184+
170185
/**
171186
* @brief Optional. True, if messages from the chat can't be forwarded to other chats.
172187
*
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef TGBOT_FORUMTOPICEDITED_H
2+
#define TGBOT_FORUMTOPICEDITED_H
3+
4+
#include <memory>
5+
#include <string>
6+
7+
namespace TgBot {
8+
9+
/**
10+
* @brief This object represents a service message about an edited forum topic.
11+
*
12+
* @ingroup types
13+
*/
14+
class ForumTopicEdited {
15+
public:
16+
typedef std::shared_ptr<ForumTopicEdited> Ptr;
17+
18+
/**
19+
* @brief Optional. New name of the topic, if it was edited
20+
*/
21+
std::string name;
22+
23+
/**
24+
* @brief Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed
25+
*/
26+
std::string iconCustomEmojiId;
27+
};
28+
}
29+
30+
#endif //TGBOT_FORUMTOPICEDITED_H
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef TGBOT_GENERALFORUMTOPICHIDDEN_H
2+
#define TGBOT_GENERALFORUMTOPICHIDDEN_H
3+
4+
#include <memory>
5+
6+
namespace TgBot {
7+
8+
/**
9+
* @brief This object represents a service message about General forum topic hidden in the chat.
10+
*
11+
* Currently holds no information.
12+
*
13+
* @ingroup types
14+
*/
15+
class GeneralForumTopicHidden {
16+
public:
17+
typedef std::shared_ptr<GeneralForumTopicHidden> Ptr;
18+
};
19+
}
20+
21+
#endif //TGBOT_GENERALFORUMTOPICHIDDEN_H
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef TGBOT_GENERALFORUMTOPICUNHIDDEN_H
2+
#define TGBOT_GENERALFORUMTOPICUNHIDDEN_H
3+
4+
#include <memory>
5+
6+
namespace TgBot {
7+
8+
/**
9+
* @brief This object represents a service message about General forum topic unhidden in the chat.
10+
*
11+
* Currently holds no information.
12+
*
13+
* @ingroup types
14+
*/
15+
class GeneralForumTopicUnhidden {
16+
public:
17+
typedef std::shared_ptr<GeneralForumTopicUnhidden> Ptr;
18+
};
19+
}
20+
21+
#endif //TGBOT_GENERALFORUMTOPICUNHIDDEN_H

include/tgbot/types/InputMedia.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,26 @@ class InputMedia {
3131

3232
/**
3333
* @brief File to send.
34+
*
3435
* Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
3536
* https://core.telegram.org/bots/api#sending-files
3637
*/
3738
std::string media;
3839

3940
/**
40-
* @brief Optional. Caption of the media to to be sent, 0-1024 characters after entities parsing
41+
* @brief Optional. Caption of the media to be sent, 0-1024 characters after entities parsing
4142
*/
4243
std::string caption;
4344

4445
/**
4546
* @brief Optional. Mode for parsing entities in the media caption.
47+
*
4648
* See https://core.telegram.org/bots/api#formatting-options for more details.
4749
*/
4850
std::string parseMode;
4951

5052
/**
51-
* @brief Optional. List of special entities that appear in the caption, which can be specified instead of InputMedia::parseMode
53+
* @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
5254
*/
5355
std::vector<MessageEntity::Ptr> captionEntities;
5456
};

include/tgbot/types/InputMediaAnimation.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class InputMediaAnimation : public InputMedia {
2626

2727
/**
2828
* @brief Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
29+
*
2930
* The thumbnail should be in JPEG format and less than 200 kB in size.
3031
* A thumbnail's width and height should not exceed 320.
3132
* Ignored if the file is not uploaded using multipart/form-data.
@@ -45,9 +46,14 @@ class InputMediaAnimation : public InputMedia {
4546
std::int32_t height;
4647

4748
/**
48-
* @brief Optional. Animation duration
49+
* @brief Optional. Animation duration in seconds
4950
*/
5051
std::int32_t duration;
52+
53+
/**
54+
* @brief Optional. Pass True if the animation needs to be covered with a spoiler animation
55+
*/
56+
bool hasSpoiler;
5157
};
5258
}
5359

include/tgbot/types/InputMediaPhoto.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "tgbot/types/InputMedia.h"
55

66
#include <memory>
7-
#include <string>
87

98
namespace TgBot {
109

@@ -22,6 +21,11 @@ class InputMediaPhoto : public InputMedia {
2221
InputMediaPhoto() {
2322
this->type = TYPE;
2423
}
24+
25+
/**
26+
* @brief Optional. Pass True if the photo needs to be covered with a spoiler animation
27+
*/
28+
bool hasSpoiler;
2529
};
2630
}
2731

0 commit comments

Comments
 (0)