Add StickerTypeFullInfo.
This commit is contained in:
parent
14dd89e804
commit
f40a6ff477
@ -300,6 +300,20 @@ stickerTypeMask = StickerType;
|
|||||||
stickerTypeCustomEmoji = StickerType;
|
stickerTypeCustomEmoji = StickerType;
|
||||||
|
|
||||||
|
|
||||||
|
//@class StickerTypeFullInfo @description Contains full information about sticker type
|
||||||
|
|
||||||
|
//@description The sticker is a regular sticker @premium_animation Premium animation of the sticker; may be null. If present, only Telegram Premium users can use the sticker
|
||||||
|
stickerTypeFullInfoRegular premium_animation:file = StickerTypeFullInfo;
|
||||||
|
|
||||||
|
//@description The sticker is a mask in WEBP format to be placed on photos or videos @mask_position Position where the mask is placed; may be null
|
||||||
|
stickerTypeFullInfoMask mask_position:maskPosition = StickerTypeFullInfo;
|
||||||
|
|
||||||
|
//@description The sticker is a custom emoji to be used inside message text and caption. Currently, only Telegram Premium users can use custom emoji
|
||||||
|
//@custom_emoji_id Identifier of the custom emoji
|
||||||
|
//@has_text_color True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, or another appropriate color in other places
|
||||||
|
stickerTypeFullInfoCustomEmoji custom_emoji_id:int64 has_text_color:Bool = StickerTypeFullInfo;
|
||||||
|
|
||||||
|
|
||||||
//@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands
|
//@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands
|
||||||
closedVectorPath commands:vector<VectorPathCommand> = ClosedVectorPath;
|
closedVectorPath commands:vector<VectorPathCommand> = ClosedVectorPath;
|
||||||
|
|
||||||
@ -368,16 +382,11 @@ photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector<photoSize> = Ph
|
|||||||
//@height Sticker height; as defined by the sender
|
//@height Sticker height; as defined by the sender
|
||||||
//@emoji Emoji corresponding to the sticker
|
//@emoji Emoji corresponding to the sticker
|
||||||
//@format Sticker format
|
//@format Sticker format
|
||||||
//@type Sticker type
|
//@full_type Sticker full type
|
||||||
//@mask_position Position where the mask is placed; may be null even the sticker is a mask
|
|
||||||
//@custom_emoji_id Identifier of the emoji if the sticker is a custom emoji
|
|
||||||
//@has_text_color True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, or other appropriate color in other places; for custom emoji only
|
|
||||||
//@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
|
//@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
|
||||||
//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null
|
//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null
|
||||||
//@is_premium True, if only Premium users can use the sticker
|
|
||||||
//@premium_animation Premium animation of the sticker; may be null
|
|
||||||
//@sticker File containing the sticker
|
//@sticker File containing the sticker
|
||||||
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition custom_emoji_id:int64 has_text_color:Bool outline:vector<closedVectorPath> thumbnail:thumbnail is_premium:Bool premium_animation:file sticker:file = Sticker;
|
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat full_type:StickerTypeFullInfo outline:vector<closedVectorPath> thumbnail:thumbnail sticker:file = Sticker;
|
||||||
|
|
||||||
//@description Describes a video file
|
//@description Describes a video file
|
||||||
//@duration Duration of the video, in seconds; as defined by the sender
|
//@duration Duration of the video, in seconds; as defined by the sender
|
||||||
|
@ -1169,14 +1169,20 @@ tl_object_ptr<td_api::maskPosition> copy(const td_api::maskPosition &obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
tl_object_ptr<td_api::StickerType> copy(const td_api::StickerType &obj) {
|
tl_object_ptr<td_api::StickerTypeFullInfo> copy(const td_api::StickerTypeFullInfo &obj) {
|
||||||
switch (obj.get_id()) {
|
switch (obj.get_id()) {
|
||||||
case td_api::stickerTypeRegular::ID:
|
case td_api::stickerTypeFullInfoRegular::ID: {
|
||||||
return td_api::make_object<td_api::stickerTypeRegular>();
|
auto &info = static_cast<const td_api::stickerTypeFullInfoRegular &>(obj);
|
||||||
case td_api::stickerTypeMask::ID:
|
return td_api::make_object<td_api::stickerTypeFullInfoRegular>(copy(info.premium_animation_));
|
||||||
return td_api::make_object<td_api::stickerTypeMask>();
|
}
|
||||||
case td_api::stickerTypeCustomEmoji::ID:
|
case td_api::stickerTypeFullInfoMask::ID: {
|
||||||
return td_api::make_object<td_api::stickerTypeCustomEmoji>();
|
auto &info = static_cast<const td_api::stickerTypeFullInfoMask &>(obj);
|
||||||
|
return td_api::make_object<td_api::stickerTypeFullInfoMask>(copy(info.mask_position_));
|
||||||
|
}
|
||||||
|
case td_api::stickerTypeFullInfoCustomEmoji::ID: {
|
||||||
|
auto &info = static_cast<const td_api::stickerTypeFullInfoCustomEmoji &>(obj);
|
||||||
|
return td_api::make_object<td_api::stickerTypeFullInfoCustomEmoji>(info.custom_emoji_id_, info.has_text_color_);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -1269,10 +1275,9 @@ tl_object_ptr<td_api::photo> copy(const td_api::photo &obj) {
|
|||||||
|
|
||||||
template <>
|
template <>
|
||||||
tl_object_ptr<td_api::sticker> copy(const td_api::sticker &obj) {
|
tl_object_ptr<td_api::sticker> copy(const td_api::sticker &obj) {
|
||||||
return td_api::make_object<td_api::sticker>(
|
return td_api::make_object<td_api::sticker>(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_),
|
||||||
obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), copy(obj.type_), copy(obj.mask_position_),
|
copy(obj.full_type_), transform(obj.outline_, copy_closed_vector_path),
|
||||||
obj.custom_emoji_id_, obj.has_text_color_, transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_),
|
copy(obj.thumbnail_), copy(obj.sticker_));
|
||||||
obj.is_premium_, copy(obj.premium_animation_), copy(obj.sticker_));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -5371,7 +5371,10 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
|||||||
const auto *m = static_cast<const MessageSticker *>(content);
|
const auto *m = static_cast<const MessageSticker *>(content);
|
||||||
auto sticker = td->stickers_manager_->get_sticker_object(m->file_id);
|
auto sticker = td->stickers_manager_->get_sticker_object(m->file_id);
|
||||||
CHECK(sticker != nullptr);
|
CHECK(sticker != nullptr);
|
||||||
auto is_premium = m->is_premium && sticker->premium_animation_ != nullptr;
|
auto is_premium =
|
||||||
|
m->is_premium && sticker->full_type_->get_id() == td_api::stickerTypeFullInfoRegular::ID &&
|
||||||
|
static_cast<const td_api::stickerTypeFullInfoRegular *>(sticker->full_type_.get())->premium_animation_ !=
|
||||||
|
nullptr;
|
||||||
return make_tl_object<td_api::messageSticker>(std::move(sticker), is_premium);
|
return make_tl_object<td_api::messageSticker>(std::move(sticker), is_premium);
|
||||||
}
|
}
|
||||||
case MessageContentType::Text: {
|
case MessageContentType::Text: {
|
||||||
|
@ -2176,15 +2176,9 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
|
|||||||
|
|
||||||
const auto *sticker = get_sticker(file_id);
|
const auto *sticker = get_sticker(file_id);
|
||||||
CHECK(sticker != nullptr);
|
CHECK(sticker != nullptr);
|
||||||
auto mask_position = sticker->point_ >= 0
|
|
||||||
? make_tl_object<td_api::maskPosition>(get_mask_point_object(sticker->point_),
|
|
||||||
sticker->x_shift_, sticker->y_shift_, sticker->scale_)
|
|
||||||
: nullptr;
|
|
||||||
|
|
||||||
const PhotoSize &thumbnail = sticker->m_thumbnail_.file_id.is_valid() ? sticker->m_thumbnail_ : sticker->s_thumbnail_;
|
const PhotoSize &thumbnail = sticker->m_thumbnail_.file_id.is_valid() ? sticker->m_thumbnail_ : sticker->s_thumbnail_;
|
||||||
auto thumbnail_format = PhotoFormat::Webp;
|
auto thumbnail_format = PhotoFormat::Webp;
|
||||||
int64 document_id = 0;
|
int64 document_id = 0;
|
||||||
CustomEmojiId custom_emoji_id;
|
|
||||||
if (!sticker->set_id_.is_valid()) {
|
if (!sticker->set_id_.is_valid()) {
|
||||||
auto sticker_file_view = td_->file_manager_->get_file_view(sticker->file_id_);
|
auto sticker_file_view = td_->file_manager_->get_file_view(sticker->file_id_);
|
||||||
if (sticker_file_view.is_encrypted()) {
|
if (sticker_file_view.is_encrypted()) {
|
||||||
@ -2202,8 +2196,6 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (sticker->type_ == StickerType::CustomEmoji) {
|
|
||||||
custom_emoji_id = get_custom_emoji_id(sticker->file_id_);
|
|
||||||
}
|
}
|
||||||
auto thumbnail_object = get_thumbnail_object(td_->file_manager_.get(), thumbnail, thumbnail_format);
|
auto thumbnail_object = get_thumbnail_object(td_->file_manager_.get(), thumbnail, thumbnail_format);
|
||||||
int32 width = sticker->dimensions_.width;
|
int32 width = sticker->dimensions_.width;
|
||||||
@ -2222,15 +2214,34 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
|
|||||||
height *= 3;
|
height *= 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto premium_animation_object = sticker->premium_animation_file_id_.is_valid()
|
auto full_type = [&]() -> td_api::object_ptr<td_api::StickerTypeFullInfo> {
|
||||||
? td_->file_manager_->get_file_object(sticker->premium_animation_file_id_)
|
switch (sticker->type_) {
|
||||||
: nullptr;
|
case StickerType::Regular: {
|
||||||
|
auto premium_animation_object = sticker->premium_animation_file_id_.is_valid()
|
||||||
|
? td_->file_manager_->get_file_object(sticker->premium_animation_file_id_)
|
||||||
|
: nullptr;
|
||||||
|
return td_api::make_object<td_api::stickerTypeFullInfoRegular>(std::move(premium_animation_object));
|
||||||
|
}
|
||||||
|
case StickerType::Mask: {
|
||||||
|
td_api::object_ptr<td_api::maskPosition> mask_position;
|
||||||
|
if (sticker->point_ >= 0) {
|
||||||
|
mask_position = td_api::make_object<td_api::maskPosition>(
|
||||||
|
get_mask_point_object(sticker->point_), sticker->x_shift_, sticker->y_shift_, sticker->scale_);
|
||||||
|
}
|
||||||
|
return td_api::make_object<td_api::stickerTypeFullInfoMask>(std::move(mask_position));
|
||||||
|
}
|
||||||
|
case StickerType::CustomEmoji:
|
||||||
|
return td_api::make_object<td_api::stickerTypeFullInfoCustomEmoji>(get_custom_emoji_id(sticker->file_id_).get(),
|
||||||
|
sticker->has_text_color_);
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}();
|
||||||
return td_api::make_object<td_api::sticker>(
|
return td_api::make_object<td_api::sticker>(
|
||||||
sticker->set_id_.get(), width, height, sticker->alt_, get_sticker_format_object(sticker->format_),
|
sticker->set_id_.get(), width, height, sticker->alt_, get_sticker_format_object(sticker->format_),
|
||||||
get_sticker_type_object(sticker->type_), std::move(mask_position), custom_emoji_id.get(),
|
std::move(full_type), get_sticker_minithumbnail(sticker->minithumbnail_, sticker->set_id_, document_id, zoom),
|
||||||
sticker->has_text_color_, get_sticker_minithumbnail(sticker->minithumbnail_, sticker->set_id_, document_id, zoom),
|
std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id));
|
||||||
std::move(thumbnail_object), sticker->is_premium_, std::move(premium_animation_object),
|
|
||||||
td_->file_manager_->get_file_object(file_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::stickers> StickersManager::get_stickers_object(const vector<FileId> &sticker_ids) const {
|
tl_object_ptr<td_api::stickers> StickersManager::get_stickers_object(const vector<FileId> &sticker_ids) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user