Add td_api::starSubscription.
This commit is contained in:
parent
9315b118e0
commit
070675b4cd
@ -553,6 +553,7 @@ set(TDLIB_SOURCE_PART2
|
||||
td/telegram/SpecialStickerSetType.cpp
|
||||
td/telegram/SponsoredMessageManager.cpp
|
||||
td/telegram/StarManager.cpp
|
||||
td/telegram/StarSubscription.cpp
|
||||
td/telegram/StarSubscriptionPricing.cpp
|
||||
td/telegram/StateManager.cpp
|
||||
td/telegram/StatisticsManager.cpp
|
||||
@ -897,6 +898,7 @@ set(TDLIB_SOURCE_PART2
|
||||
td/telegram/SpecialStickerSetType.h
|
||||
td/telegram/SponsoredMessageManager.h
|
||||
td/telegram/StarManager.h
|
||||
td/telegram/StarSubscription.h
|
||||
td/telegram/StarSubscriptionPricing.h
|
||||
td/telegram/StateManager.h
|
||||
td/telegram/StatisticsManager.h
|
||||
|
@ -412,6 +412,7 @@ function split_file($file, $chunks, $undo) {
|
||||
'SharedDialog' => 'SharedDialog',
|
||||
'sponsored_message_manager[_(-](?![.]get[(][)])|SponsoredMessageManager' => 'SponsoredMessageManager',
|
||||
'star_manager[_(-](?![.]get[(][)])|StarManager' => 'StarManager',
|
||||
'StarSubscription[^P]' => 'StarSubscription',
|
||||
'StarSubscriptionPricing' => 'StarSubscriptionPricing',
|
||||
'state_manager[_(-](?![.]get[(][)])|StateManager' => 'StateManager',
|
||||
'statistics_manager[_(-](?![.]get[(][)])|StatisticsManager' => 'StatisticsManager',
|
||||
|
@ -803,6 +803,14 @@ chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messa
|
||||
//@star_count The amount of Telegram Stars that must be paid for each period
|
||||
starSubscriptionPricing period:int32 star_count:int53 = StarSubscriptionPricing;
|
||||
|
||||
//@description Contains information about subscription to a channel chat paid in Telegram Stars
|
||||
//@id Unique identifier of the subscription
|
||||
//@chat_id Identifier of the channel chat that is subscribed
|
||||
//@expiration_date Point in time (Unix timestamp) when the subscription will expire or expired
|
||||
//@is_canceled True, if the subscription was canceled
|
||||
//@pricing The subscription plan
|
||||
starSubscription id:string chat_id:int53 expiration_date:int32 is_canceled:Bool pricing:starSubscriptionPricing = StarSubscription;
|
||||
|
||||
|
||||
//@description Contains information about a product that can be paid with invoice
|
||||
//@title Product title
|
||||
|
35
td/telegram/StarSubscription.cpp
Normal file
35
td/telegram/StarSubscription.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/telegram/StarSubscription.h"
|
||||
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
StarSubscription::StarSubscription(telegram_api::object_ptr<telegram_api::starsSubscription> &&subscription)
|
||||
: id_(std::move(subscription->id_))
|
||||
, dialog_id_(subscription->peer_)
|
||||
, until_date_(subscription->until_date_)
|
||||
, is_canceled_(subscription->canceled_)
|
||||
, pricing_(std::move(subscription->pricing_)) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::starSubscription> StarSubscription::get_star_subscription_object(Td *td) const {
|
||||
td->dialog_manager_->force_create_dialog(dialog_id_, "starSubscription", true);
|
||||
return td_api::make_object<td_api::starSubscription>(
|
||||
id_, td->dialog_manager_->get_chat_id_object(dialog_id_, "starSubscription"), until_date_, is_canceled_,
|
||||
pricing_.get_star_subscription_pricing_object());
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscription &subscription) {
|
||||
return string_builder << (subscription.is_canceled_ ? "canceled " : "") << "subscription " << subscription.id_
|
||||
<< " to " << subscription.dialog_id_ << " until " << subscription.until_date_ << " for "
|
||||
<< subscription.pricing_;
|
||||
}
|
||||
|
||||
} // namespace td
|
44
td/telegram/StarSubscription.h
Normal file
44
td/telegram/StarSubscription.h
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/StarSubscriptionPricing.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
class StarSubscription {
|
||||
string id_;
|
||||
DialogId dialog_id_;
|
||||
int32 until_date_ = 0;
|
||||
bool is_canceled_ = false;
|
||||
StarSubscriptionPricing pricing_;
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscription &subscription);
|
||||
|
||||
public:
|
||||
StarSubscription() = default;
|
||||
|
||||
explicit StarSubscription(telegram_api::object_ptr<telegram_api::starsSubscription> &&subscription);
|
||||
|
||||
bool is_valid() const {
|
||||
return !id_.empty() && dialog_id_.is_valid() && until_date_ >= 0 && !pricing_.is_empty();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::starSubscription> get_star_subscription_object(Td *td) const;
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscription &subscription);
|
||||
|
||||
} // namespace td
|
Loading…
x
Reference in New Issue
Block a user