Allow methods for sticker set management for regular users.

This commit is contained in:
levlam 2024-03-15 23:47:55 +03:00
parent b15bf856e2
commit 6306a595d8
3 changed files with 22 additions and 22 deletions

View File

@ -10076,49 +10076,49 @@ checkStickerSetName name:string = CheckStickerSetNameResult;
//@source Source of the sticker set; may be empty if unknown //@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<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 //@description Adds a new sticker to a set
//@user_id Sticker set owner //@user_id Sticker set owner; ignored for regular users
//@name Sticker set name //@name Sticker set name
//@sticker Sticker to add to the set //@sticker Sticker to add to the set
addStickerToSet user_id:int53 name:string sticker:inputSticker = Ok; addStickerToSet user_id:int53 name:string sticker:inputSticker = Ok;
//@description Sets a sticker set thumbnail; for bots only //@description Sets a sticker set thumbnail
//@user_id Sticker set owner //@user_id Sticker set owner; ignored for regular users
//@name Sticker set name //@name Sticker set name
//@thumbnail Thumbnail to set; pass null to remove the sticker set thumbnail //@thumbnail Thumbnail to set; pass null to remove the sticker set thumbnail
//@format Format of the thumbnail; pass null if thumbnail is removed //@format Format of the thumbnail; pass null if thumbnail is removed
setStickerSetThumbnail user_id:int53 name:string thumbnail:InputFile format:StickerFormat = Ok; 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 //@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 //@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; 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; 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; 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 //@sticker Sticker
//@position New position of the sticker in the set, 0-based //@position New position of the sticker in the set, 0-based
setStickerPositionInSet sticker:InputFile position:int32 = Ok; 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; 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 //@sticker Sticker
//@emojis New string with 1-20 emoji corresponding to the sticker //@emojis New string with 1-20 emoji corresponding to the sticker
setStickerEmojis sticker:InputFile emojis:string = Ok; 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 //@sticker Sticker
//@keywords List of up to 20 keywords with total length up to 64 characters, which can be used to find the 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<string> = Ok; setStickerKeywords sticker:InputFile keywords:vector<string> = 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 //@sticker Sticker
//@mask_position Position where the mask is placed; pass null to remove mask position //@mask_position Position where the mask is placed; pass null to remove mask position
setStickerMaskPosition sticker:InputFile mask_position:maskPosition = Ok; setStickerMaskPosition sticker:InputFile mask_position:maskPosition = Ok;

View File

@ -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, void StickersManager::add_sticker_to_set(UserId user_id, string short_name,
td_api::object_ptr<td_api::inputSticker> &&sticker, Promise<Unit> &&promise) { td_api::object_ptr<td_api::inputSticker> &&sticker, Promise<Unit> &&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)); 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)); 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<Unit> re
void StickersManager::set_sticker_set_thumbnail(UserId user_id, string short_name, void StickersManager::set_sticker_set_thumbnail(UserId user_id, string short_name,
td_api::object_ptr<td_api::InputFile> &&thumbnail, StickerFormat format, td_api::object_ptr<td_api::InputFile> &&thumbnail, StickerFormat format,
Promise<Unit> &&promise) { Promise<Unit> &&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)); 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)); short_name = clean_username(strip_empty_characters(short_name, MAX_STICKER_SET_SHORT_NAME_LENGTH));

View File

@ -8209,7 +8209,6 @@ void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
} }
void Td::on_request(uint64 id, td_api::addStickerToSet &request) { void Td::on_request(uint64 id, td_api::addStickerToSet &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->add_sticker_to_set(UserId(request.user_id_), std::move(request.name_), std::move(request.sticker_), 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) { void Td::on_request(uint64 id, td_api::setStickerSetThumbnail &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_sticker_set_thumbnail(UserId(request.user_id_), std::move(request.name_), 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) { void Td::on_request(uint64 id, td_api::setCustomEmojiStickerSetThumbnail &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_custom_emoji_sticker_set_thumbnail( 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) { void Td::on_request(uint64 id, td_api::setStickerSetTitle &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CLEAN_INPUT_STRING(request.title_); CLEAN_INPUT_STRING(request.title_);
CREATE_OK_REQUEST_PROMISE(); 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) { void Td::on_request(uint64 id, td_api::deleteStickerSet &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.name_); CLEAN_INPUT_STRING(request.name_);
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->delete_sticker_set(std::move(request.name_), std::move(promise)); stickers_manager_->delete_sticker_set(std::move(request.name_), std::move(promise));
} }
void Td::on_request(uint64 id, td_api::setStickerPositionInSet &request) { void Td::on_request(uint64 id, td_api::setStickerPositionInSet &request) {
CHECK_IS_BOT();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_sticker_position_in_set(request.sticker_, request.position_, std::move(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) { void Td::on_request(uint64 id, const td_api::removeStickerFromSet &request) {
CHECK_IS_BOT();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->remove_sticker_from_set(request.sticker_, std::move(promise)); stickers_manager_->remove_sticker_from_set(request.sticker_, std::move(promise));
} }
void Td::on_request(uint64 id, td_api::setStickerEmojis &request) { void Td::on_request(uint64 id, td_api::setStickerEmojis &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.emojis_); CLEAN_INPUT_STRING(request.emojis_);
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_sticker_emojis(request.sticker_, request.emojis_, std::move(promise)); stickers_manager_->set_sticker_emojis(request.sticker_, request.emojis_, std::move(promise));
} }
void Td::on_request(uint64 id, td_api::setStickerKeywords &request) { void Td::on_request(uint64 id, td_api::setStickerKeywords &request) {
CHECK_IS_BOT();
for (auto &keyword : request.keywords_) { for (auto &keyword : request.keywords_) {
CLEAN_INPUT_STRING(keyword); 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) { void Td::on_request(uint64 id, td_api::setStickerMaskPosition &request) {
CHECK_IS_BOT();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
stickers_manager_->set_sticker_mask_position(request.sticker_, std::move(request.mask_position_), std::move(promise)); stickers_manager_->set_sticker_mask_position(request.sticker_, std::move(request.mask_position_), std::move(promise));
} }