From 13353bb6155628f90c7d2b9477472adf211aefd5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 2 Sep 2024 13:12:53 +0300 Subject: [PATCH] Improved phrases in service message for giveaway results with credits. --- Telegram/Resources/langs/lang.strings | 3 +++ .../export/data/export_data_types.cpp | 1 + .../export/data/export_data_types.h | 1 + .../export/output/export_output_html.cpp | 19 ++++++++++++++----- .../export/output/export_output_json.cpp | 1 + Telegram/SourceFiles/history/history_item.cpp | 11 ++++++++--- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 3d1fecb02..7bf546470 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -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"; diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 4ef1ae7ea..ef7f25e51 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -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(); diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index a708f01b4..7adf63d8c 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -590,6 +590,7 @@ struct ActionGiveawayLaunch { struct ActionGiveawayResults { int winners = 0; int unclaimed = 0; + bool credits = false; }; struct ActionBoostApply { diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index 05b6dc2de..00a755bd9 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -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 " diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 964193a7b..c7378f392 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -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 diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index edc2da634..ea92626c4 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -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; };