Add createNewStickerSet.source.

This commit is contained in:
levlam 2021-06-18 18:45:57 +03:00
parent cec785022a
commit 16f52b59ab
5 changed files with 23 additions and 13 deletions

View File

@ -5315,10 +5315,11 @@ checkStickerSetName name:string = CheckStickerSetNameResult;
//@description Creates a new sticker set. Returns the newly created sticker set
//@user_id Sticker set owner; ignored for regular users
//@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); 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
//@is_masks True, if stickers are masks. Animated stickers can't be masks
//@stickers List of stickers to be added to the set; must be non-empty. All stickers must be of the same type
createNewStickerSet user_id:int32 title:string name:string is_masks:Bool stickers:vector<InputSticker> = StickerSet;
//@source Source of the sticker set; may be empty if unknown
createNewStickerSet user_id:int32 title:string name:string is_masks: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 @name Sticker set name @sticker Sticker to add to the set

View File

@ -961,8 +961,8 @@ class CreateNewStickerSetQuery : public Td::ResultHandler {
}
void send(tl_object_ptr<telegram_api::InputUser> &&input_user, const string &title, const string &short_name,
bool is_masks, bool is_animated,
vector<tl_object_ptr<telegram_api::inputStickerSetItem>> &&input_stickers) {
bool is_masks, bool is_animated, vector<tl_object_ptr<telegram_api::inputStickerSetItem>> &&input_stickers,
const string &software) {
CHECK(input_user != nullptr);
int32 flags = 0;
@ -972,10 +972,13 @@ class CreateNewStickerSetQuery : public Td::ResultHandler {
if (is_animated) {
flags |= telegram_api::stickers_createStickerSet::ANIMATED_MASK;
}
if (!software.empty()) {
flags |= telegram_api::stickers_createStickerSet::SOFTWARE_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::stickers_createStickerSet(flags, false /*ignored*/, false /*ignored*/, std::move(input_user),
title, short_name, nullptr, std::move(input_stickers), string())));
title, short_name, nullptr, std::move(input_stickers), software)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -4818,7 +4821,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, bool is_masks,
vector<tl_object_ptr<td_api::InputSticker>> &&stickers,
vector<tl_object_ptr<td_api::InputSticker>> &&stickers, string software,
Promise<Unit> &&promise) {
bool is_bot = td_->auth_manager_->is_bot();
if (!is_bot) {
@ -4889,6 +4892,7 @@ void StickersManager::create_new_sticker_set(UserId user_id, string &title, stri
pending_new_sticker_set->is_animated = is_animated;
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);
pending_new_sticker_set->promise = std::move(promise);
auto &multipromise = pending_new_sticker_set->upload_files_multipromise;
@ -5061,7 +5065,7 @@ void StickersManager::on_new_stickers_uploaded(int64 random_id, Result<Unit> res
td_->create_handler<CreateNewStickerSetQuery>(std::move(pending_new_sticker_set->promise))
->send(std::move(input_user), pending_new_sticker_set->title, pending_new_sticker_set->short_name, is_masks,
is_animated, std::move(input_stickers));
is_animated, std::move(input_stickers), std::move(pending_new_sticker_set->software));
}
void StickersManager::add_sticker_to_set(UserId user_id, string &short_name,

View File

@ -174,7 +174,8 @@ class StickersManager : public Actor {
CheckStickerSetNameResult result);
void create_new_sticker_set(UserId user_id, string &title, string &short_name, bool is_masks,
vector<tl_object_ptr<td_api::InputSticker>> &&stickers, Promise<Unit> &&promise);
vector<tl_object_ptr<td_api::InputSticker>> &&stickers, string software,
Promise<Unit> &&promise);
void add_sticker_to_set(UserId user_id, string &short_name, tl_object_ptr<td_api::InputSticker> &&sticker,
Promise<Unit> &&promise);
@ -373,6 +374,7 @@ class StickersManager : public Actor {
bool is_animated;
vector<FileId> file_ids;
vector<tl_object_ptr<td_api::InputSticker>> stickers;
string software;
Promise<> promise;
};

View File

@ -2558,10 +2558,11 @@ class CreateNewStickerSetRequest : public RequestOnceActor {
string name_;
bool is_masks_;
vector<tl_object_ptr<td_api::InputSticker>> stickers_;
string software_;
void do_run(Promise<Unit> &&promise) override {
td->stickers_manager_->create_new_sticker_set(user_id_, title_, name_, is_masks_, std::move(stickers_),
std::move(promise));
std::move(software_), std::move(promise));
}
void do_send_result() override {
@ -2574,13 +2575,14 @@ class CreateNewStickerSetRequest : public RequestOnceActor {
public:
CreateNewStickerSetRequest(ActorShared<Td> td, uint64 request_id, int32 user_id, string &&title, string &&name,
bool is_masks, vector<tl_object_ptr<td_api::InputSticker>> &&stickers)
bool is_masks, vector<tl_object_ptr<td_api::InputSticker>> &&stickers, string &&software)
: RequestOnceActor(std::move(td), request_id)
, user_id_(user_id)
, title_(std::move(title))
, name_(std::move(name))
, is_masks_(is_masks)
, stickers_(std::move(stickers)) {
, stickers_(std::move(stickers))
, software_(std::move(software)) {
}
};
@ -7061,8 +7063,9 @@ void Td::on_request(uint64 id, td_api::checkStickerSetName &request) {
void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
CLEAN_INPUT_STRING(request.title_);
CLEAN_INPUT_STRING(request.name_);
CLEAN_INPUT_STRING(request.source_);
CREATE_REQUEST(CreateNewStickerSetRequest, request.user_id_, std::move(request.title_), std::move(request.name_),
request.is_masks_, std::move(request.stickers_));
request.is_masks_, std::move(request.stickers_), std::move(request.source_));
}
void Td::on_request(uint64 id, td_api::addStickerToSet &request) {

View File

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