summaryrefslogtreecommitdiff
path: root/include/tgbot
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2024-04-15 01:24:12 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2024-04-15 01:24:12 +0200
commitfbeb025e21fad2fa1fb6cd5ae186eabf9a349091 (patch)
tree032c992390707b7f68c0e5259c9a23d74ec8553f /include/tgbot
parent38258eb91f752222e1e64f0499a408643a107149 (diff)
Update to Bot API 6.7
Diffstat (limited to 'include/tgbot')
-rw-r--r--include/tgbot/Api.h28
-rw-r--r--include/tgbot/TgTypeParser.h12
-rw-r--r--include/tgbot/types/BotName.h25
-rw-r--r--include/tgbot/types/ChatMemberUpdated.h8
-rw-r--r--include/tgbot/types/InlineKeyboardButton.h6
-rw-r--r--include/tgbot/types/InlineQueryResultsButton.h44
-rw-r--r--include/tgbot/types/InputSticker.h2
-rw-r--r--include/tgbot/types/KeyboardButtonRequestChat.h2
-rw-r--r--include/tgbot/types/KeyboardButtonRequestUser.h2
-rw-r--r--include/tgbot/types/SwitchInlineQueryChosenChat.h46
-rw-r--r--include/tgbot/types/WriteAccessAllowed.h10
11 files changed, 175 insertions, 10 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index a30a9fe..5efe50f 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -1412,6 +1412,26 @@ public:
const std::string& languageCode = "") const;
/**
+ * @brief Use this method to change the bot's name.
+ *
+ * @param name Optional. New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
+ * @param languageCode Optional. A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
+ *
+ * @return Returns True on success.
+ */
+ bool setMyName(const std::string& name = "",
+ const std::string& languageCode = "") const;
+
+ /**
+ * @brief Use this method to get the current bot name for the given user language.
+ *
+ * @param languageCode Optional. A two-letter ISO 639-1 language code or an empty string
+ *
+ * @return Returns BotName on success.
+ */
+ BotName::Ptr getMyName(const std::string& languageCode = "") const;
+
+ /**
* @brief Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
*
* @param description Optional. New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
@@ -1815,10 +1835,9 @@ public:
* @param inlineQueryId Unique identifier for the answered query
* @param results A JSON-serialized array of results for the inline query
* @param cacheTime Optional. The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
- * @param isPersonal Optional. Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
+ * @param isPersonal Optional. Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.
* @param nextOffset Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
- * @param switchPmText Optional. If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switchPmParameter
- * @param switchPmParameter Optional. Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer an InlineKeyboardMarkup button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
+ * @param button Optional. A JSON-serialized object describing a button to be shown above inline query results
*
* @return On success, True is returned.
*/
@@ -1827,8 +1846,7 @@ public:
std::int32_t cacheTime = 300,
bool isPersonal = false,
const std::string& nextOffset = "",
- const std::string& switchPmText = "",
- const std::string& switchPmParameter = "") const;
+ InlineQueryResultsButton::Ptr button = nullptr) const;
/**
* @brief Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 9f135fd..99a38a9 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -51,6 +51,7 @@
#include "tgbot/types/InlineKeyboardMarkup.h"
#include "tgbot/types/InlineKeyboardButton.h"
#include "tgbot/types/LoginUrl.h"
+#include "tgbot/types/SwitchInlineQueryChosenChat.h"
#include "tgbot/types/CallbackQuery.h"
#include "tgbot/types/ForceReply.h"
#include "tgbot/types/ChatPhoto.h"
@@ -77,6 +78,7 @@
#include "tgbot/types/BotCommandScopeChat.h"
#include "tgbot/types/BotCommandScopeChatAdministrators.h"
#include "tgbot/types/BotCommandScopeChatMember.h"
+#include "tgbot/types/BotName.h"
#include "tgbot/types/BotDescription.h"
#include "tgbot/types/BotShortDescription.h"
#include "tgbot/types/MenuButton.h"
@@ -95,6 +97,7 @@
#include "tgbot/types/MaskPosition.h"
#include "tgbot/types/InputSticker.h"
#include "tgbot/types/InlineQuery.h"
+#include "tgbot/types/InlineQueryResultsButton.h"
#include "tgbot/types/InlineQueryResult.h"
#include "tgbot/types/InlineQueryResultArticle.h"
#include "tgbot/types/InlineQueryResultPhoto.h"
@@ -316,6 +319,9 @@ public:
LoginUrl::Ptr parseJsonAndGetLoginUrl(const boost::property_tree::ptree& data) const;
std::string parseLoginUrl(const LoginUrl::Ptr& object) const;
+ SwitchInlineQueryChosenChat::Ptr parseJsonAndGetSwitchInlineQueryChosenChat(const boost::property_tree::ptree& data) const;
+ std::string parseSwitchInlineQueryChosenChat(const SwitchInlineQueryChosenChat::Ptr& object) const;
+
CallbackQuery::Ptr parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const;
std::string parseCallbackQuery(const CallbackQuery::Ptr& object) const;
@@ -394,6 +400,9 @@ public:
BotCommandScopeChatMember::Ptr parseJsonAndGetBotCommandScopeChatMember(const boost::property_tree::ptree& data) const;
std::string parseBotCommandScopeChatMember(const BotCommandScopeChatMember::Ptr& object) const;
+ BotName::Ptr parseJsonAndGetBotName(const boost::property_tree::ptree& data) const;
+ std::string parseBotName(const BotName::Ptr& object) const;
+
BotDescription::Ptr parseJsonAndGetBotDescription(const boost::property_tree::ptree& data) const;
std::string parseBotDescription(const BotDescription::Ptr& object) const;
@@ -448,6 +457,9 @@ public:
InlineQuery::Ptr parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const;
std::string parseInlineQuery(const InlineQuery::Ptr& object) const;
+ InlineQueryResultsButton::Ptr parseJsonAndGetInlineQueryResultsButton(const boost::property_tree::ptree& data) const;
+ std::string parseInlineQueryResultsButton(const InlineQueryResultsButton::Ptr& object) const;
+
InlineQueryResult::Ptr parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const;
std::string parseInlineQueryResult(const InlineQueryResult::Ptr& object) const;
diff --git a/include/tgbot/types/BotName.h b/include/tgbot/types/BotName.h
new file mode 100644
index 0000000..d89ee5c
--- /dev/null
+++ b/include/tgbot/types/BotName.h
@@ -0,0 +1,25 @@
+#ifndef TGBOT_BOTNAME_H
+#define TGBOT_BOTNAME_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents the bot's name.
+ *
+ * @ingroup types
+ */
+class BotName {
+public:
+ typedef std::shared_ptr<BotName> Ptr;
+
+ /**
+ * @brief The bot's name
+ */
+ std::string name;
+};
+}
+
+#endif //TGBOT_BOTNAME_H
diff --git a/include/tgbot/types/ChatMemberUpdated.h b/include/tgbot/types/ChatMemberUpdated.h
index 9d8ce2b..1d572e6 100644
--- a/include/tgbot/types/ChatMemberUpdated.h
+++ b/include/tgbot/types/ChatMemberUpdated.h
@@ -6,6 +6,7 @@
#include "tgbot/types/ChatMember.h"
#include "tgbot/types/ChatInviteLink.h"
+#include <cstdint>
#include <memory>
namespace TgBot {
@@ -33,7 +34,7 @@ public:
/**
* @brief Date the change was done in Unix time
*/
- std::uint32_t date;
+ std::uint64_t date;
/**
* @brief Previous information about the chat member
@@ -49,6 +50,11 @@ public:
* @brief Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
*/
ChatInviteLink::Ptr inviteLink;
+
+ /**
+ * @brief Optional. True, if the user joined the chat via a chat folder invite link
+ */
+ bool viaChatFolderInviteLink;
};
}
diff --git a/include/tgbot/types/InlineKeyboardButton.h b/include/tgbot/types/InlineKeyboardButton.h
index f216669..1f2e16f 100644
--- a/include/tgbot/types/InlineKeyboardButton.h
+++ b/include/tgbot/types/InlineKeyboardButton.h
@@ -3,6 +3,7 @@
#include "tgbot/types/WebAppInfo.h"
#include "tgbot/types/LoginUrl.h"
+#include "tgbot/types/SwitchInlineQueryChosenChat.h"
#include "tgbot/types/CallbackGame.h"
#include <memory>
@@ -67,6 +68,11 @@ public:
std::string switchInlineQueryCurrentChat;
/**
+ * @brief Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field
+ */
+ SwitchInlineQueryChosenChat::Ptr switchInlineQueryChosenChat;
+
+ /**
* @brief Optional. Description of the game that will be launched when the user presses the button.
*
* NOTE: This type of button must always be the first button in the first row.
diff --git a/include/tgbot/types/InlineQueryResultsButton.h b/include/tgbot/types/InlineQueryResultsButton.h
new file mode 100644
index 0000000..2343ff5
--- /dev/null
+++ b/include/tgbot/types/InlineQueryResultsButton.h
@@ -0,0 +1,44 @@
+#ifndef TGBOT_INLINEQUERYRESULTSBUTTON_H
+#define TGBOT_INLINEQUERYRESULTSBUTTON_H
+
+#include "tgbot/types/WebAppInfo.h"
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents a button to be shown above inline query results.
+ *
+ * You must use exactly one of the optional fields.
+ *
+ * @ingroup types
+ */
+class InlineQueryResultsButton {
+public:
+ typedef std::shared_ptr<InlineQueryResultsButton> Ptr;
+
+ /**
+ * @brief Label text on the button
+ */
+ std::string text;
+
+ /**
+ * @brief Optional. Description of the Web App (https://core.telegram.org/bots/webapps) that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery (https://core.telegram.org/bots/webapps#initializing-web-apps) inside the Web App.
+ */
+ WebAppInfo::Ptr webApp;
+
+ /**
+ * @brief Optional. Deep-linking (https://core.telegram.org/bots/features#deep-linking) parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
+ *
+ * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly.
+ * To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any.
+ * The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link.
+ * Once done, the bot can offer a switchInline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
+ */
+ std::string startParameter;
+};
+}
+
+#endif //TGBOT_INLINEQUERYRESULTSBUTTON_H
diff --git a/include/tgbot/types/InputSticker.h b/include/tgbot/types/InputSticker.h
index f71107e..06dafd2 100644
--- a/include/tgbot/types/InputSticker.h
+++ b/include/tgbot/types/InputSticker.h
@@ -20,7 +20,7 @@ public:
/**
* @brief The added sticker.
- * Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
+ * Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
* Animated and video stickers can't be uploaded via HTTP URL. https://core.telegram.org/bots/api#sending-files
*/
std::string sticker;
diff --git a/include/tgbot/types/KeyboardButtonRequestChat.h b/include/tgbot/types/KeyboardButtonRequestChat.h
index 9e446d8..92e858d 100644
--- a/include/tgbot/types/KeyboardButtonRequestChat.h
+++ b/include/tgbot/types/KeyboardButtonRequestChat.h
@@ -10,7 +10,9 @@ namespace TgBot {
/**
* @brief This object defines the criteria used to request a suitable chat.
+ *
* The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
+ * https://core.telegram.org/bots/features#chat-and-user-selection
*
* @ingroup types
*/
diff --git a/include/tgbot/types/KeyboardButtonRequestUser.h b/include/tgbot/types/KeyboardButtonRequestUser.h
index 3463e49..3ec6f16 100644
--- a/include/tgbot/types/KeyboardButtonRequestUser.h
+++ b/include/tgbot/types/KeyboardButtonRequestUser.h
@@ -8,7 +8,9 @@ namespace TgBot {
/**
* @brief This object defines the criteria used to request a suitable user.
+ *
* The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
+ * https://core.telegram.org/bots/features#chat-and-user-selection
*
* @ingroup types
*/
diff --git a/include/tgbot/types/SwitchInlineQueryChosenChat.h b/include/tgbot/types/SwitchInlineQueryChosenChat.h
new file mode 100644
index 0000000..b0ecf2c
--- /dev/null
+++ b/include/tgbot/types/SwitchInlineQueryChosenChat.h
@@ -0,0 +1,46 @@
+#ifndef TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
+#define TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
+
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.
+ *
+ * @ingroup types
+ */
+class SwitchInlineQueryChosenChat {
+
+public:
+ typedef std::shared_ptr<SwitchInlineQueryChosenChat> Ptr;
+
+ /**
+ * @brief Optional. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted
+ */
+ std::string query;
+
+ /**
+ * @brief Optional. True, if private chats with users can be chosen
+ */
+ bool allowUserChats;
+
+ /**
+ * @brief Optional. True, if private chats with bots can be chosen
+ */
+ bool allowBotChats;
+
+ /**
+ * @brief Optional. True, if group and supergroup chats can be chosen
+ */
+ bool allowGroupChats;
+
+ /**
+ * @brief Optional. True, if channel chats can be chosen
+ */
+ bool allowChannelChats;
+};
+}
+
+#endif //TGBOT_SWITCHINLINEQUERYCHOSENCHAT_H
diff --git a/include/tgbot/types/WriteAccessAllowed.h b/include/tgbot/types/WriteAccessAllowed.h
index d01aa31..e3138df 100644
--- a/include/tgbot/types/WriteAccessAllowed.h
+++ b/include/tgbot/types/WriteAccessAllowed.h
@@ -2,19 +2,23 @@
#define TGBOT_WRITEACCESSALLOWED_H
#include <memory>
+#include <string>
namespace TgBot {
/**
- * @brief This object represents a service message about a user allowing a bot added to the attachment menu to write messages.
- *
- * Currently holds no information.
+ * @brief This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.
*
* @ingroup types
*/
class WriteAccessAllowed {
public:
typedef std::shared_ptr<WriteAccessAllowed> Ptr;
+
+ /**
+ * @brief Optional. Name of the Web App which was launched from a link
+ */
+ std::string webAppName;
};
}