tdlight/td/telegram/BotMenuButton.h

84 lines
2.2 KiB
C
Raw Normal View History

2022-04-06 19:24:54 +02:00
//
2022-12-31 22:28:08 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
2022-04-06 19:24:54 +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"
2022-04-07 16:20:26 +02:00
#include "td/telegram/UserId.h"
2022-04-06 19:24:54 +02:00
#include "td/utils/common.h"
2022-06-27 12:30:18 +02:00
#include "td/utils/Promise.h"
2022-04-06 19:24:54 +02:00
#include "td/utils/tl_helpers.h"
namespace td {
class Td;
class BotMenuButton {
string text_;
string url_;
friend bool operator==(const BotMenuButton &lhs, const BotMenuButton &rhs);
public:
BotMenuButton() = default;
BotMenuButton(string &&text, string &&url) : text_(std::move(text)), url_(std::move(url)) {
}
2022-04-07 17:29:59 +02:00
td_api::object_ptr<td_api::botMenuButton> get_bot_menu_button_object(Td *td) const;
2022-04-06 19:24:54 +02:00
template <class StorerT>
void store(StorerT &storer) const {
bool has_text = !text_.empty();
bool has_url = !url_.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_text);
STORE_FLAG(has_url);
END_STORE_FLAGS();
if (has_text) {
td::store(text_, storer);
}
if (has_url) {
td::store(url_, storer);
}
}
template <class ParserT>
void parse(ParserT &parser) {
bool has_text;
bool has_url;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_text);
PARSE_FLAG(has_url);
END_PARSE_FLAGS();
if (has_text) {
td::parse(text_, parser);
}
if (has_url) {
td::parse(url_, parser);
}
}
};
bool operator==(const BotMenuButton &lhs, const BotMenuButton &rhs);
2022-04-07 16:20:26 +02:00
inline bool operator!=(const BotMenuButton &lhs, const BotMenuButton &rhs) {
2022-04-06 19:24:54 +02:00
return !(lhs == rhs);
}
2022-04-07 16:20:26 +02:00
unique_ptr<BotMenuButton> get_bot_menu_button(telegram_api::object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
2022-04-07 17:29:59 +02:00
td_api::object_ptr<td_api::botMenuButton> get_bot_menu_button_object(Td *td, const BotMenuButton *bot_menu_button);
2022-04-07 16:20:26 +02:00
2022-04-07 17:15:58 +02:00
void set_menu_button(Td *td, UserId user_id, td_api::object_ptr<td_api::botMenuButton> &&menu_button,
Promise<Unit> &&promise);
2022-04-07 16:20:26 +02:00
void get_menu_button(Td *td, UserId user_id, Promise<td_api::object_ptr<td_api::botMenuButton>> &&promise);
2022-04-06 19:24:54 +02:00
} // namespace td