Add chat_id to getStickers.
This commit is contained in:
parent
9e4ae8997b
commit
feafa4aacc
@ -5916,8 +5916,12 @@ sharePhoneNumber user_id:int53 = Ok;
|
||||
getUserProfilePhotos user_id:int53 offset:int32 limit:int32 = ChatPhotos;
|
||||
|
||||
|
||||
//@description Returns stickers from the installed sticker sets that correspond to a given emoji. If the emoji is non-empty, then favorite, recently used or trending stickers may also be returned @sticker_type Type of the sticker sets to return @emoji String representation of emoji. If empty, returns all known installed stickers @limit The maximum number of stickers to be returned
|
||||
getStickers sticker_type:StickerType emoji:string limit:int32 = Stickers;
|
||||
//@description Returns stickers from the installed sticker sets that correspond to a given emoji. If the emoji is non-empty, then favorite, recently used or trending stickers may also be returned
|
||||
//@sticker_type Type of the sticker sets to return
|
||||
//@emoji String representation of emoji. If empty, returns all known installed stickers
|
||||
//@limit The maximum number of stickers to be returned
|
||||
//@chat_id Chat identifier for which to return stickers. Available custom emoji may be different for different chats
|
||||
getStickers sticker_type:StickerType emoji:string limit:int32 chat_id:int53 = Stickers;
|
||||
|
||||
//@description Searches for stickers from public sticker sets that correspond to a given emoji @emoji String representation of emoji; must be non-empty @limit The maximum number of stickers to be returned
|
||||
searchStickers emoji:string limit:int32 = Stickers;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/PhotoSizeSource.h"
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/SecretChatLayer.h"
|
||||
#include "td/telegram/StickerSetId.hpp"
|
||||
#include "td/telegram/StickersManager.hpp"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -3780,8 +3781,8 @@ std::pair<vector<FileId>, vector<FileId>> StickersManager::split_stickers_by_pre
|
||||
return {std::move(regular_sticker_ids), std::move(premium_sticker_ids)};
|
||||
}
|
||||
|
||||
vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string emoji, int32 limit, bool force,
|
||||
Promise<Unit> &&promise) {
|
||||
vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string emoji, int32 limit, DialogId dialog_id,
|
||||
bool force, Promise<Unit> &&promise) {
|
||||
if (limit <= 0) {
|
||||
promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||
return {};
|
||||
@ -3883,6 +3884,26 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string em
|
||||
}
|
||||
}
|
||||
|
||||
bool allow_premium = false;
|
||||
if (sticker_type == StickerType::CustomEmoji) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
if (dialog_id.get_user_id() == td_->contacts_manager_->get_my_id()) {
|
||||
allow_premium = true;
|
||||
}
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
if (td_->contacts_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id()) <
|
||||
static_cast<int32>(SecretChatLayer::SpoilerAndCustomEmojiEntities)) {
|
||||
promise.set_value(Unit());
|
||||
return {};
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vector<FileId> result;
|
||||
auto limit_size_t = static_cast<size_t>(limit);
|
||||
if (emoji.empty()) {
|
||||
@ -3977,7 +3998,7 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string em
|
||||
vector<FileId> regular_sticker_ids;
|
||||
vector<FileId> premium_sticker_ids;
|
||||
std::tie(regular_sticker_ids, premium_sticker_ids) = split_stickers_by_premium(result);
|
||||
if (G()->shared_config().get_option_boolean("is_premium")) {
|
||||
if (G()->shared_config().get_option_boolean("is_premium") || allow_premium) {
|
||||
auto normal_count = G()->shared_config().get_option_integer("stickers_normal_by_emoji_per_premium_num", 2);
|
||||
if (normal_count < 0) {
|
||||
normal_count = 2;
|
||||
|
@ -135,7 +135,8 @@ class StickersManager final : public Actor {
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
BufferSlice thumbnail, int32 layer) const;
|
||||
|
||||
vector<FileId> get_stickers(StickerType sticker_type, string emoji, int32 limit, bool force, Promise<Unit> &&promise);
|
||||
vector<FileId> get_stickers(StickerType sticker_type, string emoji, int32 limit, DialogId dialog_id, bool force,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void search_stickers(string emoji, int32 limit, Promise<td_api::object_ptr<td_api::stickers>> &&promise);
|
||||
|
||||
|
@ -1986,12 +1986,13 @@ class GetStickersRequest final : public RequestActor<> {
|
||||
StickerType sticker_type_;
|
||||
string emoji_;
|
||||
int32 limit_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
vector<FileId> sticker_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
sticker_ids_ =
|
||||
td_->stickers_manager_->get_stickers(sticker_type_, emoji_, limit_, get_tries() < 2, std::move(promise));
|
||||
sticker_ids_ = td_->stickers_manager_->get_stickers(sticker_type_, emoji_, limit_, dialog_id_, get_tries() < 2,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -1999,8 +2000,13 @@ class GetStickersRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
public:
|
||||
GetStickersRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, string &&emoji, int32 limit)
|
||||
: RequestActor(std::move(td), request_id), sticker_type_(sticker_type), emoji_(std::move(emoji)), limit_(limit) {
|
||||
GetStickersRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, string &&emoji, int32 limit,
|
||||
int64 dialog_id)
|
||||
: RequestActor(std::move(td), request_id)
|
||||
, sticker_type_(sticker_type)
|
||||
, emoji_(std::move(emoji))
|
||||
, limit_(limit)
|
||||
, dialog_id_(dialog_id) {
|
||||
set_tries(5);
|
||||
}
|
||||
};
|
||||
@ -6969,8 +6975,8 @@ void Td::on_request(uint64 id, td_api::closeSecretChat &request) {
|
||||
void Td::on_request(uint64 id, td_api::getStickers &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.emoji_);
|
||||
CREATE_REQUEST(GetStickersRequest, get_sticker_type(request.sticker_type_), std::move(request.emoji_),
|
||||
request.limit_);
|
||||
CREATE_REQUEST(GetStickersRequest, get_sticker_type(request.sticker_type_), std::move(request.emoji_), request.limit_,
|
||||
request.chat_id_);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::searchStickers &request) {
|
||||
|
@ -2610,10 +2610,11 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getUser>(user_id));
|
||||
} else if (op == "gsu") {
|
||||
send_request(td_api::make_object<td_api::getSupportUser>());
|
||||
} else if (op == "gs" || op == "gsmm" || op == "gsee") {
|
||||
} else if (op == "gs" || op == "gsmm" || op == "gsee" || op == "gseeme") {
|
||||
SearchQuery query;
|
||||
get_args(args, query);
|
||||
send_request(td_api::make_object<td_api::getStickers>(as_sticker_type(op), query.query, query.limit));
|
||||
send_request(td_api::make_object<td_api::getStickers>(as_sticker_type(op), query.query, query.limit,
|
||||
op == "gseeme" ? my_id_ : 0));
|
||||
} else if (op == "sst") {
|
||||
SearchQuery query;
|
||||
get_args(args, query);
|
||||
|
Loading…
x
Reference in New Issue
Block a user