Add td_api::suggestedActionProlongPremium.

This commit is contained in:
levlam 2024-04-25 21:44:05 +03:00
parent 1df777bb75
commit 6d57718258
4 changed files with 22 additions and 1 deletions

View File

@ -6494,6 +6494,9 @@ suggestedActionGiftPremiumForChristmas = SuggestedAction;
//@description Suggests the user to set birthdate
suggestedActionSetBirthdate = SuggestedAction;
//@description Suggests the user to prolong about to expire Telegram Premium @manage_premium_subscription_url A URL for managing Telegram Premium subscription
suggestedActionProlongPremium manage_premium_subscription_url:string = SuggestedAction;
//@description Contains a counter @count Count
count count:int32 = Count;

View File

@ -48,6 +48,8 @@ SuggestedAction::SuggestedAction(Slice action_str) {
init(Type::GiftPremiumForChristmas);
} else if (action_str == Slice("BIRTHDAY_SETUP")) {
init(Type::BirthdaySetup);
} else if (action_str == Slice("PREMIUM_GRACE")) {
init(Type::PremiumGrace);
}
}
@ -106,6 +108,9 @@ SuggestedAction::SuggestedAction(const td_api::object_ptr<td_api::SuggestedActio
case td_api::suggestedActionSetBirthdate::ID:
init(Type::BirthdaySetup);
break;
case td_api::suggestedActionProlongPremium::ID:
init(Type::PremiumGrace);
break;
default:
UNREACHABLE();
}
@ -135,6 +140,8 @@ string SuggestedAction::get_suggested_action_str() const {
return "PREMIUM_CHRISTMAS";
case Type::BirthdaySetup:
return "BIRTHDAY_SETUP";
case Type::PremiumGrace:
return "PREMIUM_GRACE";
default:
return string();
}
@ -166,6 +173,9 @@ td_api::object_ptr<td_api::SuggestedAction> SuggestedAction::get_suggested_actio
return td_api::make_object<td_api::suggestedActionGiftPremiumForChristmas>();
case Type::BirthdaySetup:
return td_api::make_object<td_api::suggestedActionSetBirthdate>();
case Type::PremiumGrace:
return td_api::make_object<td_api::suggestedActionProlongPremium>(
G()->get_option_string("premium_manage_subscription_url", "https://T.me/premiumbot?start=status"));
default:
UNREACHABLE();
return nullptr;
@ -232,6 +242,7 @@ void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
case SuggestedAction::Type::RestorePremium:
case SuggestedAction::Type::GiftPremiumForChristmas:
case SuggestedAction::Type::BirthdaySetup:
case SuggestedAction::Type::PremiumGrace:
return send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
std::move(promise));
case SuggestedAction::Type::ConvertToGigagroup:

View File

@ -28,7 +28,8 @@ struct SuggestedAction {
SubscribeToAnnualPremium,
RestorePremium,
GiftPremiumForChristmas,
BirthdaySetup
BirthdaySetup,
PremiumGrace
};
Type type_ = Type::Empty;
DialogId dialog_id_;

View File

@ -2125,6 +2125,12 @@ class CliClient final : public Actor {
if (action == "checks") {
return td_api::make_object<td_api::suggestedActionViewChecksHint>();
}
if (action == "prolong") {
return td_api::make_object<td_api::suggestedActionProlongPremium>("");
}
if (action == "annual") {
return td_api::make_object<td_api::suggestedActionSubscribeToAnnualPremium>();
}
if (begins_with(action, "giga")) {
return td_api::make_object<td_api::suggestedActionConvertToBroadcastGroup>(as_supergroup_id(action.substr(4)));
}