Support creation of repainted custom emoji sticker sets.

This commit is contained in:
levlam 2023-02-08 20:29:53 +03:00
parent 58775c5852
commit 5bbac9d0b4
5 changed files with 20 additions and 8 deletions

View File

@ -7982,9 +7982,10 @@ checkStickerSetName name:string = CheckStickerSetNameResult;
//@title Sticker set title; 1-64 characters
//@name Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive) for bots; 1-64 characters
//@sticker_type Type of the stickers in the set
//@needs_repainting True, if stickers in the sticker set must be repainted; for custom emoji sticker sets only
//@stickers List of stickers to be added to the set; must be non-empty. All stickers must have the same format. For TGS stickers, uploadStickerFile must be used before the sticker is shown
//@source Source of the sticker set; may be empty if unknown
createNewStickerSet user_id:int53 title:string name:string sticker_type:StickerType stickers:vector<inputSticker> source:string = StickerSet;
createNewStickerSet user_id:int53 title:string name:string sticker_type:StickerType needs_repainting:Bool stickers:vector<inputSticker> source:string = StickerSet;
//@description Adds a new sticker to a set; for bots only. Returns the sticker set
//@user_id Sticker set owner

View File

@ -1135,7 +1135,7 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
}
void send(tl_object_ptr<telegram_api::InputUser> &&input_user, const string &title, const string &short_name,
StickerType sticker_type, StickerFormat sticker_format,
StickerType sticker_type, bool has_text_color, StickerFormat sticker_format,
vector<tl_object_ptr<telegram_api::inputStickerSetItem>> &&input_stickers, const string &software) {
CHECK(input_user != nullptr);
@ -1146,6 +1146,9 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
if (sticker_type == StickerType::CustomEmoji) {
flags |= telegram_api::stickers_createStickerSet::EMOJIS_MASK;
}
if (has_text_color) {
flags |= telegram_api::stickers_createStickerSet::TEXT_COLOR_MASK;
}
if (sticker_format == StickerFormat::Tgs) {
flags |= telegram_api::stickers_createStickerSet::ANIMATED_MASK;
}
@ -8000,6 +8003,7 @@ td_api::object_ptr<td_api::CheckStickerSetNameResult> StickersManager::get_check
}
void StickersManager::create_new_sticker_set(UserId user_id, string title, string short_name, StickerType sticker_type,
bool has_text_color,
vector<td_api::object_ptr<td_api::inputSticker>> &&stickers,
string software,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise) {
@ -8024,6 +8028,10 @@ void StickersManager::create_new_sticker_set(UserId user_id, string title, strin
return promise.set_error(Status::Error(400, "At least 1 sticker must be specified"));
}
if (has_text_color && sticker_type != StickerType::CustomEmoji) {
return promise.set_error(Status::Error(400, "Only custom emoji stickers support repainting"));
}
vector<FileId> file_ids;
file_ids.reserve(stickers.size());
vector<FileId> local_file_ids;
@ -8061,6 +8069,7 @@ void StickersManager::create_new_sticker_set(UserId user_id, string title, strin
pending_new_sticker_set->short_name_ = short_name;
pending_new_sticker_set->sticker_format_ = sticker_format;
pending_new_sticker_set->sticker_type_ = sticker_type;
pending_new_sticker_set->has_text_color_ = has_text_color;
pending_new_sticker_set->file_ids_ = std::move(file_ids);
pending_new_sticker_set->stickers_ = std::move(stickers);
pending_new_sticker_set->software_ = std::move(software);
@ -8246,7 +8255,8 @@ void StickersManager::on_new_stickers_uploaded(int64 random_id, Result<Unit> res
td_->create_handler<CreateNewStickerSetQuery>(std::move(promise))
->send(std::move(input_user), pending_new_sticker_set->title_, pending_new_sticker_set->short_name_, sticker_type,
sticker_format, std::move(input_stickers), pending_new_sticker_set->software_);
pending_new_sticker_set->has_text_color_, sticker_format, std::move(input_stickers),
pending_new_sticker_set->software_);
}
void StickersManager::add_sticker_to_set(UserId user_id, string short_name,

View File

@ -296,8 +296,8 @@ class StickersManager final : public Actor {
CheckStickerSetNameResult result);
void create_new_sticker_set(UserId user_id, string title, string short_name, StickerType sticker_type,
vector<td_api::object_ptr<td_api::inputSticker>> &&stickers, string software,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise);
bool has_text_color, vector<td_api::object_ptr<td_api::inputSticker>> &&stickers,
string software, Promise<td_api::object_ptr<td_api::stickerSet>> &&promise);
void add_sticker_to_set(UserId user_id, string short_name, tl_object_ptr<td_api::inputSticker> &&sticker,
Promise<td_api::object_ptr<td_api::stickerSet>> &&promise);
@ -507,6 +507,7 @@ class StickersManager final : public Actor {
string short_name_;
StickerType sticker_type_ = StickerType::Regular;
StickerFormat sticker_format_ = StickerFormat::Unknown;
bool has_text_color_ = false;
vector<FileId> file_ids_;
vector<tl_object_ptr<td_api::inputSticker>> stickers_;
string software_;

View File

@ -7283,8 +7283,8 @@ void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
CREATE_REQUEST_PROMISE();
stickers_manager_->create_new_sticker_set(UserId(request.user_id_), std::move(request.title_),
std::move(request.name_), get_sticker_type(request.sticker_type_),
std::move(request.stickers_), std::move(request.source_),
std::move(promise));
request.needs_repainting_, std::move(request.stickers_),
std::move(request.source_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::addStickerToSet &request) {

View File

@ -2901,7 +2901,7 @@ class CliClient final : public Actor {
return td_api::make_object<td_api::inputSticker>(as_input_file(sticker), "😀", as_sticker_format(op),
as_mask_position(op));
});
send_request(td_api::make_object<td_api::createNewStickerSet>(my_id_, title, name, as_sticker_type(op),
send_request(td_api::make_object<td_api::createNewStickerSet>(my_id_, title, name, as_sticker_type(op), false,
std::move(input_stickers), "tg_cli"));
} else if (op == "sss") {
send_request(td_api::make_object<td_api::searchStickerSet>(args));