Add td_api::premiumStatus.
This commit is contained in:
parent
52b973af35
commit
c73fa3ed72
@ -475,6 +475,9 @@ chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messa
|
||||
//@payment_link An internal link to be opened for buying Telegram Premium to the user if store payment isn't possible; may be null if direct payment isn't available
|
||||
premiumPaymentOption currency:string amount:int53 discount_percentage:int32 month_count:int32 store_product_id:string payment_link:InternalLinkType = PremiumPaymentOption;
|
||||
|
||||
//@description Describes a custom emoji to be shown instead of the Telegram Premium badge @custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format
|
||||
premiumStatus custom_emoji_id:int64 = PremiumStatus;
|
||||
|
||||
|
||||
//@description Represents a user
|
||||
//@id User identifier
|
||||
@ -484,7 +487,7 @@ premiumPaymentOption currency:string amount:int53 discount_percentage:int32 mont
|
||||
//@phone_number Phone number of the user
|
||||
//@status Current online status of the user
|
||||
//@profile_photo Profile photo of the user; may be null
|
||||
//@premium_badge_custom_emoji_id Identifier of the custom emoji to be shown instead of the Telegram Premium badge; 0 if none. For Telegram Premium users only
|
||||
//@premium_status Premium status to be shown instead of the default Telegram Premium badge; may be null. For Telegram Premium users only
|
||||
//@is_contact The user is a contact of the current user
|
||||
//@is_mutual_contact The user is a contact of the current user and the current user is a contact of the user
|
||||
//@is_verified True, if the user is verified
|
||||
@ -497,7 +500,7 @@ premiumPaymentOption currency:string amount:int53 discount_percentage:int32 mont
|
||||
//@type Type of the user
|
||||
//@language_code IETF language tag of the user's language; only available to bots
|
||||
//@added_to_attachment_menu True, if the user added the current bot to attachment menu; only available to bots
|
||||
user id:int53 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto premium_badge_custom_emoji_id:int64 is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
|
||||
user id:int53 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto premium_status:premiumStatus is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
|
||||
|
||||
|
||||
//@description Contains information about a bot
|
||||
@ -6075,8 +6078,8 @@ setBio bio:string = Ok;
|
||||
//@description Changes the username of the current user @username The new value of the username. Use an empty string to remove the username
|
||||
setUsername username:string = Ok;
|
||||
|
||||
//@description Changes the premium badge of the current user; for Telegram Premium users only @custom_emoji_id Identifier of the custom emoji to use as premium badge; pass 0 to switch to default badge. The custom emoji must have stickerFormatTgs
|
||||
setPremiumBadge custom_emoji_id:int64 = Ok;
|
||||
//@description Changes the premium status of the current user; for Telegram Premium users only @premium_status New premium status; pass null to switch to the default badge
|
||||
setPremiumStatus premium_status:premiumStatus = Ok;
|
||||
|
||||
//@description Changes the location of the current user. Needs to be called if GetOption("is_location_visible") is true and location changes for more than 1 kilometer @location The new location of the user
|
||||
setLocation location:location = Ok;
|
||||
|
@ -16745,8 +16745,8 @@ td_api::object_ptr<td_api::UserStatus> ContactsManager::get_user_status_object(U
|
||||
|
||||
td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_object(UserId user_id) {
|
||||
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
|
||||
user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, 0, false, false, false,
|
||||
false, false, "", false, false, false, td_api::make_object<td_api::userTypeUnknown>(), "", false));
|
||||
user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, nullptr, false, false,
|
||||
false, false, false, "", false, false, false, td_api::make_object<td_api::userTypeUnknown>(), "", false));
|
||||
}
|
||||
|
||||
int64 ContactsManager::get_user_id_object(UserId user_id, const char *source) const {
|
||||
@ -16777,12 +16777,13 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
|
||||
type = make_tl_object<td_api::userTypeRegular>();
|
||||
}
|
||||
|
||||
int64 premium_badge = u->is_premium ? u->emoji_status.get_premium_badge_object() : 0;
|
||||
auto premium_status = u->is_premium ? u->emoji_status.get_premium_status_object() : nullptr;
|
||||
return make_tl_object<td_api::user>(
|
||||
user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u),
|
||||
get_profile_photo_object(td_->file_manager_.get(), u->photo), premium_badge, u->is_contact, u->is_mutual_contact,
|
||||
u->is_verified, u->is_premium, u->is_support, get_restriction_reason_description(u->restriction_reasons),
|
||||
u->is_scam, u->is_fake, u->is_received, std::move(type), u->language_code, u->attach_menu_enabled);
|
||||
get_profile_photo_object(td_->file_manager_.get(), u->photo), std::move(premium_status), u->is_contact,
|
||||
u->is_mutual_contact, u->is_verified, u->is_premium, u->is_support,
|
||||
get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake, u->is_received,
|
||||
std::move(type), u->language_code, u->attach_menu_enabled);
|
||||
}
|
||||
|
||||
vector<int64> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids, const char *source) const {
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -24,7 +25,8 @@ class EmojiStatus {
|
||||
public:
|
||||
EmojiStatus() = default;
|
||||
|
||||
explicit EmojiStatus(int64 custom_emoji_id) : custom_emoji_id_(custom_emoji_id) {
|
||||
explicit EmojiStatus(const td_api::object_ptr<td_api::premiumStatus> &premium_status)
|
||||
: custom_emoji_id_(premium_status != nullptr ? premium_status->custom_emoji_id_ : 0) {
|
||||
}
|
||||
|
||||
explicit EmojiStatus(tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status) {
|
||||
@ -40,8 +42,11 @@ class EmojiStatus {
|
||||
return make_tl_object<telegram_api::emojiStatus>(custom_emoji_id_);
|
||||
}
|
||||
|
||||
int64 get_premium_badge_object() const {
|
||||
return custom_emoji_id_;
|
||||
td_api::object_ptr<td_api::premiumStatus> get_premium_status_object() const {
|
||||
if (is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::premiumStatus>(custom_emoji_id_);
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
|
@ -6727,10 +6727,10 @@ void Td::on_request(uint64 id, td_api::setUsername &request) {
|
||||
contacts_manager_->set_username(request.username_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setPremiumBadge &request) {
|
||||
void Td::on_request(uint64 id, const td_api::setPremiumStatus &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_emoji_status(EmojiStatus(request.custom_emoji_id_), std::move(promise));
|
||||
contacts_manager_->set_emoji_status(EmojiStatus(request.premium_status_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setCommands &request) {
|
||||
|
@ -1012,7 +1012,7 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::setUsername &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setPremiumBadge &request);
|
||||
void on_request(uint64 id, const td_api::setPremiumStatus &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setCommands &request);
|
||||
|
||||
|
@ -4473,8 +4473,10 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::setBio>("\n" + args + "\n" + args + "\n"));
|
||||
} else if (op == "sun") {
|
||||
send_request(td_api::make_object<td_api::setUsername>(args));
|
||||
} else if (op == "spb") {
|
||||
send_request(td_api::make_object<td_api::setPremiumBadge>(to_integer<int64>(args)));
|
||||
} else if (op == "sps") {
|
||||
auto premium_status =
|
||||
args.empty() ? nullptr : td_api::make_object<td_api::premiumStatus>(to_integer<int64>(args));
|
||||
send_request(td_api::make_object<td_api::setPremiumStatus>(std::move(premium_status)));
|
||||
} else if (op == "ccun") {
|
||||
ChatId chat_id;
|
||||
string username;
|
||||
|
Loading…
Reference in New Issue
Block a user