1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#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"
#include "td/utils/tl_helpers.h"
namespace td {
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, 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);
td_api::object_ptr<td_api::botCommand> get_bot_command_object() const;
telegram_api::object_ptr<telegram_api::botCommand> get_input_bot_command() const;
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);
}
};
bool operator==(const BotCommand &lhs, const BotCommand &rhs);
inline bool operator!=(const BotCommand &lhs, const BotCommand &rhs) {
return !(lhs == rhs);
}
class BotCommands {
UserId bot_user_id_;
vector<BotCommand> commands_;
friend bool operator==(const BotCommands &lhs, const BotCommands &rhs);
public:
BotCommands() = default;
BotCommands(UserId bot_user_id, vector<telegram_api::object_ptr<telegram_api::botCommand>> &&bot_commands);
td_api::object_ptr<td_api::botCommands> get_bot_commands_object(Td *td) const;
static bool update_all_bot_commands(vector<BotCommands> &all_bot_commands, BotCommands &&bot_commands);
UserId get_bot_user_id() const {
return bot_user_id_;
}
template <class StorerT>
void store(StorerT &storer) const {
td::store(bot_user_id_, storer);
td::store(commands_, storer);
}
template <class ParserT>
void parse(ParserT &parser) {
td::parse(bot_user_id_, parser);
td::parse(commands_, parser);
}
};
bool operator==(const BotCommands &lhs, const BotCommands &rhs);
inline bool operator!=(const BotCommands &lhs, const BotCommands &rhs) {
return !(lhs == rhs);
}
void set_commands(Td *td, td_api::object_ptr<td_api::BotCommandScope> &&scope_ptr, string &&language_code,
vector<td_api::object_ptr<td_api::botCommand>> &&commands, Promise<Unit> &&promise);
void delete_commands(Td *td, td_api::object_ptr<td_api::BotCommandScope> &&scope_ptr, string &&language_code,
Promise<Unit> &&promise);
void get_commands(Td *td, td_api::object_ptr<td_api::BotCommandScope> &&scope_ptr, string &&language_code,
Promise<td_api::object_ptr<td_api::botCommands>> &&promise);
} // namespace td
|