summaryrefslogtreecommitdiff
path: root/include/tgbot
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-04 20:59:46 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-04 20:59:46 +0200
commit5a72b4b1fc89d9b6033f929d9bf4f6e30d7f9698 (patch)
tree33fba0566f2bb1f378ca2d3de57fe63170312cca /include/tgbot
parent5492d26d21d09dc9cc3551f32a8eab7a2e783e3c (diff)
Update to API 5.4
Diffstat (limited to 'include/tgbot')
-rw-r--r--include/tgbot/Api.h38
-rw-r--r--include/tgbot/TgTypeParser.h4
-rw-r--r--include/tgbot/types/ChatInviteLink.h15
-rw-r--r--include/tgbot/types/ChatJoinRequest.h51
-rw-r--r--include/tgbot/types/Update.h7
5 files changed, 112 insertions, 3 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index 51717db..428c8b2 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -612,7 +612,7 @@ public:
* 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, find_location for location data, record_video_note or upload_video_note for video notes.
+ * @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.
*
* @return True on success.
*/
@@ -763,12 +763,16 @@ public:
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param expireDate Optional. Point in time (Unix timestamp) when the link will expire
* @param memberLimit Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
+ * @param name Optional. Invite link name; 0-32 characters
+ * @param createsJoinRequest Optional. True, if users joining the chat via the link need to be approved by chat administrators. If True, memberLimit can't be specified
*
* @return the new invite link as ChatInviteLink object.
*/
ChatInviteLink::Ptr createChatInviteLink(std::int64_t chatId,
std::int32_t expireDate = 0,
- std::int32_t memberLimit = 0) const;
+ std::int32_t memberLimit = 0,
+ const std::string& name = "",
+ bool createsJoinRequest = false) const;
/**
* @brief Use this method to edit a non-primary invite link created by the bot.
@@ -778,13 +782,17 @@ public:
* @param inviteLink The invite link to edit
* @param expireDate Optional. Point in time (Unix timestamp) when the link will expire
* @param memberLimit Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
+ * @param name Optional. Invite link name; 0-32 characters
+ * @param createsJoinRequest Optional. True, if users joining the chat via the link need to be approved by chat administrators. If True, memberLimit can't be specified
*
* @return the edited invite link as a ChatInviteLink object.
*/
ChatInviteLink::Ptr editChatInviteLink(std::int64_t chatId,
std::string inviteLink,
std::int32_t expireDate = 0,
- std::int32_t memberLimit = 0) const;
+ std::int32_t memberLimit = 0,
+ const std::string& name = "",
+ bool createsJoinRequest = false) const;
/**
* @brief Use this method to revoke an invite link created by the bot.
@@ -800,6 +808,30 @@ public:
std::string inviteLink) const;
/**
+ * @brief Use this method to approve a chat join request.
+ * The bot must be an administrator in the chat for this to work and must have the canInviteUsers administrator right.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ *
+ * @return True on success.
+ */
+ bool approveChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const;
+
+ /**
+ * @brief Use this method to decline a chat join request.
+ * The bot must be an administrator in the chat for this to work and must have the canInviteUsers administrator right.
+ *
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ * @param userId Unique identifier of the target user
+ *
+ * @return True on success.
+ */
+ bool declineChatJoinRequest(std::int64_t chatId,
+ std::int64_t userId) const;
+
+ /**
* @brief Use this method to set a new profile photo for the chat.
*
* Photos can't be changed for private chats.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 58b11d9..db96a0b 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -45,6 +45,7 @@
#include "tgbot/types/ChatMemberLeft.h"
#include "tgbot/types/ChatMemberBanned.h"
#include "tgbot/types/ChatMemberUpdated.h"
+#include "tgbot/types/ChatJoinRequest.h"
#include "tgbot/types/ChatPhoto.h"
#include "tgbot/types/ResponseParameters.h"
#include "tgbot/types/GenericReply.h"
@@ -303,6 +304,9 @@ public:
ChatMemberUpdated::Ptr parseJsonAndGetChatMemberUpdated(const boost::property_tree::ptree& data) const;
std::string parseChatMemberUpdated(const ChatMemberUpdated::Ptr& object) const;
+ ChatJoinRequest::Ptr parseJsonAndGetChatJoinRequest(const boost::property_tree::ptree& data) const;
+ std::string parseChatJoinRequest(const ChatJoinRequest::Ptr& object) const;
+
ChatPhoto::Ptr parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const;
std::string parseChatPhoto(const ChatPhoto::Ptr& object) const;
diff --git a/include/tgbot/types/ChatInviteLink.h b/include/tgbot/types/ChatInviteLink.h
index 22de714..b0fb840 100644
--- a/include/tgbot/types/ChatInviteLink.h
+++ b/include/tgbot/types/ChatInviteLink.h
@@ -31,6 +31,11 @@ public:
User::Ptr creator;
/**
+ * @brief True, if users joining the chat via the link need to be approved by chat administrators
+ */
+ bool createsJoinRequest;
+
+ /**
* @brief True, if the link is primary
*/
bool isPrimary;
@@ -41,6 +46,11 @@ public:
bool isRevoked;
/**
+ * @brief Optional. Invite link name
+ */
+ std::string name;
+
+ /**
* @brief Optional. Point in time (Unix timestamp) when the link will expire or has been expired
*/
std::uint32_t expireDate;
@@ -49,6 +59,11 @@ public:
* @brief Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
*/
std::uint32_t memberLimit;
+
+ /**
+ * @brief Optional. Number of pending join requests created using this link
+ */
+ std::uint32_t pendingJoinRequestCount;
};
}
diff --git a/include/tgbot/types/ChatJoinRequest.h b/include/tgbot/types/ChatJoinRequest.h
new file mode 100644
index 0000000..bcd3e4e
--- /dev/null
+++ b/include/tgbot/types/ChatJoinRequest.h
@@ -0,0 +1,51 @@
+#ifndef TGBOT_CPP_CHATJOINREQUEST_H
+#define TGBOT_CPP_CHATJOINREQUEST_H
+
+#include "tgbot/types/Chat.h"
+#include "tgbot/types/User.h"
+#include "tgbot/types/ChatInviteLink.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief Represents a join request sent to a chat.
+ *
+ * @ingroup types
+ */
+class ChatJoinRequest {
+
+public:
+ typedef std::shared_ptr<ChatJoinRequest> Ptr;
+
+ /**
+ * @brief Chat to which the request was sent
+ */
+ Chat::Ptr chat;
+
+ /**
+ * @brief User that sent the join request
+ */
+ User::Ptr from;
+
+ /**
+ * @brief Date the request was sent in Unix time
+ */
+ std::int32_t date;
+
+ /**
+ * @brief Optional. Bio of the user.
+ */
+ std::string bio;
+
+ /**
+ * @brief Optional. Chat invite link that was used by the user to send the join request
+ */
+ ChatInviteLink::Ptr inviteLink;
+};
+}
+
+#endif //TGBOT_CPP_CHATJOINREQUEST_H
diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h
index 3f15c46..6294ff5 100644
--- a/include/tgbot/types/Update.h
+++ b/include/tgbot/types/Update.h
@@ -10,6 +10,7 @@
#include "tgbot/types/Poll.h"
#include "tgbot/types/PollAnswer.h"
#include "tgbot/types/ChatMemberUpdated.h"
+#include "tgbot/types/ChatJoinRequest.h"
#include <cstdint>
#include <memory>
@@ -106,6 +107,12 @@ public:
* The bot must be an administrator in the chat and must explicitly specify “chatMember” in the list of allowedUpdates to receive these updates.
*/
ChatMemberUpdated::Ptr chatMember;
+
+ /**
+ * @brief Optional. A request to join the chat has been sent.
+ * The bot must have the canInviteUsers administrator right in the chat to receive these updates.
+ */
+ ChatJoinRequest::Ptr chatJoinRequest;
};
}