Add class ForumTopicIcon.
This commit is contained in:
parent
177b5f1e89
commit
be4b1bad46
@ -352,6 +352,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/files/FileUploader.cpp
|
td/telegram/files/FileUploader.cpp
|
||||||
td/telegram/files/PartsManager.cpp
|
td/telegram/files/PartsManager.cpp
|
||||||
td/telegram/files/ResourceManager.cpp
|
td/telegram/files/ResourceManager.cpp
|
||||||
|
td/telegram/ForumTopicIcon.cpp
|
||||||
td/telegram/ForumTopicInfo.cpp
|
td/telegram/ForumTopicInfo.cpp
|
||||||
td/telegram/Game.cpp
|
td/telegram/Game.cpp
|
||||||
td/telegram/GameManager.cpp
|
td/telegram/GameManager.cpp
|
||||||
@ -580,6 +581,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/files/ResourceManager.h
|
td/telegram/files/ResourceManager.h
|
||||||
td/telegram/files/ResourceState.h
|
td/telegram/files/ResourceState.h
|
||||||
td/telegram/FolderId.h
|
td/telegram/FolderId.h
|
||||||
|
td/telegram/ForumTopicIcon.h
|
||||||
td/telegram/ForumTopicInfo.h
|
td/telegram/ForumTopicInfo.h
|
||||||
td/telegram/FullMessageId.h
|
td/telegram/FullMessageId.h
|
||||||
td/telegram/Game.h
|
td/telegram/Game.h
|
||||||
|
@ -1298,16 +1298,18 @@ webAppInfo launch_id:int64 url:string = WebAppInfo;
|
|||||||
messageThreadInfo chat_id:int53 message_thread_id:int53 reply_info:messageReplyInfo unread_message_count:int32 messages:vector<message> draft_message:draftMessage = MessageThreadInfo;
|
messageThreadInfo chat_id:int53 message_thread_id:int53 reply_info:messageReplyInfo unread_message_count:int32 messages:vector<message> draft_message:draftMessage = MessageThreadInfo;
|
||||||
|
|
||||||
|
|
||||||
|
//@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;
|
||||||
|
|
||||||
//@description Contains basic information about a forum topic
|
//@description Contains basic information about a forum topic
|
||||||
//@message_thread_id Thread identifier of the topic
|
//@message_thread_id Thread identifier of the topic
|
||||||
//@title Title of the topic
|
//@title Title of the topic
|
||||||
//@icon_color Color of the topic icon
|
//@icon Icon of the topic
|
||||||
//@icon_custom_emoji_id Unique identifier of the custom emoji shown on the topic icon; 0 if none
|
|
||||||
//@creation_date Date the topic was created
|
//@creation_date Date the topic was created
|
||||||
//@creator_id Identifier of the creator of the topic
|
//@creator_id Identifier of the creator of the topic
|
||||||
//@is_outgoing True, if the topic was created by the current user
|
//@is_outgoing True, if the topic was created by the current user
|
||||||
//@is_closed True, if the topic is closed
|
//@is_closed True, if the topic is closed
|
||||||
forumTopicInfo message_thread_id:int53 title:string icon_color:int32 icon_custom_emoji_id:int64 creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool = ForumTopicInfo;
|
forumTopicInfo message_thread_id:int53 title:string icon:forumTopicIcon creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool = ForumTopicInfo;
|
||||||
|
|
||||||
|
|
||||||
//@class RichText @description Describes a text object inside an instant-view web page
|
//@class RichText @description Describes a text object inside an instant-view web page
|
||||||
|
27
td/telegram/ForumTopicIcon.cpp
Normal file
27
td/telegram/ForumTopicIcon.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// 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/ForumTopicIcon.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
ForumTopicIcon::ForumTopicIcon(int32 color, int64 custom_emoji_id)
|
||||||
|
: color_(color & 0xFFFFFF), custom_emoji_id_(custom_emoji_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::forumTopicIcon> ForumTopicIcon::get_forum_topic_icon_object() const {
|
||||||
|
return td_api::make_object<td_api::forumTopicIcon>(color_, custom_emoji_id_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicIcon &topic_icon) {
|
||||||
|
string_builder << "icon color " << topic_icon.color_;
|
||||||
|
if (topic_icon.custom_emoji_id_.is_valid()) {
|
||||||
|
string_builder << " and " << topic_icon.custom_emoji_id_;
|
||||||
|
}
|
||||||
|
return string_builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
32
td/telegram/ForumTopicIcon.h
Normal file
32
td/telegram/ForumTopicIcon.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// 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 ForumTopicIcon {
|
||||||
|
int32 color_ = 0x6FB9F0;
|
||||||
|
CustomEmojiId custom_emoji_id_;
|
||||||
|
|
||||||
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicIcon &topic_icon);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ForumTopicIcon() = default;
|
||||||
|
ForumTopicIcon(int32 color, int64 custom_emoji_id);
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::forumTopicIcon> get_forum_topic_icon_object() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicIcon &topic_icon);
|
||||||
|
|
||||||
|
} // namespace td
|
@ -24,18 +24,15 @@ ForumTopicInfo::ForumTopicInfo(Td *td, const tl_object_ptr<telegram_api::ForumTo
|
|||||||
|
|
||||||
top_thread_message_id_ = MessageId(ServerMessageId(forum_topic->id_));
|
top_thread_message_id_ = MessageId(ServerMessageId(forum_topic->id_));
|
||||||
title_ = forum_topic->title_;
|
title_ = forum_topic->title_;
|
||||||
icon_color_ = (forum_topic->icon_color_ & 0xFFFFFF);
|
icon_ = ForumTopicIcon(forum_topic->icon_color_, forum_topic->icon_emoji_id_);
|
||||||
if ((forum_topic->flags_ & telegram_api::forumTopic::ICON_EMOJI_ID_MASK) != 0) {
|
|
||||||
icon_custom_emoji_id_ = CustomEmojiId(forum_topic->icon_emoji_id_);
|
|
||||||
}
|
|
||||||
creation_date_ = forum_topic->date_;
|
creation_date_ = forum_topic->date_;
|
||||||
creator_dialog_id_ = DialogId(forum_topic->from_id_);
|
creator_dialog_id_ = DialogId(forum_topic->from_id_);
|
||||||
is_outgoing_ = forum_topic->my_;
|
is_outgoing_ = forum_topic->my_;
|
||||||
is_closed_ = forum_topic->closed_;
|
is_closed_ = forum_topic->closed_;
|
||||||
|
|
||||||
if (creation_date_ <= 0 || !top_thread_message_id_.is_valid() || !creator_dialog_id_.is_valid()) {
|
if (creation_date_ <= 0 || !top_thread_message_id_.is_valid() || !creator_dialog_id_.is_valid()) {
|
||||||
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
|
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
|
||||||
top_thread_message_id_ = MessageId();
|
*this = ForumTopicInfo();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +42,14 @@ td_api::object_ptr<td_api::forumTopicInfo> ForumTopicInfo::get_forum_topic_info_
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto creator_id = get_message_sender_object_const(td, creator_dialog_id_, "get_forum_topic_info_object");
|
auto creator_id = get_message_sender_object_const(td, creator_dialog_id_, "get_forum_topic_info_object");
|
||||||
return td_api::make_object<td_api::forumTopicInfo>(top_thread_message_id_.get(), title_, icon_color_,
|
return td_api::make_object<td_api::forumTopicInfo>(top_thread_message_id_.get(), title_,
|
||||||
icon_custom_emoji_id_.get(), creation_date_, std::move(creator_id),
|
icon_.get_forum_topic_icon_object(), creation_date_,
|
||||||
is_outgoing_, is_closed_);
|
std::move(creator_id), is_outgoing_, is_closed_);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicInfo &topic_info) {
|
StringBuilder &operator<<(StringBuilder &string_builder, const ForumTopicInfo &topic_info) {
|
||||||
return string_builder << "Forum topic " << topic_info.top_thread_message_id_.get() << '/' << topic_info.title_
|
return string_builder << "Forum topic " << topic_info.top_thread_message_id_.get() << '/' << topic_info.title_
|
||||||
<< " by " << topic_info.creator_dialog_id_;
|
<< " by " << topic_info.creator_dialog_id_ << " with " << topic_info.icon_;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/CustomEmojiId.h"
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
|
#include "td/telegram/ForumTopicIcon.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
@ -22,8 +22,7 @@ class Td;
|
|||||||
class ForumTopicInfo {
|
class ForumTopicInfo {
|
||||||
MessageId top_thread_message_id_;
|
MessageId top_thread_message_id_;
|
||||||
string title_;
|
string title_;
|
||||||
int32 icon_color_ = 0x6FB9F0;
|
ForumTopicIcon icon_;
|
||||||
CustomEmojiId icon_custom_emoji_id_;
|
|
||||||
int32 creation_date_ = 0;
|
int32 creation_date_ = 0;
|
||||||
DialogId creator_dialog_id_;
|
DialogId creator_dialog_id_;
|
||||||
bool is_outgoing_ = false;
|
bool is_outgoing_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user