diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2afbd364b..8e9acbc5a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -10076,49 +10076,49 @@ checkStickerSetName name:string = CheckStickerSetNameResult; //@source Source of the sticker set; may be empty if unknown createNewStickerSet user_id:int53 title:string name:string sticker_type:StickerType needs_repainting:Bool stickers:vector source:string = StickerSet; -//@description Adds a new sticker to a set; for bots only -//@user_id Sticker set owner +//@description Adds a new sticker to a set +//@user_id Sticker set owner; ignored for regular users //@name Sticker set name //@sticker Sticker to add to the set addStickerToSet user_id:int53 name:string sticker:inputSticker = Ok; -//@description Sets a sticker set thumbnail; for bots only -//@user_id Sticker set owner +//@description Sets a sticker set thumbnail +//@user_id Sticker set owner; ignored for regular users //@name Sticker set name //@thumbnail Thumbnail to set; pass null to remove the sticker set thumbnail //@format Format of the thumbnail; pass null if thumbnail is removed setStickerSetThumbnail user_id:int53 name:string thumbnail:InputFile format:StickerFormat = Ok; -//@description Sets a custom emoji sticker set thumbnail; for bots only +//@description Sets a custom emoji sticker set thumbnail //@name Sticker set name //@custom_emoji_id Identifier of the custom emoji from the sticker set, which will be set as sticker set thumbnail; pass 0 to remove the sticker set thumbnail setCustomEmojiStickerSetThumbnail name:string custom_emoji_id:int64 = Ok; -//@description Sets a sticker set title; for bots only @name Sticker set name @title New sticker set title +//@description Sets a sticker set title @name Sticker set name @title New sticker set title setStickerSetTitle name:string title:string = Ok; -//@description Deleted a sticker set; for bots only @name Sticker set name +//@description Delete a sticker set @name Sticker set name deleteStickerSet name:string = Ok; -//@description Changes the position of a sticker in the set to which it belongs; for bots only. The sticker set must have been created by the bot +//@description Changes the position of a sticker in the set to which it belongs. The sticker set must have been created by the current user //@sticker Sticker //@position New position of the sticker in the set, 0-based setStickerPositionInSet sticker:InputFile position:int32 = Ok; -//@description Removes a sticker from the set to which it belongs; for bots only. The sticker set must have been created by the bot @sticker Sticker +//@description Removes a sticker from the set to which it belongs. The sticker set must have been created by the current user @sticker Sticker removeStickerFromSet sticker:InputFile = Ok; -//@description Changes the list of emoji corresponding to a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot +//@description Changes the list of emoji corresponding to a sticker. The sticker must belong to a regular or custom emoji sticker set created by the current user //@sticker Sticker //@emojis New string with 1-20 emoji corresponding to the sticker setStickerEmojis sticker:InputFile emojis:string = Ok; -//@description Changes the list of keywords of a sticker; for bots only. The sticker must belong to a regular or custom emoji sticker set created by the bot +//@description Changes the list of keywords of a sticker. The sticker must belong to a regular or custom emoji sticker set created by the current user //@sticker Sticker //@keywords List of up to 20 keywords with total length up to 64 characters, which can be used to find the sticker setStickerKeywords sticker:InputFile keywords:vector = Ok; -//@description Changes the mask position of a mask sticker; for bots only. The sticker must belong to a mask sticker set created by the bot +//@description Changes the mask position of a mask sticker. The sticker must belong to a mask sticker set created by the current user //@sticker Sticker //@mask_position Position where the mask is placed; pass null to remove mask position setStickerMaskPosition sticker:InputFile mask_position:maskPosition = Ok; diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 37b1ba127..c853465ca 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -8173,6 +8173,11 @@ StickerFormat StickersManager::guess_sticker_set_format(const StickerSet *sticke void StickersManager::add_sticker_to_set(UserId user_id, string short_name, td_api::object_ptr &&sticker, Promise &&promise) { + bool is_bot = td_->auth_manager_->is_bot(); + if (!is_bot) { + user_id = td_->contacts_manager_->get_my_id(); + } + TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH)); @@ -8272,6 +8277,11 @@ void StickersManager::on_added_sticker_uploaded(int64 random_id, Result re void StickersManager::set_sticker_set_thumbnail(UserId user_id, string short_name, td_api::object_ptr &&thumbnail, StickerFormat format, Promise &&promise) { + bool is_bot = td_->auth_manager_->is_bot(); + if (!is_bot) { + user_id = td_->contacts_manager_->get_my_id(); + } + TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH)); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 0a6e59391..919ba8144 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -8209,7 +8209,6 @@ void Td::on_request(uint64 id, td_api::createNewStickerSet &request) { } void Td::on_request(uint64 id, td_api::addStickerToSet &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.name_); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->add_sticker_to_set(UserId(request.user_id_), std::move(request.name_), std::move(request.sticker_), @@ -8217,7 +8216,6 @@ void Td::on_request(uint64 id, td_api::addStickerToSet &request) { } void Td::on_request(uint64 id, td_api::setStickerSetThumbnail &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.name_); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->set_sticker_set_thumbnail(UserId(request.user_id_), std::move(request.name_), @@ -8226,7 +8224,6 @@ void Td::on_request(uint64 id, td_api::setStickerSetThumbnail &request) { } void Td::on_request(uint64 id, td_api::setCustomEmojiStickerSetThumbnail &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.name_); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->set_custom_emoji_sticker_set_thumbnail( @@ -8234,7 +8231,6 @@ void Td::on_request(uint64 id, td_api::setCustomEmojiStickerSetThumbnail &reques } void Td::on_request(uint64 id, td_api::setStickerSetTitle &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.title_); CREATE_OK_REQUEST_PROMISE(); @@ -8242,33 +8238,28 @@ void Td::on_request(uint64 id, td_api::setStickerSetTitle &request) { } void Td::on_request(uint64 id, td_api::deleteStickerSet &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.name_); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->delete_sticker_set(std::move(request.name_), std::move(promise)); } void Td::on_request(uint64 id, td_api::setStickerPositionInSet &request) { - CHECK_IS_BOT(); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->set_sticker_position_in_set(request.sticker_, request.position_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::removeStickerFromSet &request) { - CHECK_IS_BOT(); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->remove_sticker_from_set(request.sticker_, std::move(promise)); } void Td::on_request(uint64 id, td_api::setStickerEmojis &request) { - CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.emojis_); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->set_sticker_emojis(request.sticker_, request.emojis_, std::move(promise)); } void Td::on_request(uint64 id, td_api::setStickerKeywords &request) { - CHECK_IS_BOT(); for (auto &keyword : request.keywords_) { CLEAN_INPUT_STRING(keyword); } @@ -8277,7 +8268,6 @@ void Td::on_request(uint64 id, td_api::setStickerKeywords &request) { } void Td::on_request(uint64 id, td_api::setStickerMaskPosition &request) { - CHECK_IS_BOT(); CREATE_OK_REQUEST_PROMISE(); stickers_manager_->set_sticker_mask_position(request.sticker_, std::move(request.mask_position_), std::move(promise)); }