Skip to content

Commit

Permalink
Merge pull request #240 from llnulldisk/master
Browse files Browse the repository at this point in the history
Update to Bot API 6.3
  • Loading branch information
reo7sp authored Nov 8, 2022
2 parents 78d036f + 89fba68 commit 746f848
Show file tree
Hide file tree
Showing 15 changed files with 842 additions and 198 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.2
- [x] Bot API 3.0 ~ 6.3


## Sample
Expand Down
291 changes: 213 additions & 78 deletions include/tgbot/Api.h

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions include/tgbot/TgTypeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "tgbot/types/WebAppData.h"
#include "tgbot/types/ProximityAlertTriggered.h"
#include "tgbot/types/MessageAutoDeleteTimerChanged.h"
#include "tgbot/types/ForumTopicCreated.h"
#include "tgbot/types/ForumTopicClosed.h"
#include "tgbot/types/ForumTopicReopened.h"
#include "tgbot/types/VideoChatScheduled.h"
#include "tgbot/types/VideoChatStarted.h"
#include "tgbot/types/VideoChatEnded.h"
Expand Down Expand Up @@ -56,6 +59,7 @@
#include "tgbot/types/ChatJoinRequest.h"
#include "tgbot/types/ChatPermissions.h"
#include "tgbot/types/ChatLocation.h"
#include "tgbot/types/ForumTopic.h"
#include "tgbot/types/BotCommand.h"
#include "tgbot/types/BotCommandScope.h"
#include "tgbot/types/BotCommandScopeDefault.h"
Expand Down Expand Up @@ -226,6 +230,15 @@ class TGBOT_API TgTypeParser {
MessageAutoDeleteTimerChanged::Ptr parseJsonAndGetMessageAutoDeleteTimerChanged(const boost::property_tree::ptree& data) const;
std::string parseMessageAutoDeleteTimerChanged(const MessageAutoDeleteTimerChanged::Ptr& object) const;

ForumTopicCreated::Ptr parseJsonAndGetForumTopicCreated(const boost::property_tree::ptree& data) const;
std::string parseForumTopicCreated(const ForumTopicCreated::Ptr& object) const;

ForumTopicClosed::Ptr parseJsonAndGetForumTopicClosed(const boost::property_tree::ptree& data) const;
std::string parseForumTopicClosed(const ForumTopicClosed::Ptr& object) const;

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

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

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

ForumTopic::Ptr parseJsonAndGetForumTopic(const boost::property_tree::ptree& data) const;
std::string parseForumTopic(const ForumTopic::Ptr& object) const;

BotCommand::Ptr parseJsonAndGetBotCommand(const boost::property_tree::ptree& data) const;
std::string parseBotCommand(const BotCommand::Ptr& object) const;

Expand Down
42 changes: 39 additions & 3 deletions include/tgbot/types/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstdint>
#include <memory>
#include <string>
#include <vector>

namespace TgBot {

Expand All @@ -33,8 +34,8 @@ class Chat {
/**
* @brief Unique identifier for this chat.
*
* This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
* But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
* 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.
*/
std::int64_t id;

Expand Down Expand Up @@ -63,107 +64,142 @@ class Chat {
*/
std::string lastName;

/**
* @brief Optional. True, if the supergroup chat is a forum (has topics enabled)
*/
bool isForum;

/**
* @brief Optional. Chat photo.
*
* Returned only in Api::getChat.
*/
ChatPhoto::Ptr photo;

/**
* @brief Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels.
*
* Returned only in Api::getChat.
*/
std::vector<std::string> activeUsernames;

/**
* @brief Optional. Custom emoji identifier of emoji status of the other party in a private chat.
*
* Returned only in Api::getChat.
*/
std::string emojiStatusCustomEmojiId;

/**
* @brief Optional. Bio of the other party in a private chat.
*
* Returned only in Api::getChat.
*/
std::string bio;

/**
* @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.
*
* Returned only in Api::getChat.
*/
bool hasPrivateForwards;

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

/**
* @brief Optional. True, if users need to join the supergroup before they can send messages.
*
* Returned only in Api::getChat.
*/
bool joinToSendMessages;

/**
* @brief Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators.
*
* Returned only in Api::getChat.
*/
bool joinByRequest;

/**
* @brief Optional. Description, for groups, supergroups and channel chats.
*
* Returned only in Api::getChat.
*/
std::string description;

/**
* @brief Optional. Primary invite link, for groups, supergroups and channel chats.
*
* Returned only in Api::getChat.
*/
std::string inviteLink;

/**
* @brief Optional. The most recent pinned message (by sending date).
*
* Returned only in Api::getChat.
*/
std::shared_ptr<Message> pinnedMessage;

/**
* @brief Optional. Default chat member permissions, for groups and supergroups.
*
* Returned only in Api::getChat.
*/
ChatPermissions::Ptr permissions;

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

/**
* @brief Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds.
*
* Returned only in Api::getChat.
*/
std::int32_t messageAutoDeleteTime;

/**
* @brief Optional. True, if messages from the chat can't be forwarded to other chats.
*
* Returned only in Api::getChat.
*/
bool hasProtectedContent;

/**
* @brief Optional. For supergroups, name of group sticker set.
*
* Returned only in Api::getChat.
*/
std::string stickerSetName;

/**
* @brief Optional. True, if the bot can change the group sticker set.
*
* Returned only in Api::getChat.
*/
bool canSetStickerSet;

/**
* @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.
* Returned only in Api::getChat.
*
* This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it.
* But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* Returned only in Api::getChat.
*/
std::int64_t linkedChatId;

/**
* @brief Optional. For supergroups, the location to which the supergroup is connected.
*
* Returned only in Api::getChat.
*/
ChatLocation::Ptr location;
Expand Down
6 changes: 6 additions & 0 deletions include/tgbot/types/ChatAdministratorRights.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ChatAdministratorRights {

/**
* @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.
*
* Implied by any other administrator privilege
*/
bool canManageChat;
Expand Down Expand Up @@ -69,6 +70,11 @@ class ChatAdministratorRights {
* @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only
*/
bool canPinMessages;

/**
* @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
*/
bool canManageTopics;
};
}

Expand Down
8 changes: 7 additions & 1 deletion include/tgbot/types/ChatMemberAdministrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ChatMemberAdministrator : public ChatMember {

/**
* @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.
*
* Implied by any other administrator privilege
*/
bool canManageChat;
Expand All @@ -45,7 +46,7 @@ class ChatMemberAdministrator : public ChatMember {
bool canDeleteMessages;

/**
* @brief rue, if the administrator can manage video chats
* @brief True, if the administrator can manage video chats
*/
bool canManageVideoChats;

Expand Down Expand Up @@ -84,6 +85,11 @@ class ChatMemberAdministrator : public ChatMember {
*/
bool canPinMessages;

/**
* @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
*/
bool canManageTopics;

/**
* @brief Optional. Custom title for this user
*/
Expand Down
12 changes: 10 additions & 2 deletions include/tgbot/types/ChatMemberRestricted.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace TgBot {

/**
* @brief Represents a chat member that is under certain restrictions in the chat.
*
* Supergroups only.
*
* @ingroup types
Expand Down Expand Up @@ -40,10 +41,15 @@ class ChatMemberRestricted : public ChatMember {
bool canInviteUsers;

/**
* @brief True, if the user is allowed to pin messages; groups and supergroups only
* @brief True, if the user is allowed to pin messages
*/
bool canPinMessages;

/**
* @brief True, if the user is allowed to create forum topics
*/
bool canManageTopics;

/**
* @brief True, if the user is allowed to send text messages, contacts, locations and venues
*/
Expand All @@ -70,7 +76,9 @@ class ChatMemberRestricted : public ChatMember {
bool canAddWebPagePreviews;

/**
* @brief Date when restrictions will be lifted for this user; unix time
* @brief Date when restrictions will be lifted for this user; unix time.
*
* If 0, then the user is restricted forever
*/
std::uint32_t untilDate;
};
Expand Down
Loading

0 comments on commit 746f848

Please sign in to comment.