diff --git a/CMakeLists.txt b/CMakeLists.txt index dc5c280bf..a3e76f4c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,6 +397,7 @@ set(TDLIB_SOURCE td/telegram/GroupCallVideoPayload.cpp td/telegram/HashtagHints.cpp td/telegram/InlineQueriesManager.cpp + td/telegram/InputBusinessChatLink.cpp td/telegram/InputDialogId.cpp td/telegram/InputGroupCallId.cpp td/telegram/InputInvoice.cpp @@ -717,6 +718,7 @@ set(TDLIB_SOURCE td/telegram/GroupCallVideoPayload.h td/telegram/HashtagHints.h td/telegram/InlineQueriesManager.h + td/telegram/InputBusinessChatLink.h td/telegram/InputDialogId.h td/telegram/InputGroupCallId.h td/telegram/InputInvoice.h diff --git a/SplitSource.php b/SplitSource.php index 99d3fee73..f4dcd16f9 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -362,6 +362,7 @@ function split_file($file, $chunks, $undo) { 'group_call_manager[_(-](?![.]get[(][)])|GroupCallManager' => 'GroupCallManager', 'hashtag_hints[_(-](?![.]get[(][)])|HashtagHints' => 'HashtagHints', 'inline_queries_manager[_(-](?![.]get[(][)])|InlineQueriesManager' => 'InlineQueriesManager', + 'InputBusinessChatLink' => 'InputBusinessChatLink', 'language_pack_manager[_(-]|LanguagePackManager' => 'LanguagePackManager', 'link_manager[_(-](?![.]get[(][)])|LinkManager' => 'LinkManager', 'LogeventIdWithGeneration|add_log_event|delete_log_event|get_erase_log_event_promise|parse_time|store_time' => 'logevent/LogEventHelper', diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 555d2edf7..894b5b78a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -669,6 +669,11 @@ businessChatLink link:string text:formattedText title:string view_count:int32 = //@description Contains a list of business chat links created by the user @links List of links businessChatLinks links:vector = BusinessChatLinks; +//@description Describes a business chat link to create or edit +//@text Message draft text that will be added to the input field +//@title Link title +inputBusinessChatLink text:formattedText title:string = InputBusinessChatLink; + //@class ChatPhotoStickerType @description Describes type of sticker, which was used to create a chat photo diff --git a/td/telegram/InputBusinessChatLink.cpp b/td/telegram/InputBusinessChatLink.cpp new file mode 100644 index 000000000..e0b3eede0 --- /dev/null +++ b/td/telegram/InputBusinessChatLink.cpp @@ -0,0 +1,45 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 +// +// 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) +// +#include "td/telegram/InputBusinessChatLink.h" + +#include "td/telegram/DialogManager.h" +#include "td/telegram/misc.h" +#include "td/telegram/Td.h" + +namespace td { + +InputBusinessChatLink::InputBusinessChatLink(const Td *td, td_api::object_ptr &&link) { + auto r_text = + get_formatted_text(td, td->dialog_manager_->get_my_dialog_id(), std::move(link->text_), false, true, true, false); + if (r_text.is_error()) { + LOG(INFO) << "Ignore draft text: " << r_text.error(); + } else { + text_ = r_text.move_as_ok(); + } + if (!clean_input_string(link->title_)) { + title_ = std::move(link->title_); + } +} + +telegram_api::object_ptr InputBusinessChatLink::get_input_business_chat_link( + const UserManager *user_manager) const { + int32 flags = 0; + auto entities = get_input_message_entities(user_manager, &text_, "get_input_business_chat_link"); + if (!entities.empty()) { + flags |= telegram_api::inputBusinessChatLink::ENTITIES_MASK; + } + if (!title_.empty()) { + flags |= telegram_api::inputBusinessChatLink::TITLE_MASK; + } + return telegram_api::make_object(flags, text_.text, std::move(entities), title_); +} + +StringBuilder &operator<<(StringBuilder &string_builder, const InputBusinessChatLink &link) { + return string_builder << '[' << link.title_ << ']'; +} + +} // namespace td diff --git a/td/telegram/InputBusinessChatLink.h b/td/telegram/InputBusinessChatLink.h new file mode 100644 index 000000000..1cd9d1eb6 --- /dev/null +++ b/td/telegram/InputBusinessChatLink.h @@ -0,0 +1,36 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 +// +// 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/MessageEntity.h" +#include "td/telegram/td_api.h" +#include "td/telegram/telegram_api.h" + +#include "td/utils/common.h" +#include "td/utils/StringBuilder.h" + +namespace td { + +class Td; +class UserManager; + +class InputBusinessChatLink { + FormattedText text_; + string title_; + + friend StringBuilder &operator<<(StringBuilder &string_builder, const InputBusinessChatLink &link); + + public: + InputBusinessChatLink(const Td *td, td_api::object_ptr &&link); + + telegram_api::object_ptr get_input_business_chat_link( + const UserManager *user_manager) const; +}; + +StringBuilder &operator<<(StringBuilder &string_builder, const InputBusinessChatLink &link); + +} // namespace td