Enable createNewStickerSet for regular users.

This commit is contained in:
levlam 2021-06-17 20:14:48 +03:00
parent a8edbe38db
commit 4048e5ae95
4 changed files with 21 additions and 7 deletions

View File

@ -5303,8 +5303,8 @@ 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 Creates a new sticker set; for bots only. Returns the newly created sticker set
//@user_id Sticker set owner
//@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
//@is_masks True, if stickers are masks. Animated stickers can't be masks

View File

@ -4720,6 +4720,10 @@ tl_object_ptr<telegram_api::inputStickerSetItem> StickersManager::get_input_stic
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) {
bool is_bot = td_->auth_manager_->is_bot();
if (!is_bot) {
user_id = td_->contacts_manager_->get_my_id();
}
auto input_user = td_->contacts_manager_->get_input_user(user_id);
if (input_user == nullptr) {
return promise.set_error(Status::Error(3, "User not found"));

View File

@ -7039,7 +7039,6 @@ void Td::on_request(uint64 id, td_api::uploadStickerFile &request) {
}
void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.title_);
CLEAN_INPUT_STRING(request.name_);
CREATE_REQUEST(CreateNewStickerSetRequest, request.user_id_, std::move(request.title_), std::move(request.name_),

View File

@ -433,7 +433,7 @@ class CliClient final : public Actor {
static char get_delimiter(Slice str) {
std::unordered_set<char> chars;
for (auto c : trim(str)) {
if (!is_alnum(c) && c != '-') {
if (!is_alnum(c) && c != '-' && c != '.' && c != '/') {
chars.insert(c);
}
}
@ -2412,6 +2412,18 @@ 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 == "cnss") {
string title;
string name;
string stickers;
get_args(args, title, name, stickers);
auto input_stickers =
transform(full_split(stickers, get_delimiter(stickers)),
[](string sticker) -> td_api::object_ptr<td_api::InputSticker> {
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)));
} else if (op == "sss") {
send_request(td_api::make_object<td_api::searchStickerSet>(args));
} else if (op == "siss") {
@ -3167,9 +3179,8 @@ class CliClient final : public Actor {
vector<string> attached_files;
get_args(args, chat_id, message_file, args);
attached_files = full_split(args);
send_request(td_api::make_object<td_api::importMessages>(
as_chat_id(chat_id), as_input_file(message_file),
transform(attached_files, [](const string &attached_file) { return as_input_file(attached_file); })));
send_request(td_api::make_object<td_api::importMessages>(as_chat_id(chat_id), as_input_file(message_file),
transform(attached_files, as_input_file)));
} else if (op == "em") {
string chat_id;
string message_id;