Skip to content

Commit

Permalink
Merge pull request #250 from llnulldisk/master
Browse files Browse the repository at this point in the history
Update to Bot API 6.4
  • Loading branch information
reo7sp committed Jan 4, 2023
2 parents 2544005 + c3ba72e commit 8f49832
Show file tree
Hide file tree
Showing 16 changed files with 455 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).

## State

- [x] Bot API 3.0 ~ 6.3
- [x] Bot API 3.0 ~ 6.4


## Sample
Expand Down
89 changes: 79 additions & 10 deletions include/tgbot/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ friend class Bot;
* @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found
* @param protectContent Optional. Protects the contents of the sent message from forwarding and saving
* @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
* @param hasSpoiler Optional. Pass True if the photo needs to be covered with a spoiler animation
*
* @return On success, the sent Message is returned.
*/
Expand All @@ -271,7 +272,8 @@ friend class Bot;
const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(),
bool allowSendingWithoutReply = false,
bool protectContent = false,
std::int32_t messageThreadId = 0) const;
std::int32_t messageThreadId = 0,
bool hasSpoiler = false) const;

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

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

/**
* @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
Expand Down Expand Up @@ -732,18 +738,20 @@ friend class Bot;
* The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
*
* Example: The ImageBot needs some time to process a request and upload the image.
* Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo.
* Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use Api::sendChatAction with action = upload_photo.
* The user will see a “sending photo” status for the bot.
*
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
*
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @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.
* @param messageThreadId Optional. Unique identifier for the target message thread; supergroups only
*
* @return True on success.
* @return Returns True on success.
*/
bool sendChatAction(std::int64_t chatId,
const std::string& action) const;
const std::string& action,
std::int32_t messageThreadId = 0) const;

/**
* @brief Use this method to get a list of profile pictures for a user.
Expand Down Expand Up @@ -1149,6 +1157,8 @@ friend class Bot;
/**
* @brief Use this method to get information about a member of a chat.
*
* The method is guaranteed to work for other users, only if the bot is an administrator in the chat.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*
Expand Down Expand Up @@ -1214,15 +1224,15 @@ friend class Bot;
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param messageThreadId Unique identifier for the target message thread of the forum topic
* @param name New topic name, 1-128 characters
* @param iconCustomEmojiId New unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers
* @param name Optional. New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept
* @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
*
* @return Returns True on success.
*/
bool editForumTopic(boost::variant<std::int64_t, std::string> chatId,
std::int32_t messageThreadId,
const std::string& name,
const std::string& iconCustomEmojiId) const;
const std::string& name = "",
boost::variant<std::int8_t, std::string> iconCustomEmojiId = 0) const;

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

/**
* @brief Use this method to edit the name of the 'General' topic in a forum supergroup chat.
*
* The bot must be an administrator in the chat for this to work and must have canManageTopics administrator rights.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param name New topic name, 1-128 characters
*
* @return Returns True on success.
*/
bool editGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId,
std::string name) const;

/**
* @brief Use this method to close an open 'General' topic in a forum supergroup chat.
*
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*
* @return Returns True on success.
*/
bool closeGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;

/**
* @brief Use this method to reopen a closed 'General' topic in a forum supergroup chat.
*
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
* The topic will be automatically unhidden if it was hidden.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*
* @return Returns True on success.
*/
bool reopenGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;

/**
* @brief Use this method to hide the 'General' topic in a forum supergroup chat.
*
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
* The topic will be automatically closed if it was open.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*
* @return Returns True on success.
*/
bool hideGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;

/**
* @brief Use this method to unhide the 'General' topic in a forum supergroup chat.
*
* The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights.
*
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*
* @return Returns True on success.
*/
bool unhideGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;

/**
* @brief Use this method to send answers to callback queries sent from inline keyboards.
*
Expand Down
16 changes: 16 additions & 0 deletions include/tgbot/TgTypeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
#include "tgbot/types/ForumTopicCreated.h"
#include "tgbot/types/ForumTopicClosed.h"
#include "tgbot/types/ForumTopicEdited.h"
#include "tgbot/types/ForumTopicReopened.h"
#include "tgbot/types/GeneralForumTopicHidden.h"
#include "tgbot/types/GeneralForumTopicUnhidden.h"
#include "tgbot/types/WriteAccessAllowed.h"
#include "tgbot/types/VideoChatScheduled.h"
#include "tgbot/types/VideoChatStarted.h"
#include "tgbot/types/VideoChatEnded.h"
Expand Down Expand Up @@ -236,9 +240,21 @@ class TGBOT_API TgTypeParser {
ForumTopicClosed::Ptr parseJsonAndGetForumTopicClosed(const boost::property_tree::ptree& data) const;
std::string parseForumTopicClosed(const ForumTopicClosed::Ptr& object) const;

ForumTopicEdited::Ptr parseJsonAndGetForumTopicEdited(const boost::property_tree::ptree& data) const;
std::string parseForumTopicEdited(const ForumTopicEdited::Ptr& object) const;

ForumTopicReopened::Ptr parseJsonAndGetForumTopicReopened(const boost::property_tree::ptree& data) const;
std::string parseForumTopicReopened(const ForumTopicReopened::Ptr& object) const;

GeneralForumTopicHidden::Ptr parseJsonAndGetGeneralForumTopicHidden(const boost::property_tree::ptree& data) const;
std::string parseGeneralForumTopicHidden(const GeneralForumTopicHidden::Ptr& object) const;

GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const;
std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const;

WriteAccessAllowed::Ptr parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const;
std::string parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& object) const;

VideoChatScheduled::Ptr parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const;
std::string parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const;

Expand Down
15 changes: 15 additions & 0 deletions include/tgbot/types/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ class Chat {
*/
std::int32_t messageAutoDeleteTime;

