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;
|
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
|
//@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
|
||||||
getStickers sticker_type:StickerType emoji:string limit:int32 = Stickers;
|
//@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
|
//@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;
|
searchStickers emoji:string limit:int32 = Stickers;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||||
#include "td/telegram/PhotoSizeSource.h"
|
#include "td/telegram/PhotoSizeSource.h"
|
||||||
#include "td/telegram/secret_api.h"
|
#include "td/telegram/secret_api.h"
|
||||||
|
#include "td/telegram/SecretChatLayer.h"
|
||||||
#include "td/telegram/StickerSetId.hpp"
|
#include "td/telegram/StickerSetId.hpp"
|
||||||
#include "td/telegram/StickersManager.hpp"
|
#include "td/telegram/StickersManager.hpp"
|
||||||
#include "td/telegram/Td.h"
|
#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)};
|
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,
|
vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string emoji, int32 limit, DialogId dialog_id,
|
||||||
Promise<Unit> &&promise) {
|
bool force, Promise<Unit> &&promise) {
|
||||||
if (limit <= 0) {
|
if (limit <= 0) {
|
||||||
promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||||
return {};
|
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;
|
vector<FileId> result;
|
||||||
auto limit_size_t = static_cast<size_t>(limit);
|
auto limit_size_t = static_cast<size_t>(limit);
|
||||||
if (emoji.empty()) {
|
if (emoji.empty()) {
|
||||||
@ -3977,7 +3998,7 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string em
|
|||||||
vector<FileId> regular_sticker_ids;
|
vector<FileId> regular_sticker_ids;
|
||||||
vector<FileId> premium_sticker_ids;
|
vector<FileId> premium_sticker_ids;
|
||||||
std::tie(regular_sticker_ids, premium_sticker_ids) = split_stickers_by_premium(result);
|
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);
|
auto normal_count = G()->shared_config().get_option_integer("stickers_normal_by_emoji_per_premium_num", 2);
|
||||||
if (normal_count < 0) {
|
if (normal_count < 0) {
|
||||||
normal_count = 2;
|
normal_count = 2;
|
||||||
|
@ -135,7 +135,8 @@ class StickersManager final : public Actor {
|
|||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
BufferSlice thumbnail, int32 layer) const;
|
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);
|
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_;
|
StickerType sticker_type_;
|
||||||
string emoji_;
|
string emoji_;
|
||||||
int32 limit_;
|
int32 limit_;
|
||||||
|
DialogId dialog_id_;
|
||||||
|
|
||||||
vector<FileId> sticker_ids_;
|
vector<FileId> sticker_ids_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) final {
|
void do_run(Promise<Unit> &&promise) final {
|
||||||
sticker_ids_ =
|
sticker_ids_ = td_->stickers_manager_->get_stickers(sticker_type_, emoji_, limit_, dialog_id_, get_tries() < 2,
|
||||||
td_->stickers_manager_->get_stickers(sticker_type_, emoji_, limit_, get_tries() < 2, std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_send_result() final {
|
void do_send_result() final {
|
||||||
@ -1999,8 +2000,13 @@ class GetStickersRequest final : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GetStickersRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, string &&emoji, int32 limit)
|
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) {
|
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);
|
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) {
|
void Td::on_request(uint64 id, td_api::getStickers &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.emoji_);
|
CLEAN_INPUT_STRING(request.emoji_);
|
||||||
CREATE_REQUEST(GetStickersRequest, get_sticker_type(request.sticker_type_), std::move(request.emoji_),
|
CREATE_REQUEST(GetStickersRequest, get_sticker_type(request.sticker_type_), std::move(request.emoji_), request.limit_,
|
||||||
request.limit_);
|
request.chat_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::searchStickers &request) {
|
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));
|
send_request(td_api::make_object<td_api::getUser>(user_id));
|
||||||
} else if (op == "gsu") {
|
} else if (op == "gsu") {
|
||||||
send_request(td_api::make_object<td_api::getSupportUser>());
|
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;
|
SearchQuery query;
|
||||||
get_args(args, 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") {
|
} else if (op == "sst") {
|
||||||
SearchQuery query;
|
SearchQuery query;
|
||||||
get_args(args, query);
|
get_args(args, query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user