2018-12-31 20:04:05 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-12-31 20:04:05 +01: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
|
|
|
|
|
2023-01-13 15:16:16 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
2023-01-11 14:54:46 +01:00
|
|
|
#include "td/telegram/RequestedDialogType.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
2021-11-10 15:14:00 +01:00
|
|
|
#include "td/telegram/UserId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2022-03-11 13:10:24 +01:00
|
|
|
class Dependencies;
|
2024-04-02 02:52:34 +02:00
|
|
|
class UserManager;
|
2021-11-10 15:14:00 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct KeyboardButton {
|
|
|
|
// append only
|
2020-01-14 18:18:35 +01:00
|
|
|
enum class Type : int32 {
|
|
|
|
Text,
|
|
|
|
RequestPhoneNumber,
|
|
|
|
RequestLocation,
|
|
|
|
RequestPoll,
|
|
|
|
RequestPollQuiz,
|
2022-03-27 00:20:26 +01:00
|
|
|
RequestPollRegular,
|
2023-01-11 14:54:46 +01:00
|
|
|
WebView,
|
|
|
|
RequestDialog
|
2020-01-14 18:18:35 +01:00
|
|
|
};
|
2018-12-31 20:04:05 +01:00
|
|
|
Type type;
|
|
|
|
string text;
|
2023-01-11 14:54:46 +01:00
|
|
|
string url; // WebView only
|
|
|
|
unique_ptr<RequestedDialogType> requested_dialog_type; // RequestDialog only
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InlineKeyboardButton {
|
|
|
|
// append only
|
2020-08-18 08:32:37 +02:00
|
|
|
enum class Type : int32 {
|
|
|
|
Url,
|
|
|
|
Callback,
|
|
|
|
CallbackGame,
|
|
|
|
SwitchInline,
|
|
|
|
SwitchInlineCurrentDialog,
|
|
|
|
Buy,
|
|
|
|
UrlAuth,
|
2021-11-10 15:14:00 +01:00
|
|
|
CallbackWithPassword,
|
2022-03-24 22:32:38 +01:00
|
|
|
User,
|
|
|
|
WebView
|
2020-08-18 08:32:37 +02:00
|
|
|
};
|
2023-04-07 13:00:10 +02:00
|
|
|
|
|
|
|
static constexpr int64 USERS_MASK = 1;
|
|
|
|
static constexpr int64 BOTS_MASK = 2;
|
|
|
|
static constexpr int64 CHATS_MASK = 4;
|
|
|
|
static constexpr int64 BROADCASTS_MASK = 8;
|
|
|
|
static constexpr int64 FULL_MASK = USERS_MASK | BOTS_MASK | CHATS_MASK | BROADCASTS_MASK;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Type type;
|
2023-04-07 13:00:10 +02:00
|
|
|
int64 id = 0; // UrlAuth: button_id or (2 * request_write_access - 1) * bot_user_id
|
|
|
|
// SwitchInline: mask of allowed target chats; 0 if any
|
2021-11-10 15:14:00 +01:00
|
|
|
UserId user_id; // User only
|
2018-12-31 20:04:05 +01:00
|
|
|
string text;
|
2019-05-27 16:48:15 +02:00
|
|
|
string forward_text; // UrlAuth only
|
2018-12-31 20:04:05 +01:00
|
|
|
string data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReplyMarkup {
|
|
|
|
// append only
|
|
|
|
enum class Type : int32 { InlineKeyboard, ShowKeyboard, RemoveKeyboard, ForceReply };
|
|
|
|
Type type;
|
|
|
|
|
|
|
|
bool is_personal = false; // for ShowKeyboard, RemoveKeyboard, ForceReply
|
|
|
|
|
2022-12-15 12:59:12 +01:00
|
|
|
bool is_persistent = false; // for ShowKeyboard
|
2018-12-31 20:04:05 +01:00
|
|
|
bool need_resize_keyboard = false; // for ShowKeyboard
|
|
|
|
bool is_one_time_keyboard = false; // for ShowKeyboard
|
|
|
|
vector<vector<KeyboardButton>> keyboard; // for ShowKeyboard
|
2021-06-19 04:20:27 +02:00
|
|
|
string placeholder; // for ShowKeyboard, ForceReply
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
vector<vector<InlineKeyboardButton>> inline_keyboard; // for InlineKeyboard
|
|
|
|
|
|
|
|
StringBuilder &print(StringBuilder &string_builder) const;
|
|
|
|
|
2024-04-02 02:52:34 +02:00
|
|
|
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(UserManager *user_manager) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-04-02 02:52:34 +02:00
|
|
|
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(UserManager *user_manager) const;
|
2023-01-13 15:03:35 +01:00
|
|
|
|
2023-01-23 16:19:35 +01:00
|
|
|
Status check_shared_dialog(Td *td, int32 button_id, DialogId dialog_id) const;
|
2023-12-22 16:47:23 +01:00
|
|
|
|
|
|
|
Status check_shared_dialog_count(int32 button_id, size_t count) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const ReplyMarkup &lhs, const ReplyMarkup &rhs);
|
|
|
|
bool operator!=(const ReplyMarkup &lhs, const ReplyMarkup &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const ReplyMarkup &reply_markup);
|
|
|
|
|
|
|
|
unique_ptr<ReplyMarkup> get_reply_markup(tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup_ptr, bool is_bot,
|
|
|
|
bool only_inline_keyboard, bool message_contains_mention);
|
|
|
|
|
2024-01-11 18:35:02 +01:00
|
|
|
Result<unique_ptr<ReplyMarkup>> get_reply_markup(td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
|
|
|
bool is_bot, bool only_inline_keyboard, bool request_buttons_allowed,
|
|
|
|
bool switch_inline_buttons_allowed);
|
|
|
|
|
|
|
|
Result<unique_ptr<ReplyMarkup>> get_reply_markup(td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
2024-03-11 13:08:17 +01:00
|
|
|
DialogType dialog_type, bool is_bot, bool is_anonymous);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-01-11 14:54:46 +01:00
|
|
|
unique_ptr<ReplyMarkup> dup_reply_markup(const unique_ptr<ReplyMarkup> &reply_markup);
|
|
|
|
|
2024-04-02 02:52:34 +02:00
|
|
|
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(UserManager *user_manager,
|
2022-06-28 17:34:53 +02:00
|
|
|
const unique_ptr<ReplyMarkup> &reply_markup);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-04-02 02:52:34 +02:00
|
|
|
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(UserManager *user_manager,
|
2022-06-28 17:34:53 +02:00
|
|
|
const unique_ptr<ReplyMarkup> &reply_markup);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-10 15:14:00 +01:00
|
|
|
void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|