Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bot API 7.2 #300

Merged
merged 11 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update to Bot API 6.8
  • Loading branch information
llnulldisk committed Apr 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5aaaa79ee2441dd36a3af4e1c869717bf9b2c927
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).

## State

- [x] Telegram Bot API 6.7
- [x] Telegram Bot API 6.8
- [ ] [Deep Linking](https://core.telegram.org/bots/features#deep-linking)


11 changes: 11 additions & 0 deletions include/tgbot/Api.h
Original file line number Diff line number Diff line change
@@ -1349,6 +1349,17 @@ friend class Bot;
*/
bool unhideGeneralForumTopic(boost::variant<std::int64_t, std::string> chatId) const;

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

/**
* @brief Use this method to send answers to callback queries sent from inline keyboards.
*
4 changes: 4 additions & 0 deletions include/tgbot/TgTypeParser.h
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
#include "tgbot/types/Animation.h"
#include "tgbot/types/Audio.h"
#include "tgbot/types/Document.h"
#include "tgbot/types/Story.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Voice.h"
@@ -205,6 +206,9 @@ class TGBOT_API TgTypeParser {
Document::Ptr parseJsonAndGetDocument(const boost::property_tree::ptree& data) const;
std::string parseDocument(const Document::Ptr& object) const;

Story::Ptr parseJsonAndGetStory(const boost::property_tree::ptree& data) const;
std::string parseStory(const Story::Ptr& object) const;

Video::Ptr parseJsonAndGetVideo(const boost::property_tree::ptree& data) const;
std::string parseVideo(const Video::Ptr& object) const;

7 changes: 7 additions & 0 deletions include/tgbot/types/Chat.h
Original file line number Diff line number Diff line change
@@ -90,6 +90,13 @@ class Chat {
*/
std::string emojiStatusCustomEmojiId;

/**
* @brief Optional. Expiration date of the emoji status of the other party in a private chat, if any.
*
* Returned only in Api::getChat.
*/
std::int64_t emojiStatusExpirationDate;

/**
* @brief Optional. Bio of the other party in a private chat.
*
10 changes: 6 additions & 4 deletions include/tgbot/types/InlineKeyboardButton.h
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ namespace TgBot {

/**
* @brief This object represents one button of an inline keyboard.
*
* You must use exactly one of the optional fields.
*
* @ingroup types
@@ -28,6 +29,7 @@ class InlineKeyboardButton {

/**
* @brief Optional. HTTP or tg:// URL to be opened when the button is pressed.
*
* Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.
*/
std::string url;
@@ -39,30 +41,30 @@ class InlineKeyboardButton {

/**
* @brief Optional. Description of the Web App that will be launched when the user presses the button.
*
* The Web App will be able to send an arbitrary message on behalf of the user using the method Api::answerWebAppQuery.
* Available only in private chats between a user and the bot.
*/
WebAppInfo::Ptr webApp;

/**
* @brief Optional. An HTTPS URL used to automatically authorize the user.
*
* Can be used as a replacement for the Telegram Login Widget.
*/
LoginUrl::Ptr loginUrl;

/**
* @brief Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field.
*
* May be empty, in which case just the bot's username will be inserted.
*
* Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it.
* Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.
*/
std::string switchInlineQuery;

/**
* @brief Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field.
* May be empty, in which case only the bot's username will be inserted.
*
* May be empty, in which case only the bot's username will be inserted.
* This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options.
*/
std::string switchInlineQueryCurrentChat;
14 changes: 10 additions & 4 deletions include/tgbot/types/Message.h
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
#include "tgbot/types/Document.h"
#include "tgbot/types/PhotoSize.h"
#include "tgbot/types/Sticker.h"
#include "tgbot/types/Story.h"
#include "tgbot/types/Video.h"
#include "tgbot/types/VideoNote.h"
#include "tgbot/types/Voice.h"
@@ -41,9 +42,9 @@
#include "tgbot/types/InlineKeyboardMarkup.h"

#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include <memory>

namespace TgBot {

@@ -84,7 +85,7 @@ class Message {
/**
* @brief Date the message was sent in Unix time
*/
std::int32_t date;
std::int64_t date;

/**
* @brief Conversation the message belongs to
@@ -119,7 +120,7 @@ class Message {
/**
* @brief Optional. For forwarded messages, date the original message was sent in Unix time
*/
std::int32_t forwardDate;
std::int64_t forwardDate;

/**
* @brief Optional. True, if the message is sent to a forum topic
@@ -146,7 +147,7 @@ class Message {
/**
* @brief Optional. Date the message was last edited in Unix time
*/
std::int32_t editDate;
std::int64_t editDate;

/**
* @brief Optional. True, if the message can't be forwarded
@@ -200,6 +201,11 @@ class Message {
*/
Sticker::Ptr sticker;

/**
* @brief Optional. Message is a forwarded story
*/
Story::Ptr story;

/**
* @brief Optional. Message is a video, information about the video
*/
20 changes: 14 additions & 6 deletions include/tgbot/types/PollAnswer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef TGBOT_CPP_POLLANSWER_H
#define TGBOT_CPP_POLLANSWER_H
#ifndef TGBOT_POLLANSWER_H
#define TGBOT_POLLANSWER_H

#include "tgbot/types/Chat.h"
#include "tgbot/types/User.h"

#include <cstdint>
#include <string>
#include <memory>
#include <vector>
@@ -25,16 +27,22 @@ class PollAnswer {
std::string pollId;

/**
* @brief The user, who changed the answer to the poll
* @brief Optional. The chat that changed the answer to the poll, if the voter is anonymous
*/
Chat::Ptr voterChat;

/**
* @brief Optional. The user that changed the answer to the poll, if the voter isn't anonymous
*/
User::Ptr user;

/**
* @brief 0-based identifiers of answer options, chosen by the user.
* May be empty if the user retracted their vote.
* @brief 0-based identifiers of chosen answer options.
*
* May be empty if the vote was retracted.
*/
std::vector<std::int32_t> optionIds;
};
}

#endif //TGBOT_CPP_POLLANSWER_H
#endif //TGBOT_POLLANSWER_H
22 changes: 22 additions & 0 deletions include/tgbot/types/Story.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef TGBOT_STORY_H
#define TGBOT_STORY_H

#include <memory>

namespace TgBot {

/**
* @brief This object represents a message about a forwarded story in the chat.
*
* Currently holds no information.
*
* @ingroup types
*/
class Story {

public:
typedef std::shared_ptr<Story> Ptr;
};
}

#endif //TGBOT_STORY_H
9 changes: 9 additions & 0 deletions src/Api.cpp
Original file line number Diff line number Diff line change
@@ -1664,6 +1664,15 @@ bool Api::unhideGeneralForumTopic(boost::variant<std::int64_t, std::string> chat
return sendRequest("unhideGeneralForumTopic", args).get<bool>("", false);
}

bool Api::unpinAllGeneralForumTopicMessages(boost::variant<std::int64_t, std::string> chatId) const {
std::vector<HttpReqArg> args;
args.reserve(1);

args.emplace_back("chat_id", chatId);

return sendRequest("unpinAllGeneralForumTopicMessages", args).get<bool>("", false);
}

bool Api::answerCallbackQuery(const std::string& callbackQueryId,
const std::string& text,
bool showAlert,
Loading
Loading