diff --git a/CMakeLists.txt b/CMakeLists.txt index 16c8ed614..fd69f9229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,6 +352,7 @@ set(TDLIB_SOURCE td/telegram/files/FileUploader.cpp td/telegram/files/PartsManager.cpp td/telegram/files/ResourceManager.cpp + td/telegram/ForumTopicEditedData.cpp td/telegram/ForumTopicIcon.cpp td/telegram/ForumTopicInfo.cpp td/telegram/Game.cpp @@ -581,6 +582,7 @@ set(TDLIB_SOURCE td/telegram/files/ResourceManager.h td/telegram/files/ResourceState.h td/telegram/FolderId.h + td/telegram/ForumTopicEditedData.h td/telegram/ForumTopicIcon.h td/telegram/ForumTopicInfo.h td/telegram/FullMessageId.h diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ba5b2df26..93ee1ab0c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1298,6 +1298,14 @@ webAppInfo launch_id:int64 url:string = WebAppInfo; messageThreadInfo chat_id:int53 message_thread_id:int53 reply_info:messageReplyInfo unread_message_count:int32 messages:vector draft_message:draftMessage = MessageThreadInfo; +//@description Describes changed data about a forum topic +//@title If non-empty, the new title of the topic +//@edit_icon_custom_emoji_id True, if icon's custom_emoji_id is changed +//@icon_custom_emoji_id New unique identifier of the custom emoji shown on the topic icon; 0 if none. Ignored if edit_icon_custom_emoji_id is false +//@edit_is_closed True, if the topic is reopened or closed +//@is_closed True, if the topic is closed, or false if it is reopened. Ignored if edit_is_closed is false +forumTopicEditedData title:string edit_icon_custom_emoji_id:Bool icon_custom_emoji_id:int64 edit_is_closed:Bool is_closed:Bool = ForumTopicEditedData; + //@description Describes a forum topic icon @color Color of the topic icon in RGB format @custom_emoji_id Unique identifier of the custom emoji shown on the topic icon; 0 if none forumTopicIcon color:int32 custom_emoji_id:int64 = ForumTopicIcon; diff --git a/td/telegram/ForumTopicEditedData.cpp b/td/telegram/ForumTopicEditedData.cpp new file mode 100644 index 000000000..9fc9dd9b4 --- /dev/null +++ b/td/telegram/ForumTopicEditedData.cpp @@ -0,0 +1,31 @@ +// +// 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) +// +#include "td/telegram/ForumTopicEditedData.h" + +#include "td/utils/logging.h" + +namespace td { + +td_api::object_ptr ForumTopicEditedData::get_forum_topic_edited_data_object() const { + return td_api::make_object(title_, edit_icon_custom_emoji_id_, + icon_custom_emoji_id_.get(), edit_is_closed_, is_closed_); +} + +StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicEditedData &topic_edited_data) { + if (!topic_edited_data.title_.empty()) { + string_builder << "set title to \"" << topic_edited_data.title_ << '"'; + } + if (topic_edited_data.edit_icon_custom_emoji_id_) { + string_builder << "set icon to " << topic_edited_data.icon_custom_emoji_id_; + } + if (topic_edited_data.edit_is_closed_) { + string_builder << "set is_closed to " << topic_edited_data.is_closed_; + } + return string_builder; +} + +} // namespace td diff --git a/td/telegram/ForumTopicEditedData.h b/td/telegram/ForumTopicEditedData.h new file mode 100644 index 000000000..3ac4c4933 --- /dev/null +++ b/td/telegram/ForumTopicEditedData.h @@ -0,0 +1,47 @@ +// +// 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/CustomEmojiId.h" +#include "td/telegram/td_api.h" + +#include "td/utils/common.h" +#include "td/utils/StringBuilder.h" + +namespace td { + +class ForumTopicEditedData { + string title_; + CustomEmojiId icon_custom_emoji_id_; + bool edit_icon_custom_emoji_id_ = false; + bool edit_is_closed_ = false; + bool is_closed_ = false; + + friend StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicEditedData &topic_edited_data); + + public: + ForumTopicEditedData() = default; + + bool is_empty() const { + return title_.empty() && !edit_icon_custom_emoji_id_ && !edit_is_closed_; + } + + ForumTopicEditedData(string &&title, bool edit_icon_custom_emoji_id, int64 icon_custom_emoji_id, bool edit_is_closed, + bool is_closed) + : title_(std::move(title)) + , icon_custom_emoji_id_(icon_custom_emoji_id) + , edit_icon_custom_emoji_id_(edit_icon_custom_emoji_id) + , edit_is_closed_(edit_is_closed) + , is_closed_(is_closed) { + } + + td_api::object_ptr get_forum_topic_edited_data_object() const; +}; + +StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicEditedData &topic_edited_data); + +} // namespace td