diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9138bba72..86c16c352 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4955,7 +4955,7 @@ premiumFeatureAdvancedChatManagement = PremiumFeature; //@description A badge in the user's profile premiumFeatureProfileBadge = PremiumFeature; -//@description An emoji status shown along with the user's name +//@description The ability to show an emoji status along with the user's name premiumFeatureEmojiStatus = PremiumFeature; //@description Profile photo animation on message and chat screens @@ -4993,6 +4993,42 @@ premiumFeatureMessagePrivacy = PremiumFeature; premiumFeatureLastSeenTimes = PremiumFeature; +//@class BusinessFeature @description Describes a feature available to Business user accounts + +//@description The ability to set location +businessFeatureLocation = BusinessFeature; + +//@description The ability to set opening hours +businessFeatureOpeningHours = BusinessFeature; + +//@description The ability to use quick replies +businessFeatureQuickReplies = BusinessFeature; + +//@description The ability to set up a greeting message +businessFeatureGreetingMessage = BusinessFeature; + +//@description The ability to set up an away message +businessFeatureAwayMessage = BusinessFeature; + +//@description The ability to create links to the business account with predefined message text +businessFeatureAccountLinks = BusinessFeature; + +//@description The ability to customize intro +businessFeatureIntro = BusinessFeature; + +//@description The ability to connect a bot to the account +businessFeatureBots = BusinessFeature; + +//@description The ability to show an emoji status along with the business name +businessFeatureEmojiStatus = BusinessFeature; + +//@description The ability to display folder names for each chat in the chat list +businessFeatureChatFolderTags = BusinessFeature; + +//@description Allowed to use many additional features for stories +businessFeatureUpgradedStories = BusinessFeature; + + //@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, supergroups, and channels @@ -5026,6 +5062,9 @@ premiumLimit type:PremiumLimitType default_value:int32 premium_value:int32 = Pre //@payment_link An internal link to be opened to pay for Telegram Premium if store payment isn't possible; may be null if direct payment isn't available premiumFeatures features:vector limits:vector payment_link:InternalLinkType = PremiumFeatures; +//@description Contains information about features, available to Business user accounts @features The list of available business features +businessFeatures features:vector = BusinessFeatures; + //@class PremiumSource @description Describes a source from which the Premium features screen is opened @@ -10324,6 +10363,10 @@ assignAppStoreTransaction receipt:bytes purpose:StorePaymentPurpose = Ok; assignGooglePlayTransaction package_name:string store_product_id:string purchase_token:string purpose:StorePaymentPurpose = Ok; +//@description Returns information about features, available to Business users @source Source of the request; pass null if the method is called from settings or some non-standard source +getBusinessFeatures source:BusinessFeature = BusinessFeatures; + + //@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier acceptTermsOfService terms_of_service_id:string = Ok; diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index e9f7cdc2f..936e08e5d 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -111,6 +111,43 @@ static td_api::object_ptr get_premium_feature_object(Sli return nullptr; } +static td_api::object_ptr get_business_feature_object(Slice business_feature) { + if (business_feature == "business_location") { + return td_api::make_object(); + } + if (business_feature == "business_hours") { + return td_api::make_object(); + } + if (business_feature == "quick_replies") { + return td_api::make_object(); + } + if (business_feature == "greeting_message") { + return td_api::make_object(); + } + if (business_feature == "away_message") { + return td_api::make_object(); + } + if (business_feature == "business_links") { + return td_api::make_object(); + } + if (business_feature == "business_intro") { + return td_api::make_object(); + } + if (business_feature == "business_bots") { + return td_api::make_object(); + } + if (business_feature == "emoji_status") { + return td_api::make_object(); + } + if (business_feature == "folder_tags") { + return td_api::make_object(); + } + if (business_feature == "stories") { + return td_api::make_object(); + } + return nullptr; +} + Result> get_boost_input_peer(Td *td, DialogId dialog_id) { if (dialog_id == DialogId()) { return nullptr; @@ -774,6 +811,40 @@ static string get_premium_source(const td_api::PremiumFeature *feature) { return string(); } +static string get_premium_source(const td_api::BusinessFeature *feature) { + if (feature == nullptr) { + return "business"; + } + + switch (feature->get_id()) { + case td_api::businessFeatureLocation::ID: + return "business_location"; + case td_api::businessFeatureOpeningHours::ID: + return "business_hours"; + case td_api::businessFeatureQuickReplies::ID: + return "quick_replies"; + case td_api::businessFeatureGreetingMessage::ID: + return "greeting_message"; + case td_api::businessFeatureAwayMessage::ID: + return "away_message"; + case td_api::businessFeatureAccountLinks::ID: + return "business_links"; + case td_api::businessFeatureIntro::ID: + return "business_intro"; + case td_api::businessFeatureBots::ID: + return "business_bots"; + case td_api::businessFeatureEmojiStatus::ID: + return "emoji_status"; + case td_api::businessFeatureChatFolderTags::ID: + return "folder_tags"; + case td_api::businessFeatureUpgradedStories::ID: + return "stories"; + default: + UNREACHABLE(); + } + return string(); +} + static string get_premium_source(const td_api::PremiumStoryFeature *feature) { if (feature == nullptr) { return string(); @@ -961,6 +1032,39 @@ void get_premium_features(Td *td, const td_api::object_ptr(std::move(features), std::move(limits), std::move(payment_link))); } +void get_business_features(Td *td, const td_api::object_ptr &source, + Promise> &&promise) { + auto business_features = + full_split(G()->get_option_string("business_features", + "business_location,business_hours,quick_replies,greeting_message,away_message," + "business_links,business_intro,business_bots,emoji_status,folder_tags,stories"), + ','); + vector> features; + for (const auto &business_feature : business_features) { + auto feature = get_business_feature_object(business_feature); + if (feature != nullptr) { + features.push_back(std::move(feature)); + } + } + + auto source_str = get_premium_source(source.get()); + if (!source_str.empty()) { + vector> data; + vector> promo_order; + for (const auto &business_feature : business_features) { + promo_order.push_back(telegram_api::make_object(business_feature)); + } + data.push_back(telegram_api::make_object( + "business_promo_order", telegram_api::make_object(std::move(promo_order)))); + data.push_back(telegram_api::make_object( + "source", telegram_api::make_object(source_str))); + save_app_log(td, "business.promo_screen_show", DialogId(), + telegram_api::make_object(std::move(data)), Promise()); + } + + promise.set_value(td_api::make_object(std::move(features))); +} + void view_premium_feature(Td *td, const td_api::object_ptr &feature, Promise &&promise) { auto source = get_premium_source(feature.get()); if (source.empty()) { diff --git a/td/telegram/Premium.h b/td/telegram/Premium.h index 1f5ba36ae..e3659b73f 100644 --- a/td/telegram/Premium.h +++ b/td/telegram/Premium.h @@ -30,6 +30,9 @@ void get_premium_limit(const td_api::object_ptr &limit void get_premium_features(Td *td, const td_api::object_ptr &source, Promise> &&promise); +void get_business_features(Td *td, const td_api::object_ptr &source, + Promise> &&promise); + void view_premium_feature(Td *td, const td_api::object_ptr &feature, Promise &&promise); void click_premium_subscription_button(Td *td, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 703224b70..008d03aae 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -9312,6 +9312,12 @@ void Td::on_request(uint64 id, td_api::assignGooglePlayTransaction &request) { std::move(request.purpose_), std::move(promise)); } +void Td::on_request(uint64 id, const td_api::getBusinessFeatures &request) { + CHECK_IS_USER(); + CREATE_REQUEST_PROMISE(); + get_business_features(this, request.source_, std::move(promise)); +} + void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.terms_of_service_id_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 7d1917c46..0bae464c7 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1794,6 +1794,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::assignGooglePlayTransaction &request); + void on_request(uint64 id, const td_api::getBusinessFeatures &request); + void on_request(uint64 id, td_api::acceptTermsOfService &request); void on_request(uint64 id, const td_api::getCountries &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 13943149f..6ae4337be 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3341,6 +3341,8 @@ class CliClient final : public Actor { get_args(args, parameters, currency, amount); send_request(td_api::make_object( td_api::make_object(parameters, currency, amount))); + } else if (op == "gbf") { + send_request(td_api::make_object(nullptr)); } else if (op == "atos") { send_request(td_api::make_object(args)); } else if (op == "gdli") {