Improved phrases in service message for giveaway results with credits.

This commit is contained in:
23rd 2024-09-02 13:12:53 +03:00 committed by John Preston
parent d78348fd16
commit 13353bb615
6 changed files with 28 additions and 8 deletions

View file

@ -1898,6 +1898,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_giveaway_results#one" = "{count} winner of the giveaway was randomly selected by Telegram and received private messages with giftcodes.";
"lng_action_giveaway_results#other" = "{count} winners of the giveaway were randomly selected by Telegram and received private messages with giftcodes.";
"lng_action_giveaway_results_some" = "Some winners of the giveaway were randomly selected by Telegram and received private messages with giftcodes.";
"lng_action_giveaway_results_credits#one" = "{count} winner of the giveaway was randomly selected by Telegram and received their prize.";
"lng_action_giveaway_results_credits#other" = "{count} winner of the giveaway was randomly selected by Telegram and received their prize.";
"lng_action_giveaway_results_credits_some" = "Some winners of the giveaway were randomly selected by Telegram and received their prize.";
"lng_action_giveaway_results_none" = "No winners of the giveaway could be selected.";
"lng_action_boost_apply#one" = "{from} boosted the group";
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";

View file

@ -1543,6 +1543,7 @@ ServiceAction ParseServiceAction(
auto content = ActionGiveawayResults();
content.winners = data.vwinners_count().v;
content.unclaimed = data.vunclaimed_count().v;
content.credits = data.is_stars();
result.content = content;
}, [&](const MTPDmessageActionBoostApply &data) {
auto content = ActionBoostApply();

View file

@ -590,6 +590,7 @@ struct ActionGiveawayLaunch {
struct ActionGiveawayResults {
int winners = 0;
int unclaimed = 0;
bool credits = false;
};
struct ActionBoostApply {

View file

@ -1313,11 +1313,20 @@ auto HtmlWriter::Wrap::pushMessage(
return serviceFrom + " just started a giveaway "
"of Telegram Premium subscriptions to its followers.";
}, [&](const ActionGiveawayResults &data) {
return (data.winners > 0)
? NumberToString(data.winners)
+ " of the giveaway were randomly selected by Telegram "
"and received private messages with giftcodes."
: "No winners of the giveaway could be selected.";
return !data.winners
? "No winners of the giveaway could be selected."
: (data.credits && data.unclaimed)
? "Some winners of the giveaway were randomly selected by "
"Telegram and received their prize."
: (!data.credits && data.unclaimed)
? "Some winners of the giveaway were randomly selected by "
"Telegram and received private messages with giftcodes."
: (data.credits && !data.unclaimed)
? NumberToString(data.winners) + " of the giveaway was randomly "
"selected by Telegram and received their prize."
: NumberToString(data.winners) + " of the giveaway was randomly "
"selected by Telegram and received private messages with "
"giftcodes.";
}, [&](const ActionBoostApply &data) {
return serviceFrom
+ " boosted the group "

View file

@ -615,6 +615,7 @@ QByteArray SerializeMessage(
pushAction("giveaway_results");
push("winners", data.winners);
push("unclaimed", data.unclaimed);
push("stars", data.credits);
}, [&](const ActionSetChatWallPaper &data) {
pushActor();
pushAction(data.same

View file

@ -5180,15 +5180,20 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
auto result = PreparedServiceText();
const auto winners = action.vwinners_count().v;
const auto unclaimed = action.vunclaimed_count().v;
const auto credits = action.is_stars();
result.text = {
(!winners
? tr::lng_action_giveaway_results_none(tr::now)
: unclaimed
: (credits && unclaimed)
? tr::lng_action_giveaway_results_credits_some(tr::now)
: (!credits && unclaimed)
? tr::lng_action_giveaway_results_some(tr::now)
: tr::lng_action_giveaway_results(
: (credits && !unclaimed)
? tr::lng_action_giveaway_results_credits(
tr::now,
lt_count,
winners))
winners)
: tr::lng_action_giveaway_results(tr::now, lt_count, winners))
};
return result;
};