/**
* @brief Optional. True, if aggressive anti-spam checks are enabled in the supergroup.
*
* The field is only available to chat administrators.
* Returned only in Api::getChat.
*/
bool hasAggressiveAntiSpamEnabled;

/**
* @brief Optional. True, if non-administrators can only get the list of bots and administrators in the chat.
*
* Returned only in Api::getChat.
*/
bool hasHiddenMembers;

/**
* @brief Optional. True, if messages from the chat can't be forwarded to other chats.
*
Expand Down
30 changes: 30 additions & 0 deletions include/tgbot/types/ForumTopicEdited.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef TGBOT_FORUMTOPICEDITED_H
#define TGBOT_FORUMTOPICEDITED_H

#include <memory>
#include <string>

namespace TgBot {

/**
* @brief This object represents a service message about an edited forum topic.
*
* @ingroup types
*/
class ForumTopicEdited {
public:
typedef std::shared_ptr<ForumTopicEdited> Ptr;

/**
* @brief Optional. New name of the topic, if it was edited
*/
std::string name;

/**
* @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
*/
std::string iconCustomEmojiId;
};
}

#endif //TGBOT_FORUMTOPICEDITED_H
21 changes: 21 additions & 0 deletions include/tgbot/types/GeneralForumTopicHidden.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef TGBOT_GENERALFORUMTOPICHIDDEN_H
#define TGBOT_GENERALFORUMTOPICHIDDEN_H

#include <memory>

namespace TgBot {

/**
* @brief This object represents a service message about General forum topic hidden in the chat.
*
* Currently holds no information.
*
* @ingroup types
*/
class GeneralForumTopicHidden {
public:
typedef std::shared_ptr<GeneralForumTopicHidden> Ptr;
};
}

#endif //TGBOT_GENERALFORUMTOPICHIDDEN_H
21 changes: 21 additions & 0 deletions include/tgbot/types/GeneralForumTopicUnhidden.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef TGBOT_GENERALFORUMTOPICUNHIDDEN_H
#define TGBOT_GENERALFORUMTOPICUNHIDDEN_H

#include <memory>

namespace TgBot {

/**
* @brief This object represents a service message about General forum topic unhidden in the chat.
*
* Currently holds no information.
*
* @ingroup types
*/
class GeneralForumTopicUnhidden {
public:
typedef std::shared_ptr<GeneralForumTopicUnhidden> Ptr;
};
}

#endif //TGBOT_GENERALFORUMTOPICUNHIDDEN_H
6 changes: 4 additions & 2 deletions include/tgbot/types/InputMedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ class InputMedia {

/**
* @brief File to send.
*
* 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.
* https://core.telegram.org/bots/api#sending-files
*/
std::string media;

/**
* @brief Optional. Caption of the media to to be sent, 0-1024 characters after entities parsing
* @brief Optional. Caption of the media to be sent, 0-1024 characters after entities parsing
*/
std::string caption;

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

/**
* @brief Optional. List of special entities that appear in the caption, which can be specified instead of InputMedia::parseMode
* @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode
*/
std::vector<MessageEntity::Ptr> captionEntities;
};
Expand Down
8 changes: 7 additions & 1 deletion include/tgbot/types/InputMediaAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class InputMediaAnimation : public InputMedia {

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

/**
* @brief Optional. Animation duration
* @brief Optional. Animation duration in seconds
*/
std::int32_t duration;

/**
* @brief Optional. Pass True if the animation needs to be covered with a spoiler animation
*/
bool hasSpoiler;
};
}

Expand Down
6 changes: 5 additions & 1 deletion include/tgbot/types/InputMediaPhoto.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "tgbot/types/InputMedia.h"

#include <memory>
#include <string>

namespace TgBot {

Expand All @@ -22,6 +21,11 @@ class InputMediaPhoto : public InputMedia {
InputMediaPhoto() {
this->type = TYPE;
}

/**
* @brief Optional. Pass True if the photo needs to be covered with a spoiler animation
*/
bool hasSpoiler;
};
}

Expand Down
Loading

0 comments on commit 8f49832

Please sign in to comment.