Add td_api::setStickerMaskPosition.

This commit is contained in:
levlam 2023-02-10 15:52:25 +03:00
parent b895900e75
commit ae0a473cb9
6 changed files with 36 additions and 10 deletions

View File

@ -8030,6 +8030,11 @@ setStickerEmojis sticker:InputFile emojis:string = Ok;
//@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;
//@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
//@sticker Sticker
//@mask_position Position where the mask is placed; pass null to remove mask position
setStickerMaskPosition sticker:InputFile mask_position:maskPosition = Ok;
//@description Returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded
//@location Location of the map center

View File

@ -60,7 +60,8 @@ StickerMaskPosition::StickerMaskPosition(const td_api::object_ptr<td_api::maskPo
}
}();
x_shift_ = mask_position->x_shift_;
y_shift_ = mask_position->y_shift_, scale_ = mask_position->scale_;
y_shift_ = mask_position->y_shift_;
scale_ = mask_position->scale_;
}
telegram_api::object_ptr<telegram_api::maskCoords> StickerMaskPosition::get_input_mask_coords() const {

View File

@ -1395,8 +1395,7 @@ class ChangeStickerQuery final : public Td::ResultHandler {
}
void send(const string &short_name, tl_object_ptr<telegram_api::inputDocument> &&input_document, bool edit_emojis,
const string &emojis, bool edit_mask_position, StickerMaskPosition mask_position, bool edit_keywords,
const string &keywords) {
const string &emojis, StickerMaskPosition mask_position, bool edit_keywords, const string &keywords) {
vector<ChainId> chain_ids;
if (!short_name.empty()) {
chain_ids.emplace_back(short_name);
@ -1405,16 +1404,17 @@ class ChangeStickerQuery final : public Td::ResultHandler {
if (edit_emojis) {
flags |= telegram_api::stickers_changeSticker::EMOJI_MASK;
}
if (edit_mask_position) {
auto mask_coords = mask_position.get_input_mask_coords();
if (mask_coords != nullptr) {
flags |= telegram_api::stickers_changeSticker::MASK_COORDS_MASK;
}
if (edit_keywords) {
flags |= telegram_api::stickers_changeSticker::KEYWORDS_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::stickers_changeSticker(flags, std::move(input_document), emojis,
mask_position.get_input_mask_coords(), keywords),
std::move(chain_ids)));
send_query(
G()->net_query_creator().create(telegram_api::stickers_changeSticker(flags, std::move(input_document), emojis,
std::move(mask_coords), keywords),
std::move(chain_ids)));
}
void on_result(BufferSlice packet) final {
@ -8719,7 +8719,7 @@ void StickersManager::set_sticker_emojis(const td_api::object_ptr<td_api::InputF
TRY_RESULT_PROMISE(promise, input_document, get_sticker_input_document(sticker));
td_->create_handler<ChangeStickerQuery>(std::move(promise))
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), true, emojis, false,
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), true, emojis,
StickerMaskPosition(), false, string());
}
@ -8735,10 +8735,19 @@ void StickersManager::set_sticker_keywords(const td_api::object_ptr<td_api::Inpu
}
}
td_->create_handler<ChangeStickerQuery>(std::move(promise))
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), false, string(), false,
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), false, string(),
StickerMaskPosition(), true, implode(keywords, ','));
}
void StickersManager::set_sticker_mask_position(const td_api::object_ptr<td_api::InputFile> &sticker,
td_api::object_ptr<td_api::maskPosition> &&mask_position,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_document, get_sticker_input_document(sticker));
td_->create_handler<ChangeStickerQuery>(std::move(promise))
->send(input_document.sticker_set_short_name_, std::move(input_document.input_document_), false, string(),
StickerMaskPosition(mask_position), false, string());
}
vector<FileId> StickersManager::get_attached_sticker_file_ids(const vector<int32> &int_file_ids) {
vector<FileId> result;

View File

@ -324,6 +324,9 @@ class StickersManager final : public Actor {
void set_sticker_keywords(const td_api::object_ptr<td_api::InputFile> &sticker, vector<string> &&keywords,
Promise<Unit> &&promise);
void set_sticker_mask_position(const td_api::object_ptr<td_api::InputFile> &sticker,
td_api::object_ptr<td_api::maskPosition> &&mask_position, Promise<Unit> &&promise);
vector<FileId> get_recent_stickers(bool is_attached, Promise<Unit> &&promise);
void on_get_recent_stickers(bool is_repair, bool is_attached,

View File

@ -7354,6 +7354,12 @@ void Td::on_request(uint64 id, td_api::setStickerKeywords &request) {
stickers_manager_->set_sticker_keywords(request.sticker_, std::move(request.keywords_), std::move(promise));
}
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));
}
void Td::on_request(uint64 id, const td_api::getRecentStickers &request) {
CHECK_IS_USER();
CREATE_REQUEST(GetRecentStickersRequest, request.is_attached_);

View File

@ -1212,6 +1212,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::setStickerKeywords &request);
void on_request(uint64 id, td_api::setStickerMaskPosition &request);
void on_request(uint64 id, const td_api::getRecentStickers &request);
void on_request(uint64 id, td_api::addRecentSticker &request);