Add the method getSuggestedStickerSetName.
This commit is contained in:
parent
4048e5ae95
commit
706647bdbc
@ -5303,6 +5303,9 @@ setBotUpdatesStatus pending_update_count:int32 error_message:string = Ok;
|
||||
//@user_id Sticker file owner @png_sticker PNG image with the sticker; must be up to 512 KB in size and fit in 512x512 square
|
||||
uploadStickerFile user_id:int32 png_sticker:InputFile = File;
|
||||
|
||||
//@description Returns a suggested name for a new sticker set with a given title @title Sticker set title; 1-64 characters
|
||||
getSuggestedStickerSetName title:string = Text;
|
||||
|
||||
//@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
|
||||
|
@ -900,6 +900,34 @@ class UploadStickerFileQuery : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class SuggestStickerSetShortNameQuery : public Td::ResultHandler {
|
||||
Promise<string> promise_;
|
||||
|
||||
public:
|
||||
explicit SuggestStickerSetShortNameQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(const string &title) {
|
||||
send_query(G()->net_query_creator().create(telegram_api::stickers_suggestShortName(title)));
|
||||
}
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
auto result_ptr = fetch_result<telegram_api::stickers_suggestShortName>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
promise_.set_value(std::move(ptr->short_name_));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
if (status.message() == "TITLE_INVALID") {
|
||||
return promise_.set_value(string());
|
||||
}
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class CreateNewStickerSetQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -4717,6 +4745,15 @@ tl_object_ptr<telegram_api::inputStickerSetItem> StickersManager::get_input_stic
|
||||
get_input_sticker_emojis(sticker), std::move(mask_coords));
|
||||
}
|
||||
|
||||
void StickersManager::get_suggested_sticker_set_name(string title, Promise<string> &&promise) {
|
||||
title = strip_empty_characters(title, MAX_STICKER_SET_TITLE_LENGTH);
|
||||
if (title.empty()) {
|
||||
return promise.set_error(Status::Error(3, "Sticker set title can't be empty"));
|
||||
}
|
||||
|
||||
td_->create_handler<SuggestStickerSetShortNameQuery>(std::move(promise))->send(title);
|
||||
}
|
||||
|
||||
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,
|
||||
Promise<Unit> &&promise) {
|
||||
|
@ -165,6 +165,8 @@ class StickersManager : public Actor {
|
||||
|
||||
FileId upload_sticker_file(UserId user_id, const tl_object_ptr<td_api::InputFile> &sticker, Promise<Unit> &&promise);
|
||||
|
||||
void get_suggested_sticker_set_name(string short_name, Promise<string> &&promise);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -7038,6 +7038,19 @@ void Td::on_request(uint64 id, td_api::uploadStickerFile &request) {
|
||||
CREATE_REQUEST(UploadStickerFileRequest, request.user_id_, std::move(request.png_sticker_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getSuggestedStickerSetName &request) {
|
||||
CLEAN_INPUT_STRING(request.title_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
||||
}
|
||||
});
|
||||
stickers_manager_->get_suggested_sticker_set_name(std::move(request.title_), std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
|
||||
CLEAN_INPUT_STRING(request.title_);
|
||||
CLEAN_INPUT_STRING(request.name_);
|
||||
|
@ -974,6 +974,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::uploadStickerFile &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getSuggestedStickerSetName &request);
|
||||
|
||||
void on_request(uint64 id, td_api::createNewStickerSet &request);
|
||||
|
||||
void on_request(uint64 id, td_api::addStickerToSet &request);
|
||||
|
@ -2412,6 +2412,9 @@ class CliClient final : public Actor {
|
||||
string category;
|
||||
get_args(args, chat_id, category);
|
||||
send_request(td_api::make_object<td_api::removeTopChat>(get_top_chat_category(category), as_chat_id(chat_id)));
|
||||
} else if (op == "gsssn") {
|
||||
string title = args;
|
||||
send_request(td_api::make_object<td_api::getSuggestedStickerSetName>(title));
|
||||
} else if (op == "cnss") {
|
||||
string title;
|
||||
string name;
|
||||
|
Loading…
Reference in New Issue
Block a user