Add td_api::starSubscriptionPricing.

This commit is contained in:
levlam 2024-07-23 14:19:18 +03:00
parent 86a9eb8486
commit 1a8757aa6e
6 changed files with 152 additions and 0 deletions

View File

@ -553,6 +553,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/SpecialStickerSetType.cpp
td/telegram/SponsoredMessageManager.cpp
td/telegram/StarManager.cpp
td/telegram/StarSubscriptionPricing.cpp
td/telegram/StateManager.cpp
td/telegram/StatisticsManager.cpp
td/telegram/StickerFormat.cpp
@ -896,6 +897,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/SpecialStickerSetType.h
td/telegram/SponsoredMessageManager.h
td/telegram/StarManager.h
td/telegram/StarSubscriptionPricing.h
td/telegram/StateManager.h
td/telegram/StatisticsManager.h
td/telegram/StickerFormat.h
@ -1019,6 +1021,7 @@ set(TDLIB_SOURCE_PART2
td/telegram/SecureValue.hpp
td/telegram/SendCodeHelper.hpp
td/telegram/SharedDialog.hpp
td/telegram/StarSubscriptionPricing.hpp
td/telegram/StickerMaskPosition.hpp
td/telegram/StickerPhotoSize.hpp
td/telegram/StickersManager.hpp

View File

@ -412,6 +412,7 @@ function split_file($file, $chunks, $undo) {
'SharedDialog' => 'SharedDialog',
'sponsored_message_manager[_(-](?![.]get[(][)])|SponsoredMessageManager' => 'SponsoredMessageManager',
'star_manager[_(-](?![.]get[(][)])|StarManager' => 'StarManager',
'StarSubscriptionPricing' => 'StarSubscriptionPricing',
'state_manager[_(-](?![.]get[(][)])|StateManager' => 'StateManager',
'statistics_manager[_(-](?![.]get[(][)])|StatisticsManager' => 'StatisticsManager',
'StickerSetId' => 'StickerSetId',

View File

@ -798,6 +798,12 @@ chatPermissions can_send_basic_messages:Bool can_send_audios:Bool can_send_docum
chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messages:Bool can_edit_messages:Bool can_delete_messages:Bool can_invite_users:Bool can_restrict_members:Bool can_pin_messages:Bool can_manage_topics:Bool can_promote_members:Bool can_manage_video_chats:Bool can_post_stories:Bool can_edit_stories:Bool can_delete_stories:Bool is_anonymous:Bool = ChatAdministratorRights;
//@description Describes subscription plan paid in Telegram Stars
//@period The number of seconds between consecutive Telegram Star debiting
//@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 a product that can be paid with invoice
//@title Product title
//@param_description Product description

View File

@ -0,0 +1,55 @@
//
// 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/StarSubscriptionPricing.h"
#include "td/telegram/StarManager.h"
namespace td {
StarSubscriptionPricing::StarSubscriptionPricing(
telegram_api::object_ptr<telegram_api::starsSubscriptionPricing> &&pricing) {
if (pricing != nullptr) {
period_ = pricing->period_;
amount_ = StarManager::get_star_count(pricing->amount_);
}
}
StarSubscriptionPricing::StarSubscriptionPricing(td_api::object_ptr<td_api::starSubscriptionPricing> &&pricing) {
if (pricing != nullptr) {
period_ = pricing->period_;
amount_ = pricing->star_count_;
if (amount_ > 1000000000) {
amount_ = 0;
}
}
}
td_api::object_ptr<td_api::starSubscriptionPricing> StarSubscriptionPricing::get_star_subscription_pricing_object()
const {
if (is_empty()) {
return nullptr;
}
return td_api::make_object<td_api::starSubscriptionPricing>(period_, amount_);
}
telegram_api::object_ptr<telegram_api::starsSubscriptionPricing>
StarSubscriptionPricing::get_input_stars_subscription_pricing() const {
if (is_empty()) {
return nullptr;
}
return telegram_api::make_object<telegram_api::starsSubscriptionPricing>(period_, amount_);
}
bool operator==(const StarSubscriptionPricing &lhs, const StarSubscriptionPricing &rhs) {
return lhs.period_ == rhs.period_ && lhs.amount_ == rhs.amount_;
}
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscriptionPricing &pricing) {
return string_builder << "Subscription for " << pricing.period_ << " days for " << pricing.amount_ << " stars";
}
} // namespace td

View File

@ -0,0 +1,55 @@
//
// 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/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
namespace td {
class StarSubscriptionPricing {
int32 period_ = 0;
int64 amount_ = 0;
friend bool operator==(const StarSubscriptionPricing &lhs, const StarSubscriptionPricing &rhs);
friend StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscriptionPricing &pricing);
public:
StarSubscriptionPricing() = default;
explicit StarSubscriptionPricing(telegram_api::object_ptr<telegram_api::starsSubscriptionPricing> &&pricing);
explicit StarSubscriptionPricing(td_api::object_ptr<td_api::starSubscriptionPricing> &&pricing);
bool is_empty() const {
return period_ <= 0 || amount_ <= 0;
}
td_api::object_ptr<td_api::starSubscriptionPricing> get_star_subscription_pricing_object() const;
telegram_api::object_ptr<telegram_api::starsSubscriptionPricing> get_input_stars_subscription_pricing() const;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
bool operator==(const StarSubscriptionPricing &lhs, const StarSubscriptionPricing &rhs);
inline bool operator!=(const StarSubscriptionPricing &lhs, const StarSubscriptionPricing &rhs) {
return !(lhs == rhs);
}
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscriptionPricing &pricing);
} // namespace td

View File

@ -0,0 +1,32 @@
//
// 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/StarSubscriptionPricing.h"
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"
namespace td {
template <class StorerT>
void StarSubscriptionPricing::store(StorerT &storer) const {
BEGIN_STORE_FLAGS();
END_STORE_FLAGS();
td::store(period_, storer);
td::store(amount_, storer);
}
template <class ParserT>
void StarSubscriptionPricing::parse(ParserT &parser) {
BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS();
td::parse(period_, parser);
td::parse(amount_, parser);
}
} // namespace td