// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // 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/utils/common.h" #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)) { } static unique_ptr get_bot_menu_button( telegram_api::object_ptr &&bot_menu_button); td_api::object_ptr get_bot_menu_button_object() const; template 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 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); bool operator==(const unique_ptr &lhs, const unique_ptr &rhs); inline bool operator!=(const unique_ptr &lhs, const unique_ptr &rhs) { return !(lhs == rhs); } } // namespace td