diff options
| author | levlam <levlam@telegram.org> | 2026-06-29 17:35:45 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-06-29 17:35:45 +0300 |
| commit | 8a7bd041cb15b7f8467dc7ea020e27f0520946e0 (patch) | |
| tree | fe9ee9399f93a4662c438ddbfa6d62950c78902f /td | |
| parent | 8d2cc61664a4073d6f54ecaa0fa8cd7fecbbede5 (diff) | |
Add botCommand.is_ephemeral.
Diffstat (limited to 'td')
| -rw-r--r-- | td/generate/scheme/td_api.tl | 7 | ||||
| -rw-r--r-- | td/telegram/BotCommand.cpp | 9 | ||||
| -rw-r--r-- | td/telegram/BotCommand.h | 13 | ||||
| -rw-r--r-- | td/telegram/Version.h | 3 |
4 files changed, 24 insertions, 8 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ddfdd4cf7..b28eb2096 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -819,8 +819,11 @@ userTypeBot can_be_edited:Bool can_join_groups:Bool can_read_all_group_messages: userTypeUnknown = UserType; -//@description Represents a command supported by a bot @command Text of the bot command @param_description Description of the bot command -botCommand command:string description:string = BotCommand; +//@description Represents a command supported by a bot +//@command Text of the bot command +//@param_description Description of the bot command +//@is_ephemeral True, if the command must send an ephemeral message instead of a regular one +botCommand command:string description:string is_ephemeral:Bool = BotCommand; //@description Contains a list of bot commands @bot_user_id Bot's user identifier @commands List of bot commands botCommands bot_user_id:int53 commands:vector<botCommand> = BotCommands; diff --git a/td/telegram/BotCommand.cpp b/td/telegram/BotCommand.cpp index b65be4f6a..b8e3a0424 100644 --- a/td/telegram/BotCommand.cpp +++ b/td/telegram/BotCommand.cpp @@ -113,18 +113,19 @@ BotCommand::BotCommand(telegram_api::object_ptr<telegram_api::botCommand> &&bot_ CHECK(bot_command != nullptr); command_ = std::move(bot_command->command_); description_ = std::move(bot_command->description_); + is_ephemeral_ = bot_command->ephemeral_; } td_api::object_ptr<td_api::botCommand> BotCommand::get_bot_command_object() const { - return td_api::make_object<td_api::botCommand>(command_, description_); + return td_api::make_object<td_api::botCommand>(command_, description_, is_ephemeral_); } telegram_api::object_ptr<telegram_api::botCommand> BotCommand::get_input_bot_command() const { - return telegram_api::make_object<telegram_api::botCommand>(0, false, command_, description_); + return telegram_api::make_object<telegram_api::botCommand>(0, is_ephemeral_, command_, description_); } bool operator==(const BotCommand &lhs, const BotCommand &rhs) { - return lhs.command_ == rhs.command_ && lhs.description_ == rhs.description_; + return lhs.command_ == rhs.command_ && lhs.description_ == rhs.description_ && lhs.is_ephemeral_ == rhs.is_ephemeral_; } BotCommands::BotCommands(UserId bot_user_id, vector<telegram_api::object_ptr<telegram_api::botCommand>> &&bot_commands) @@ -204,7 +205,7 @@ void set_commands(Td *td, td_api::object_ptr<td_api::BotCommandScope> &&scope_pt 400, PSLICE() << "Command description length must not exceed " << MAX_COMMAND_DESCRIPTION_LENGTH); } - new_commands.emplace_back(std::move(command->command_), std::move(command->description_)); + new_commands.emplace_back(std::move(command->command_), std::move(command->description_), command->is_ephemeral_); } td->create_handler<SetBotCommandsQuery>(std::move(promise))->send(scope, language_code, std::move(new_commands)); diff --git a/td/telegram/BotCommand.h b/td/telegram/BotCommand.h index 13069944d..603cbb81f 100644 --- a/td/telegram/BotCommand.h +++ b/td/telegram/BotCommand.h @@ -9,6 +9,7 @@ #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/telegram/UserId.h" +#include "td/telegram/Version.h" #include "td/utils/common.h" #include "td/utils/Promise.h" @@ -21,12 +22,14 @@ class Td; class BotCommand { string command_; string description_; + bool is_ephemeral_ = false; friend bool operator==(const BotCommand &lhs, const BotCommand &rhs); public: BotCommand() = default; - BotCommand(string command, string description) : command_(std::move(command)), description_(std::move(description)) { + BotCommand(string command, string description, bool is_ephemeral) + : command_(std::move(command)), description_(std::move(description)), is_ephemeral_(is_ephemeral) { } explicit BotCommand(telegram_api::object_ptr<telegram_api::botCommand> &&bot_command); @@ -36,12 +39,20 @@ class BotCommand { template <class StorerT> void store(StorerT &storer) const { + BEGIN_STORE_FLAGS(); + STORE_FLAG(is_ephemeral_); + END_STORE_FLAGS(); td::store(command_, storer); td::store(description_, storer); } template <class ParserT> void parse(ParserT &parser) { + if (parser.version() >= static_cast<int32>(Version::SupportEphemeralMessages)) { + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(is_ephemeral_); + END_PARSE_FLAGS(); + } td::parse(command_, parser); td::parse(description_, parser); } diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 71a1ce6b9..144b50e3e 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -73,7 +73,8 @@ enum class Version : int32 { AddDiceFlags, AddStarGiftAttributeRarity, AddPollCaption, - SupportRichMessages, + SupportRichMessages, // 60 + SupportEphemeralMessages, Next }; |
