Support supergroups in getChatBoostFeatures,
This commit is contained in:
parent
1728dbf561
commit
81f959be99
@ -3735,16 +3735,20 @@ publicForwards total_count:int32 forwards:vector<PublicForward> next_offset:stri
|
||||
//@can_set_emoji_status True, if emoji status can be set
|
||||
//@chat_theme_background_count Number of chat theme backgrounds that can be set as chat background
|
||||
//@can_set_custom_background True, if custom background can be set in the chat for all users
|
||||
chatBoostLevelFeatures level:int32 story_per_day_count:int32 custom_emoji_reaction_count:int32 title_color_count:int32 profile_accent_color_count:int32 can_set_profile_background_custom_emoji:Bool accent_color_count:int32 can_set_background_custom_emoji:Bool can_set_emoji_status:Bool chat_theme_background_count:int32 can_set_custom_background:Bool = ChatBoostLevelFeatures;
|
||||
//@can_set_custom_emoji_sticker_set True, if custom emoji sticker set can be set for the chat
|
||||
//@can_recognize_speech True, if speech recognition can be used for video note and voice note messages by all users
|
||||
chatBoostLevelFeatures level:int32 story_per_day_count:int32 custom_emoji_reaction_count:int32 title_color_count:int32 profile_accent_color_count:int32 can_set_profile_background_custom_emoji:Bool accent_color_count:int32 can_set_background_custom_emoji:Bool can_set_emoji_status:Bool chat_theme_background_count:int32 can_set_custom_background:Bool can_set_custom_emoji_sticker_set:Bool can_recognize_speech:Bool = ChatBoostLevelFeatures;
|
||||
|
||||
//@description Contains a list of features available on the first chat boost levels
|
||||
//@features The list of features
|
||||
//@min_profile_background_custom_emoji_boost_level The minimum boost level required to set custom emoji for profile background
|
||||
//@min_background_custom_emoji_boost_level The minimum boost level required to set custom emoji for reply header and link preview background
|
||||
//@min_background_custom_emoji_boost_level The minimum boost level required to set custom emoji for reply header and link preview background; for channel chats only
|
||||
//@min_emoji_status_boost_level The minimum boost level required to set emoji status
|
||||
//@min_chat_theme_background_boost_level The minimum boost level required to set a chat theme background as chat background
|
||||
//@min_custom_background_boost_level The minimum boost level required to set custom chat background
|
||||
chatBoostFeatures features:vector<chatBoostLevelFeatures> min_profile_background_custom_emoji_boost_level:int32 min_background_custom_emoji_boost_level:int32 min_emoji_status_boost_level:int32 min_chat_theme_background_boost_level:int32 min_custom_background_boost_level:int32 = ChatBoostFeatures;
|
||||
//@min_custom_emoji_sticker_set_boost_level The minimum boost level required to set custom emoji sticker set for the chat; for supergroup chats only
|
||||
//@min_speech_recognition_boost_level The minimum boost level allowing to recognize speech in video note and voice note messages for non-Premium chat members; for supergroup chats only
|
||||
chatBoostFeatures features:vector<chatBoostLevelFeatures> min_profile_background_custom_emoji_boost_level:int32 min_background_custom_emoji_boost_level:int32 min_emoji_status_boost_level:int32 min_chat_theme_background_boost_level:int32 min_custom_background_boost_level:int32 min_custom_emoji_sticker_set_boost_level:int32 min_speech_recognition_boost_level:int32 = ChatBoostFeatures;
|
||||
|
||||
|
||||
//@class ChatBoostSource @description Describes source of a chat boost
|
||||
@ -4793,7 +4797,7 @@ premiumFeatureSavedMessagesTags = PremiumFeature;
|
||||
|
||||
//@class PremiumStoryFeature @description Describes a story feature available to Premium users
|
||||
|
||||
//@description Stories of the current user are displayed before stories of non-premium contacts and channels
|
||||
//@description Stories of the current user are displayed before stories of non-Premium contacts and channels
|
||||
premiumStoryFeaturePriorityOrder = PremiumStoryFeature;
|
||||
|
||||
//@description The ability to hide the fact that the user viewed other's stories
|
||||
@ -8528,35 +8532,40 @@ activateStoryStealthMode = Ok;
|
||||
getStoryPublicForwards story_sender_chat_id:int53 story_id:int32 offset:string limit:int32 = PublicForwards;
|
||||
|
||||
|
||||
//@description Returns list of features available on the specific chat boost level; this is an offline request @level Chat boost level
|
||||
getChatBoostLevelFeatures level:int32 = ChatBoostLevelFeatures;
|
||||
//@description Returns list of features available on the specific chat boost level; this is an offline request
|
||||
//@is_channel Pass true to get the list of features for channels; pass false to get the list of features for supergroups
|
||||
//@level Chat boost level
|
||||
getChatBoostLevelFeatures is_channel:Bool level:int32 = ChatBoostLevelFeatures;
|
||||
|
||||
//@description Returns list of features available on the first 10 chat boost levels; this is an offline request
|
||||
getChatBoostFeatures = ChatBoostFeatures;
|
||||
//@is_channel Pass true to get the list of features for channels; pass false to get the list of features for supergroups
|
||||
getChatBoostFeatures is_channel:Bool = ChatBoostFeatures;
|
||||
|
||||
//@description Returns the list of available chat boost slots for the current user
|
||||
getAvailableChatBoostSlots = ChatBoostSlots;
|
||||
|
||||
//@description Returns the current boost status for a channel chat @chat_id Identifier of the channel chat
|
||||
//@description Returns the current boost status for a supergroup or a channel chat @chat_id Identifier of the chat
|
||||
getChatBoostStatus chat_id:int53 = ChatBoostStatus;
|
||||
|
||||
//@description Boosts a chat and returns the list of available chat boost slots for the current user after the boost @chat_id Identifier of the chat @slot_ids Identifiers of boost slots of the current user from which to apply boosts to the chat
|
||||
//@description Boosts a chat and returns the list of available chat boost slots for the current user after the boost
|
||||
//@chat_id Identifier of the chat
|
||||
//@slot_ids Identifiers of boost slots of the current user from which to apply boosts to the chat
|
||||
boostChat chat_id:int53 slot_ids:vector<int32> = ChatBoostSlots;
|
||||
|
||||
//@description Returns an HTTPS link to boost the specified channel chat @chat_id Identifier of the chat
|
||||
//@description Returns an HTTPS link to boost the specified supergroup or channel chat @chat_id Identifier of the chat
|
||||
getChatBoostLink chat_id:int53 = ChatBoostLink;
|
||||
|
||||
//@description Returns information about a link to boost a chat. Can be called for any internal link of the type internalLinkTypeChatBoost @url The link to boost a chat
|
||||
getChatBoostLinkInfo url:string = ChatBoostLinkInfo;
|
||||
|
||||
//@description Returns list of boosts applied to a chat; requires administrator rights in the channel chat
|
||||
//@description Returns list of boosts applied to a chat; requires administrator rights in the chat
|
||||
//@chat_id Identifier of the chat
|
||||
//@only_gift_codes Pass true to receive only boosts received from gift codes and giveaways created by the chat
|
||||
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
|
||||
//@limit The maximum number of boosts to be returned; up to 100. For optimal performance, the number of returned boosts can be smaller than the specified limit
|
||||
getChatBoosts chat_id:int53 only_gift_codes:Bool offset:string limit:int32 = FoundChatBoosts;
|
||||
|
||||
//@description Returns list of boosts applied to a chat by a given user; requires administrator rights in the channel chat; for bots only
|
||||
//@description Returns list of boosts applied to a chat by a given user; requires administrator rights in the chat; for bots only
|
||||
//@chat_id Identifier of the chat
|
||||
//@user_id Identifier of the user
|
||||
getUserChatBoosts chat_id:int53 user_id:int53 = FoundChatBoosts;
|
||||
@ -9370,13 +9379,15 @@ toggleSupergroupUsernameIsActive supergroup_id:int53 username:string is_active:B
|
||||
//@description Disables all active non-editable usernames of a supergroup or channel, requires owner privileges in the supergroup or channel @supergroup_id Identifier of the supergroup or channel
|
||||
disableAllSupergroupUsernames supergroup_id:int53 = Ok;
|
||||
|
||||
//@description Changes order of active usernames of a supergroup or channel, requires owner privileges in the supergroup or channel @supergroup_id Identifier of the supergroup or channel @usernames The new order of active usernames. All currently active usernames must be specified
|
||||
//@description Changes order of active usernames of a supergroup or channel, requires owner privileges in the supergroup or channel
|
||||
//@supergroup_id Identifier of the supergroup or channel
|
||||
//@usernames The new order of active usernames. All currently active usernames must be specified
|
||||
reorderSupergroupActiveUsernames supergroup_id:int53 usernames:vector<string> = Ok;
|
||||
|
||||
//@description Changes the sticker set of a supergroup; requires can_change_info administrator right @supergroup_id Identifier of the supergroup @sticker_set_id New value of the supergroup sticker set identifier. Use 0 to remove the supergroup sticker set
|
||||
setSupergroupStickerSet supergroup_id:int53 sticker_set_id:int64 = Ok;
|
||||
|
||||
//@description Changes the sticker set of a supergroup; requires can_change_info administrator right. The chat must have at least chatBoostFeatures.min_custom_emoji_sticker_set_boost_level boost level to pass the corresponding color
|
||||
//@description Changes the custom emoji sticker set of a supergroup; requires can_change_info administrator right. The chat must have at least chatBoostFeatures.min_custom_emoji_sticker_set_boost_level boost level to pass the corresponding color
|
||||
//@supergroup_id Identifier of the supergroup
|
||||
//@custom_emoji_sticker_set_id New value of the custom emoji sticker set identifier for the supergroup. Use 0 to remove the custom emoji sticker set in the supergroup
|
||||
setSupergroupCustomEmojiStickerSet supergroup_id:int53 custom_emoji_sticker_set_id:int64 = Ok;
|
||||
|
@ -345,35 +345,42 @@ void BoostManager::tear_down() {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatBoostLevelFeatures> BoostManager::get_chat_boost_level_features_object(
|
||||
int32 level) const {
|
||||
bool for_megagroup, int32 level) const {
|
||||
int32 actual_level =
|
||||
clamp(level, 0, static_cast<int32>(td_->option_manager_->get_option_integer("chat_boost_level_max")));
|
||||
auto theme_counts = td_->theme_manager_->get_dialog_boost_available_count(actual_level, false);
|
||||
auto can_set_profile_background_custom_emoji =
|
||||
actual_level >= td_->option_manager_->get_option_integer("channel_profile_bg_icon_level_min");
|
||||
auto can_set_background_custom_emoji =
|
||||
actual_level >= td_->option_manager_->get_option_integer("channel_bg_icon_level_min");
|
||||
auto can_set_emoji_status =
|
||||
actual_level >= td_->option_manager_->get_option_integer("channel_emoji_status_level_min");
|
||||
auto can_set_custom_background =
|
||||
actual_level >= td_->option_manager_->get_option_integer("channel_custom_wallpaper_level_min");
|
||||
auto have_enough_boost_level = [&](Slice name) {
|
||||
auto needed_boost_level = narrow_cast<int32>(td_->option_manager_->get_option_integer(
|
||||
PSLICE() << (for_megagroup ? "group" : "channel") << '_' << name << "_level_min"));
|
||||
return needed_boost_level != 0 && actual_level >= needed_boost_level;
|
||||
};
|
||||
auto theme_counts = td_->theme_manager_->get_dialog_boost_available_count(actual_level, for_megagroup);
|
||||
auto can_set_profile_background_custom_emoji = have_enough_boost_level("profile_bg_icon");
|
||||
auto can_set_background_custom_emoji = have_enough_boost_level("bg_icon");
|
||||
auto can_set_emoji_status = have_enough_boost_level("emoji_status");
|
||||
auto can_set_custom_background = have_enough_boost_level("custom_wallpaper");
|
||||
auto can_set_custom_emoji_sticker_set = have_enough_boost_level("emoji_stickers");
|
||||
auto can_recognize_speech = have_enough_boost_level("transcribe");
|
||||
return td_api::make_object<td_api::chatBoostLevelFeatures>(
|
||||
level, actual_level, actual_level, theme_counts.title_color_count_, theme_counts.profile_accent_color_count_,
|
||||
can_set_profile_background_custom_emoji, theme_counts.accent_color_count_, can_set_background_custom_emoji,
|
||||
can_set_emoji_status, theme_counts.chat_theme_count_, can_set_custom_background);
|
||||
level, actual_level, for_megagroup ? 0 : actual_level, theme_counts.title_color_count_,
|
||||
theme_counts.profile_accent_color_count_, can_set_profile_background_custom_emoji,
|
||||
theme_counts.accent_color_count_, can_set_background_custom_emoji, can_set_emoji_status,
|
||||
theme_counts.chat_theme_count_, can_set_custom_background, can_set_custom_emoji_sticker_set,
|
||||
can_recognize_speech);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatBoostFeatures> BoostManager::get_chat_boost_features_object() const {
|
||||
td_api::object_ptr<td_api::chatBoostFeatures> BoostManager::get_chat_boost_features_object(bool for_megagroup) const {
|
||||
vector<td_api::object_ptr<td_api::chatBoostLevelFeatures>> features;
|
||||
for (int32 level = 1; level <= 10; level++) {
|
||||
features.push_back(get_chat_boost_level_features_object(level));
|
||||
features.push_back(get_chat_boost_level_features_object(for_megagroup, level));
|
||||
}
|
||||
auto get_min_boost_level = [&](Slice name) {
|
||||
return narrow_cast<int32>(td_->option_manager_->get_option_integer(PSLICE() << "channel_" << name << "_level_min"));
|
||||
return narrow_cast<int32>(td_->option_manager_->get_option_integer(
|
||||
PSLICE() << (for_megagroup ? "group" : "channel") << '_' << name << "_level_min", 1000000000));
|
||||
};
|
||||
return td_api::make_object<td_api::chatBoostFeatures>(
|
||||
std::move(features), get_min_boost_level("profile_bg_icon"), get_min_boost_level("profile_bg_icon"),
|
||||
get_min_boost_level("emoji_status"), get_min_boost_level("wallpaper"), get_min_boost_level("custom_wallpaper"));
|
||||
std::move(features), get_min_boost_level("profile_bg_icon"), get_min_boost_level("bg_icon"),
|
||||
get_min_boost_level("emoji_status"), get_min_boost_level("wallpaper"), get_min_boost_level("custom_wallpaper"),
|
||||
get_min_boost_level("emoji_stickers"), get_min_boost_level("transcribe"));
|
||||
}
|
||||
|
||||
void BoostManager::get_boost_slots(Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) {
|
||||
@ -394,7 +401,7 @@ void BoostManager::get_dialog_boost_status(DialogId dialog_id,
|
||||
|
||||
void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
|
||||
Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "boost_dialog")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
@ -408,7 +415,7 @@ void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
|
||||
}
|
||||
|
||||
Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dialog_id) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_link")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
|
@ -29,9 +29,10 @@ class BoostManager final : public Actor {
|
||||
public:
|
||||
BoostManager(Td *td, ActorShared<> parent);
|
||||
|
||||
td_api::object_ptr<td_api::chatBoostLevelFeatures> get_chat_boost_level_features_object(int32 level) const;
|
||||
td_api::object_ptr<td_api::chatBoostLevelFeatures> get_chat_boost_level_features_object(bool for_megagroup,
|
||||
int32 level) const;
|
||||
|
||||
td_api::object_ptr<td_api::chatBoostFeatures> get_chat_boost_features_object() const;
|
||||
td_api::object_ptr<td_api::chatBoostFeatures> get_chat_boost_features_object(bool for_megagroup) const;
|
||||
|
||||
void get_boost_slots(Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise);
|
||||
|
||||
|
@ -6771,13 +6771,13 @@ void Td::on_request(uint64 id, const td_api::activateStoryStealthMode &request)
|
||||
void Td::on_request(uint64 id, const td_api::getChatBoostLevelFeatures &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
promise.set_value(boost_manager_->get_chat_boost_level_features_object(request.level_));
|
||||
promise.set_value(boost_manager_->get_chat_boost_level_features_object(!request.is_channel_, request.level_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatBoostFeatures &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
promise.set_value(boost_manager_->get_chat_boost_features_object());
|
||||
promise.set_value(boost_manager_->get_chat_boost_features_object(!request.is_channel_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAvailableChatBoostSlots &request) {
|
||||
@ -7798,8 +7798,8 @@ void Td::on_request(uint64 id, const td_api::setSupergroupStickerSet &request) {
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setSupergroupCustomEmojiStickerSet &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_channel_emoji_sticker_set(ChannelId(request.supergroup_id_),
|
||||
StickerSetId(request.custom_emoji_sticker_set_id_), std::move(promise));
|
||||
contacts_manager_->set_channel_emoji_sticker_set(
|
||||
ChannelId(request.supergroup_id_), StickerSetId(request.custom_emoji_sticker_set_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::toggleSupergroupSignMessages &request) {
|
||||
|
@ -4534,11 +4534,14 @@ class CliClient final : public Actor {
|
||||
} else if (op == "assm") {
|
||||
send_request(td_api::make_object<td_api::activateStoryStealthMode>());
|
||||
} else if (op == "gcblf") {
|
||||
bool is_channel;
|
||||
int32 level;
|
||||
get_args(args, level);
|
||||
send_request(td_api::make_object<td_api::getChatBoostLevelFeatures>(level));
|
||||
get_args(args, is_channel, level);
|
||||
send_request(td_api::make_object<td_api::getChatBoostLevelFeatures>(is_channel, level));
|
||||
} else if (op == "gcbf") {
|
||||
send_request(td_api::make_object<td_api::getChatBoostFeatures>());
|
||||
bool is_channel;
|
||||
get_args(args, is_channel);
|
||||
send_request(td_api::make_object<td_api::getChatBoostFeatures>(is_channel));
|
||||
} else if (op == "gacbs") {
|
||||
send_request(td_api::make_object<td_api::getAvailableChatBoostSlots>());
|
||||
} else if (op == "gcbs") {
|
||||
|
Loading…
Reference in New Issue
Block a user