Use td_api::StickerType instead of td_api::StickerFormat.
This commit is contained in:
parent
eaf859409e
commit
79f1890613
@ -240,19 +240,19 @@ maskPointChin = MaskPoint;
|
||||
maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPosition;
|
||||
|
||||
|
||||
//@class StickerFormat @description Describes format of a sticker
|
||||
//@class StickerType @description Describes type of a sticker
|
||||
|
||||
//@description The sticker is in TGS format
|
||||
stickerFormatTgs = StickerFormat;
|
||||
//@description The sticker is an image in WEBP format
|
||||
stickerTypeStatic = StickerType;
|
||||
|
||||
//@description The sticker is in WEBM format
|
||||
stickerFormatWebm = StickerFormat;
|
||||
//@description The sticker is an animation in TGS format
|
||||
stickerTypeAnimated = StickerType;
|
||||
|
||||
//@description The sticker is in WEBP format
|
||||
stickerFormatWebp = StickerFormat;
|
||||
//@description The sticker is a video in WEBM format
|
||||
stickerTypeVideo = StickerType;
|
||||
|
||||
//@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
|
||||
stickerFormatWebpMask mask_position:maskPosition = StickerFormat;
|
||||
stickerTypeMask mask_position:maskPosition = StickerType;
|
||||
|
||||
|
||||
//@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands
|
||||
@ -295,9 +295,9 @@ document file_name:string mime_type:string minithumbnail:minithumbnail thumbnail
|
||||
photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector<photoSize> = Photo;
|
||||
|
||||
//@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender
|
||||
//@emoji Emoji corresponding to the sticker @format Sticker format @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
|
||||
//@emoji Emoji corresponding to the sticker @type Sticker type @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 @sticker File containing the sticker
|
||||
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat outline:vector<closedVectorPath> thumbnail:thumbnail sticker:file = Sticker;
|
||||
sticker set_id:int64 width:int32 height:int32 emoji:string type:StickerType outline:vector<closedVectorPath> thumbnail:thumbnail sticker:file = Sticker;
|
||||
|
||||
//@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender
|
||||
//@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender
|
||||
@ -2194,17 +2194,17 @@ emojis emojis:vector<string> = Emojis;
|
||||
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed
|
||||
//@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
|
||||
//@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
|
||||
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets
|
||||
//@is_official True, if the sticker set is official @sticker_type Type of the stickers in the set @is_viewed True for already viewed trending sticker sets
|
||||
//@stickers List of stickers in this set @emojis A list of emoji corresponding to the stickers in the same order. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object
|
||||
stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool stickers:vector<sticker> emojis:vector<emojis> = StickerSet;
|
||||
stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_type:StickerType is_viewed:Bool stickers:vector<sticker> emojis:vector<emojis> = StickerSet;
|
||||
|
||||
//@description Represents short information about a sticker set
|
||||
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be null
|
||||
//@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
|
||||
//@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
|
||||
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets
|
||||
//@is_official True, if the sticker set is official @sticker_type Type of the stickers in the set @is_viewed True for already viewed trending sticker sets
|
||||
//@size Total number of stickers in the set @covers Up to the first 5 stickers from the set, depending on the context. If the application needs more stickers the full sticker set needs to be requested
|
||||
stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
|
||||
stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_type:StickerType is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
|
||||
|
||||
//@description Represents a list of sticker sets @total_count Approximate total number of sticker sets found @sets List of sticker sets
|
||||
stickerSets total_count:int32 sets:vector<stickerSetInfo> = StickerSets;
|
||||
@ -3585,8 +3585,8 @@ proxies proxies:vector<proxy> = Proxies;
|
||||
//@description A sticker to be added to a sticker set
|
||||
//@sticker File with the sticker; must fit in a 512x512 square. For WEBP stickers and masks the file must be in PNG format, which will be converted to WEBP server-side. Otherwise, the file must be local or uploaded within a week. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
|
||||
//@emojis Emojis corresponding to the sticker
|
||||
//@format Sticker format
|
||||
inputSticker sticker:InputFile emojis:string format:StickerFormat = InputSticker;
|
||||
//@type Sticker type
|
||||
inputSticker sticker:InputFile emojis:string type:StickerType = InputSticker;
|
||||
|
||||
|
||||
//@description Represents a date range @start_date Point in time (Unix timestamp) at which the date range begins @end_date Point in time (Unix timestamp) at which the date range ends
|
||||
|
@ -998,17 +998,17 @@ tl_object_ptr<td_api::maskPosition> copy(const td_api::maskPosition &obj) {
|
||||
}
|
||||
|
||||
template <>
|
||||
tl_object_ptr<td_api::StickerFormat> copy(const td_api::StickerFormat &obj) {
|
||||
tl_object_ptr<td_api::StickerType> copy(const td_api::StickerType &obj) {
|
||||
switch (obj.get_id()) {
|
||||
case td_api::stickerFormatWebp::ID:
|
||||
return td_api::make_object<td_api::stickerFormatWebp>();
|
||||
case td_api::stickerFormatTgs::ID:
|
||||
return td_api::make_object<td_api::stickerFormatTgs>();
|
||||
case td_api::stickerFormatWebm::ID:
|
||||
return td_api::make_object<td_api::stickerFormatWebm>();
|
||||
case td_api::stickerFormatWebpMask::ID: {
|
||||
auto &mask_position = static_cast<const td_api::stickerFormatWebpMask &>(obj).mask_position_;
|
||||
return td_api::make_object<td_api::stickerFormatWebpMask>(copy(mask_position));
|
||||
case td_api::stickerTypeStatic::ID:
|
||||
return td_api::make_object<td_api::stickerTypeStatic>();
|
||||
case td_api::stickerTypeAnimated::ID:
|
||||
return td_api::make_object<td_api::stickerTypeAnimated>();
|
||||
case td_api::stickerTypeVideo::ID:
|
||||
return td_api::make_object<td_api::stickerTypeVideo>();
|
||||
case td_api::stickerTypeMask::ID: {
|
||||
auto &mask_position = static_cast<const td_api::stickerTypeMask &>(obj).mask_position_;
|
||||
return td_api::make_object<td_api::stickerTypeMask>(copy(mask_position));
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1082,7 +1082,7 @@ tl_object_ptr<td_api::photo> copy(const td_api::photo &obj) {
|
||||
|
||||
template <>
|
||||
tl_object_ptr<td_api::sticker> copy(const td_api::sticker &obj) {
|
||||
return td_api::make_object<td_api::sticker>(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_),
|
||||
return td_api::make_object<td_api::sticker>(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.type_),
|
||||
transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_),
|
||||
copy(obj.sticker_));
|
||||
}
|
||||
|
@ -23,21 +23,21 @@ StickerFormat get_sticker_format(Slice mime_type) {
|
||||
return StickerFormat::Unknown;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(
|
||||
td_api::object_ptr<td_api::StickerType> get_sticker_type_object(
|
||||
StickerFormat sticker_format, bool is_masks, td_api::object_ptr<td_api::maskPosition> mask_position) {
|
||||
switch (sticker_format) {
|
||||
case StickerFormat::Unknown:
|
||||
LOG(ERROR) << "Have a sticker of unknown format";
|
||||
return td_api::make_object<td_api::stickerFormatWebp>();
|
||||
return td_api::make_object<td_api::stickerTypeStatic>();
|
||||
case StickerFormat::Webp:
|
||||
if (is_masks) {
|
||||
return td_api::make_object<td_api::stickerFormatWebpMask>(std::move(mask_position));
|
||||
return td_api::make_object<td_api::stickerTypeMask>(std::move(mask_position));
|
||||
}
|
||||
return td_api::make_object<td_api::stickerFormatWebp>();
|
||||
return td_api::make_object<td_api::stickerTypeStatic>();
|
||||
case StickerFormat::Tgs:
|
||||
return td_api::make_object<td_api::stickerFormatTgs>();
|
||||
return td_api::make_object<td_api::stickerTypeAnimated>();
|
||||
case StickerFormat::Webm:
|
||||
return td_api::make_object<td_api::stickerFormatWebm>();
|
||||
return td_api::make_object<td_api::stickerTypeVideo>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
|
@ -19,8 +19,8 @@ enum class StickerFormat : int32 { Unknown, Webp, Tgs, Webm };
|
||||
|
||||
StickerFormat get_sticker_format(Slice mime_type);
|
||||
|
||||
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(
|
||||
StickerFormat sticker_format, bool is_masks, td_api::object_ptr<td_api::maskPosition> mask_position);
|
||||
td_api::object_ptr<td_api::StickerType> get_sticker_type_object(StickerFormat sticker_format, bool is_masks,
|
||||
td_api::object_ptr<td_api::maskPosition> mask_position);
|
||||
|
||||
string get_sticker_format_mime_type(StickerFormat sticker_format);
|
||||
|
||||
|
@ -1852,7 +1852,7 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
|
||||
}
|
||||
return make_tl_object<td_api::sticker>(
|
||||
sticker->set_id.get(), width, height, sticker->alt,
|
||||
get_sticker_format_object(sticker->format, sticker->is_mask, std::move(mask_position)),
|
||||
get_sticker_type_object(sticker->format, sticker->is_mask, std::move(mask_position)),
|
||||
get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom),
|
||||
std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id));
|
||||
}
|
||||
@ -1976,7 +1976,7 @@ tl_object_ptr<td_api::stickerSet> StickersManager::get_sticker_set_object(Sticke
|
||||
sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail),
|
||||
get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -2, 1.0),
|
||||
sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official,
|
||||
get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
|
||||
get_sticker_type_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
|
||||
std::move(stickers), std::move(emojis));
|
||||
}
|
||||
|
||||
@ -2023,7 +2023,7 @@ tl_object_ptr<td_api::stickerSetInfo> StickersManager::get_sticker_set_info_obje
|
||||
sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail),
|
||||
get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -3, 1.0),
|
||||
sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official,
|
||||
get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
|
||||
get_sticker_type_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
|
||||
sticker_set->was_loaded ? narrow_cast<int32>(sticker_set->sticker_ids.size()) : sticker_set->sticker_count,
|
||||
std::move(stickers));
|
||||
}
|
||||
@ -5563,18 +5563,18 @@ Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_i
|
||||
return Status::Error(400, "Emojis must be encoded in UTF-8");
|
||||
}
|
||||
|
||||
if (sticker->format_ == nullptr) {
|
||||
return Status::Error(400, "Sticker format must be non-empty");
|
||||
if (sticker->type_ == nullptr) {
|
||||
return Status::Error(400, "Sticker type must be non-empty");
|
||||
}
|
||||
|
||||
switch (sticker->format_->get_id()) {
|
||||
case td_api::stickerFormatWebp::ID:
|
||||
switch (sticker->type_->get_id()) {
|
||||
case td_api::stickerTypeStatic::ID:
|
||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webp, false);
|
||||
case td_api::stickerFormatTgs::ID:
|
||||
case td_api::stickerTypeAnimated::ID:
|
||||
return prepare_input_file(sticker->sticker_, StickerFormat::Tgs, false);
|
||||
case td_api::stickerFormatWebm::ID:
|
||||
case td_api::stickerTypeVideo::ID:
|
||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webm, false);
|
||||
case td_api::stickerFormatWebpMask::ID:
|
||||
case td_api::stickerTypeMask::ID:
|
||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webp, false);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -5670,8 +5670,8 @@ tl_object_ptr<telegram_api::inputStickerSetItem> StickersManager::get_input_stic
|
||||
auto input_document = file_view.main_remote_location().as_input_document();
|
||||
|
||||
tl_object_ptr<telegram_api::maskCoords> mask_coords;
|
||||
if (sticker->format_->get_id() == td_api::stickerFormatWebpMask::ID) {
|
||||
auto sticker_format = static_cast<const td_api::stickerFormatWebpMask *>(sticker->format_.get());
|
||||
if (sticker->type_->get_id() == td_api::stickerTypeMask::ID) {
|
||||
auto sticker_format = static_cast<const td_api::stickerTypeMask *>(sticker->type_.get());
|
||||
auto mask_position = sticker_format->mask_position_.get();
|
||||
if (mask_position != nullptr && mask_position->point_ != nullptr) {
|
||||
auto point = [mask_point_id = mask_position->point_->get_id()] {
|
||||
@ -5792,7 +5792,7 @@ void StickersManager::create_new_sticker_set(UserId user_id, string &title, stri
|
||||
if (is_sticker_format_animated(sticker_format) && is_url) {
|
||||
return promise.set_error(Status::Error(400, "Animated stickers can't be uploaded by URL"));
|
||||
}
|
||||
sticker_formats.insert(sticker->format_->get_id());
|
||||
sticker_formats.insert(sticker->type_->get_id());
|
||||
|
||||
file_ids.push_back(file_id);
|
||||
if (is_url) {
|
||||
@ -5976,7 +5976,7 @@ void StickersManager::on_new_stickers_uploaded(int64 random_id, Result<Unit> res
|
||||
auto &promise = pending_new_sticker_set->promise;
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(pending_new_sticker_set->user_id));
|
||||
|
||||
bool is_masks = pending_new_sticker_set->stickers[0]->format_->get_id() == td_api::stickerFormatWebpMask::ID;
|
||||
bool is_masks = pending_new_sticker_set->stickers[0]->type_->get_id() == td_api::stickerTypeMask::ID;
|
||||
StickerFormat sticker_format = pending_new_sticker_set->sticker_format;
|
||||
|
||||
auto sticker_count = pending_new_sticker_set->stickers.size();
|
||||
|
@ -527,19 +527,19 @@ class CliClient final : public Actor {
|
||||
return to_integer<int32>(trim(str));
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::StickerFormat> as_sticker_format(string sticker_format) {
|
||||
if (!sticker_format.empty() && sticker_format.back() == 't') {
|
||||
return td_api::make_object<td_api::stickerFormatTgs>();
|
||||
static td_api::object_ptr<td_api::StickerType> as_sticker_type(string sticker_type) {
|
||||
if (!sticker_type.empty() && sticker_type.back() == 'a') {
|
||||
return td_api::make_object<td_api::stickerTypeAnimated>();
|
||||
}
|
||||
if (!sticker_format.empty() && sticker_format.back() == 'w') {
|
||||
return td_api::make_object<td_api::stickerFormatWebm>();
|
||||
if (!sticker_type.empty() && sticker_type.back() == 'v') {
|
||||
return td_api::make_object<td_api::stickerTypeVideo>();
|
||||
}
|
||||
if (!sticker_format.empty() && sticker_format.back() == 'm') {
|
||||
if (!sticker_type.empty() && sticker_type.back() == 'm') {
|
||||
auto position = td_api::make_object<td_api::maskPosition>(td_api::make_object<td_api::maskPointEyes>(),
|
||||
Random::fast(-5, 5), Random::fast(-5, 5), 1.0);
|
||||
return td_api::make_object<td_api::stickerFormatWebpMask>(Random::fast_bool() ? nullptr : std::move(position));
|
||||
return td_api::make_object<td_api::stickerTypeMask>(Random::fast_bool() ? nullptr : std::move(position));
|
||||
}
|
||||
return td_api::make_object<td_api::stickerFormatWebp>();
|
||||
return td_api::make_object<td_api::stickerTypeStatic>();
|
||||
}
|
||||
|
||||
static int32 as_limit(Slice str, int32 default_limit = 10) {
|
||||
@ -2579,17 +2579,17 @@ class CliClient final : public Actor {
|
||||
} else if (op == "cssn") {
|
||||
const string &name = args;
|
||||
send_request(td_api::make_object<td_api::checkStickerSetName>(name));
|
||||
} else if (op == "usf" || op == "usft" || op == "usfw" || op == "usfm") {
|
||||
} else if (op == "usf" || op == "usfa" || op == "usfv" || op == "usfm") {
|
||||
send_request(td_api::make_object<td_api::uploadStickerFile>(
|
||||
-1, td_api::make_object<td_api::inputSticker>(as_input_file(args), "😀", as_sticker_format(op))));
|
||||
} else if (op == "cnss" || op == "cnsst" || op == "cnssw" || op == "cnssm") {
|
||||
-1, td_api::make_object<td_api::inputSticker>(as_input_file(args), "😀", as_sticker_type(op))));
|
||||
} else if (op == "cnss" || op == "cnssa" || op == "cnssv" || op == "cnssm") {
|
||||
string title;
|
||||
string name;
|
||||
string stickers;
|
||||
get_args(args, title, name, stickers);
|
||||
auto input_stickers =
|
||||
transform(autosplit(stickers), [op](Slice sticker) -> td_api::object_ptr<td_api::inputSticker> {
|
||||
return td_api::make_object<td_api::inputSticker>(as_input_file(sticker), "😀", as_sticker_format(op));
|
||||
return td_api::make_object<td_api::inputSticker>(as_input_file(sticker), "😀", as_sticker_type(op));
|
||||
});
|
||||
send_request(
|
||||
td_api::make_object<td_api::createNewStickerSet>(my_id_, title, name, std::move(input_stickers), "tg_cli"));
|
||||
|
Loading…
Reference in New Issue
Block a user