diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index db9ee1602..d1c70c8c5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2374,9 +2374,11 @@ messageExtendedMediaUnsupported caption:formattedText = MessageExtendedMedia; //@additional_chat_ids Identifiers of other channel chats that must be subscribed by the users to be eligible for the giveaway. There can be up to getOption("giveaway_additional_chat_count_max") additional chats //@winners_selection_date Point in time (Unix timestamp) when the giveaway is expected to be performed; must be 60-getOption("giveaway_duration_max") seconds in the future in scheduled giveaways //@only_new_members True, if only new members of the chats will be eligible for the giveaway +//@has_public_winners True, if the list of winners of the giveaway will be available to everyone //@country_codes The list of two-letter ISO 3166-1 alpha-2 codes of countries, users from which will be eligible for the giveaway. If empty, then all users can participate in the giveaway. //-There can be up to getOption("giveaway_country_count_max") chosen countries. Users with phone number that was bought on Fragment can participate in any giveaway and the country code "FT" must not be specified in the list -premiumGiveawayParameters boosted_chat_id:int53 additional_chat_ids:vector winners_selection_date:int32 only_new_members:Bool country_codes:vector = PremiumGiveawayParameters; +//@prize_description Additional description of the giveaway prize +premiumGiveawayParameters boosted_chat_id:int53 additional_chat_ids:vector winners_selection_date:int32 only_new_members:Bool has_public_winners:Bool country_codes:vector prize_description:string = PremiumGiveawayParameters; //@description File with the date it was uploaded @file The file @date Point in time (Unix timestamp) when the file was uploaded diff --git a/td/telegram/GiveawayParameters.cpp b/td/telegram/GiveawayParameters.cpp index 4115b876c..eef2d7b93 100644 --- a/td/telegram/GiveawayParameters.cpp +++ b/td/telegram/GiveawayParameters.cpp @@ -12,6 +12,7 @@ #include "td/telegram/DialogId.h" #include "td/telegram/Global.h" #include "td/telegram/MessagesManager.h" +#include "td/telegram/misc.h" #include "td/telegram/OptionManager.h" #include "td/telegram/Td.h" @@ -63,8 +64,13 @@ Result GiveawayParameters::get_giveaway_parameters( td->option_manager_->get_option_integer("giveaway_country_count_max")) { return Status::Error(400, "Too many countries specified"); } + auto prize_description = parameters->prize_description_; + if (!clean_input_string(prize_description)) { + return Status::Error(400, "Strings must be encoded in UTF-8"); + } return GiveawayParameters(boosted_channel_id, std::move(additional_channel_ids), parameters->only_new_members_, - parameters->winners_selection_date_, vector(parameters->country_codes_)); + parameters->has_public_winners_, parameters->winners_selection_date_, + vector(parameters->country_codes_), std::move(prize_description)); } vector GiveawayParameters::get_channel_ids() const { @@ -101,15 +107,21 @@ GiveawayParameters::get_input_store_payment_premium_giveaway(Td *td, const strin if (only_new_subscribers_) { flags |= telegram_api::inputStorePaymentPremiumGiveaway::ONLY_NEW_SUBSCRIBERS_MASK; } + if (winners_are_visible_) { + flags |= telegram_api::inputStorePaymentPremiumGiveaway::WINNERS_ARE_VISIBLE_MASK; + } if (!additional_input_peers.empty()) { flags |= telegram_api::inputStorePaymentPremiumGiveaway::ADDITIONAL_PEERS_MASK; } if (!country_codes_.empty()) { flags |= telegram_api::inputStorePaymentPremiumGiveaway::COUNTRIES_ISO2_MASK; } + if (!prize_description_.empty()) { + flags |= telegram_api::inputStorePaymentPremiumGiveaway::PRIZE_DESCRIPTION_MASK; + } return telegram_api::make_object( flags, false /*ignored*/, false /*ignored*/, std::move(boost_input_peer), std::move(additional_input_peers), - vector(country_codes_), string(), random_id, date_, currency, amount); + vector(country_codes_), prize_description_, random_id, date_, currency, amount); } td_api::object_ptr GiveawayParameters::get_premium_giveaway_parameters_object( @@ -125,14 +137,15 @@ td_api::object_ptr GiveawayParameters::get_pr td->messages_manager_->force_create_dialog(dialog_id, "premiumGiveawayParameters", true); return td_api::make_object( td->messages_manager_->get_chat_id_object(dialog_id, "premiumGiveawayParameters"), std::move(chat_ids), date_, - only_new_subscribers_, vector(country_codes_)); + only_new_subscribers_, winners_are_visible_, vector(country_codes_), prize_description_); } bool operator==(const GiveawayParameters &lhs, const GiveawayParameters &rhs) { return lhs.boosted_channel_id_ == rhs.boosted_channel_id_ && lhs.additional_channel_ids_ == rhs.additional_channel_ids_ && - lhs.only_new_subscribers_ == rhs.only_new_subscribers_ && lhs.date_ == rhs.date_ && - lhs.country_codes_ == rhs.country_codes_; + lhs.only_new_subscribers_ == rhs.only_new_subscribers_ && + lhs.winners_are_visible_ == rhs.winners_are_visible_ && lhs.date_ == rhs.date_ && + lhs.country_codes_ == rhs.country_codes_ && lhs.prize_description_ == rhs.prize_description_; } bool operator!=(const GiveawayParameters &lhs, const GiveawayParameters &rhs) { @@ -143,6 +156,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const GiveawayParameter return string_builder << "Giveaway[" << giveaway_parameters.boosted_channel_id_ << " + " << giveaway_parameters.additional_channel_ids_ << (giveaway_parameters.only_new_subscribers_ ? " only for new members" : "") + << (giveaway_parameters.winners_are_visible_ ? " with public list of winners" : "") << " for countries " << giveaway_parameters.country_codes_ << " at " << giveaway_parameters.date_ << ']'; } diff --git a/td/telegram/GiveawayParameters.h b/td/telegram/GiveawayParameters.h index 07204623e..718ceabad 100644 --- a/td/telegram/GiveawayParameters.h +++ b/td/telegram/GiveawayParameters.h @@ -25,8 +25,10 @@ class GiveawayParameters { ChannelId boosted_channel_id_; vector additional_channel_ids_; bool only_new_subscribers_ = false; + bool winners_are_visible_ = false; int32 date_ = 0; vector country_codes_; + string prize_description_; static Result get_boosted_channel_id(Td *td, DialogId dialog_id); @@ -39,12 +41,15 @@ class GiveawayParameters { GiveawayParameters() = default; GiveawayParameters(ChannelId boosted_channel_id, vector &&additional_channel_ids, - bool only_new_subscribers, int32 date, vector &&country_codes) + bool only_new_subscribers, bool winners_are_visible, int32 date, vector &&country_codes, + string &&prize_description) : boosted_channel_id_(boosted_channel_id) , additional_channel_ids_(std::move(additional_channel_ids)) , only_new_subscribers_(only_new_subscribers) + , winners_are_visible_(winners_are_visible) , date_(date) - , country_codes_(std::move(country_codes)) { + , country_codes_(std::move(country_codes)) + , prize_description_(std::move(prize_description)) { } static Result get_giveaway_parameters(Td *td, diff --git a/td/telegram/GiveawayParameters.hpp b/td/telegram/GiveawayParameters.hpp index 64a21a4df..4341263df 100644 --- a/td/telegram/GiveawayParameters.hpp +++ b/td/telegram/GiveawayParameters.hpp @@ -16,10 +16,13 @@ template void GiveawayParameters::store(StorerT &storer) const { bool has_additional_channel_ids = !additional_channel_ids_.empty(); bool has_country_codes = !country_codes_.empty(); + bool has_prize_description = !prize_description_.empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(only_new_subscribers_); STORE_FLAG(has_additional_channel_ids); STORE_FLAG(has_country_codes); + STORE_FLAG(winners_are_visible_); + STORE_FLAG(has_prize_description); END_STORE_FLAGS(); td::store(boosted_channel_id_, storer); if (has_additional_channel_ids) { @@ -29,16 +32,22 @@ void GiveawayParameters::store(StorerT &storer) const { if (has_country_codes) { td::store(country_codes_, storer); } + if (has_prize_description) { + td::store(prize_description_, storer); + } } template void GiveawayParameters::parse(ParserT &parser) { bool has_additional_channel_ids; bool has_country_codes; + bool has_prize_description; BEGIN_PARSE_FLAGS(); PARSE_FLAG(only_new_subscribers_); PARSE_FLAG(has_additional_channel_ids); PARSE_FLAG(has_country_codes); + PARSE_FLAG(winners_are_visible_); + PARSE_FLAG(has_prize_description); END_PARSE_FLAGS(); td::parse(boosted_channel_id_, parser); if (has_additional_channel_ids) { @@ -48,6 +57,9 @@ void GiveawayParameters::parse(ParserT &parser) { if (has_country_codes) { td::parse(country_codes_, parser); } + if (has_prize_description) { + td::parse(prize_description_, parser); + } } } // namespace td diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index d03e55b79..01bfae0fc 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5741,7 +5741,8 @@ unique_ptr get_message_content(Td *td, FormattedText message, channel_ids.erase(channel_ids.begin()); return td::make_unique( GiveawayParameters{boosted_channel_id, std::move(channel_ids), media->only_new_subscribers_, - media->until_date_, std::move(media->countries_iso2_)}, + media->winners_are_visible_, media->until_date_, std::move(media->countries_iso2_), + std::move(media->prize_description_)}, media->quantity_, media->months_); } case telegram_api::messageMediaGiveawayResults::ID: diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 829890a89..5809c5009 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1004,7 +1004,8 @@ class CliClient final : public Actor { return nullptr; } return td_api::make_object(chat_id, vector(additional_chat_ids), date, - rand_bool(), vector(country_codes)); + rand_bool(), rand_bool(), + vector(country_codes), "prize"); } };