2021-06-21 01:08:11 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2021-06-21 01:08:11 +02:00
|
|
|
//
|
|
|
|
// 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/utils/common.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2021-06-21 01:08:11 +02:00
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Td;
|
|
|
|
|
|
|
|
class BotCommand {
|
|
|
|
string command_;
|
|
|
|
string description_;
|
|
|
|
|
2021-06-21 01:36:04 +02:00
|
|
|
friend bool operator==(const BotCommand &lhs, const BotCommand &rhs);
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
public:
|
|
|
|
BotCommand() = default;
|
2021-06-21 01:36:04 +02:00
|
|
|
BotCommand(string command, string description) : command_(std::move(command)), description_(std::move(description)) {
|
|
|
|
}
|
2021-06-22 03:34:29 +02:00
|
|
|
explicit BotCommand(telegram_api::object_ptr<telegram_api::botCommand> &&bot_command);
|
2021-06-21 01:08:11 +02:00
|
|
|
|
|
|
|
td_api::object_ptr<td_api::botCommand> get_bot_command_object() const;
|
|
|
|
|
2021-06-22 03:34:29 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::botCommand> get_input_bot_command() const;
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
|
|
|
td::store(command_, storer);
|
|
|
|
td::store(description_, storer);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
|
|
|
td::parse(command_, parser);
|
|
|
|
td::parse(description_, parser);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-21 01:36:04 +02:00
|
|
|
bool operator==(const BotCommand &lhs, const BotCommand &rhs);
|
|
|
|
|
|
|
|
inline bool operator!=(const BotCommand &lhs, const BotCommand &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
class BotCommands {
|
|
|
|
UserId bot_user_id_;
|
|
|
|
vector<BotCommand> commands_;
|
|
|
|
|
2021-06-21 01:36:04 +02:00
|
|
|
friend bool operator==(const BotCommands &lhs, const BotCommands &rhs);
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
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;
|
|
|
|
|
2021-06-21 03:01:13 +02:00
|
|
|
UserId get_bot_user_id() const {
|
|
|
|
return bot_user_id_;
|
|
|
|
}
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-21 01:36:04 +02:00
|
|
|
bool operator==(const BotCommands &lhs, const BotCommands &rhs);
|
|
|
|
|
|
|
|
inline bool operator!=(const BotCommands &lhs, const BotCommands &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
2021-06-22 03:25:15 +02:00
|
|
|
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);
|
|
|
|
|
2021-06-21 01:08:11 +02:00
|
|
|
} // namespace td
|