diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 8eb7c8e09..387db2670 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1209,6 +1209,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_proximity_reached" = "{from} is now within {distance} from {user}"; "lng_action_proximity_reached_you" = "{from} is now within {distance} from you"; "lng_action_you_proximity_reached" = "You are now within {distance} from {user}"; +"lng_action_you_theme_changed" = "You changed chat theme to {emoji}"; +"lng_action_theme_changed" = "{from} changed chat theme to {emoji}"; +"lng_action_theme_changed_channel" = "Channel theme changed to {emoji}"; +"lng_action_you_theme_disabled" = "You disabled chat theme"; +"lng_action_theme_disabled" = "{from} disabled chat theme"; +"lng_action_theme_disabled_channel" = "Channel theme disabled"; "lng_action_proximity_distance_m#one" = "{count} meter"; "lng_action_proximity_distance_m#other" = "{count} metres"; "lng_action_proximity_distance_km#one" = "{count} km"; diff --git a/Telegram/Resources/langs/stale.py b/Telegram/Resources/langs/stale.py new file mode 100644 index 000000000..7b219f2c7 --- /dev/null +++ b/Telegram/Resources/langs/stale.py @@ -0,0 +1,17 @@ +import os, sys, requests, re + +os.chdir() + +keys = [] +with open('lang.strings') as f: + for line in f: + m = re.match(r'\"(lng_[a-z_]+)(\#[a-z]+)?\"', line) + if m: + keys.append(m.group(1)) + elif not re.match(r'^\s*$', line): + print('Bad line: ' + line) + sys.exit(1) + +print('Keys: ' + str(len(keys))) + +sys.exit() diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index c331e4237..792a753a4 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1124,7 +1124,9 @@ ServiceAction ParseServiceAction( .date = data.vschedule_date().v, }; }, [&](const MTPDmessageActionSetChatTheme &data) { - // #TODO themes + result.content = ActionSetChatTheme{ + .emoji = qs(data.vemoticon()), + }; }, [](const MTPDmessageActionEmpty &data) {}); return result; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index 575393507..d1fd2f923 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -475,6 +475,10 @@ struct ActionGroupCallScheduled { TimeId date = 0; }; +struct ActionSetChatTheme { + QString emoji; +}; + struct ServiceAction { std::variant< v::null_t, @@ -503,7 +507,8 @@ struct ServiceAction { ActionGroupCall, ActionInviteToGroupCall, ActionSetMessagesTTL, - ActionGroupCallScheduled> content; + ActionGroupCallScheduled, + ActionSetChatTheme> content; }; ServiceAction ParseServiceAction( diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index fc6638394..b14caa18c 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1095,8 +1095,17 @@ auto HtmlWriter::Wrap::pushMessage( }, [&](const ActionGroupCallScheduled &data) { const auto dateText = FormatDateTime(data.date); return isChannel - ? "Voice chat scheduled for " + dateText + ? ("Voice chat scheduled for " + dateText) : (serviceFrom + " scheduled a voice chat for " + dateText); + }, [&](const ActionSetChatTheme &data) { + if (data.emoji.isEmpty()) { + return isChannel + ? "Channel theme was disabled" + : (serviceFrom + " disabled chat theme"); + } + return isChannel + ? ("Channel theme was changed to " + data.emoji).toUtf8() + : (serviceFrom + " changed chat theme to " + data.emoji).toUtf8(); }, [](v::null_t) { return QByteArray(); }); if (!serviceText.isEmpty()) { diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index d9ac09164..4eb287498 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -517,6 +517,12 @@ QByteArray SerializeMessage( pushActor(); pushAction("group_call_scheduled"); push("schedule_date", data.date); + }, [&](const ActionSetChatTheme &data) { + pushActor(); + pushAction("edit_chat_theme"); + if (!data.emoji.isEmpty()) { + push("emoticon", data.emoji.toUtf8()); + } }, [](v::null_t) {}); if (v::is_null(message.action.content)) { diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index aef8525a3..f74aa0b24 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -427,6 +427,31 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { return result; }; + auto prepareSetChatTheme = [this](const MTPDmessageActionSetChatTheme &action) { + auto result = PreparedText{}; + const auto text = qs(action.vemoticon()); + if (!text.isEmpty()) { + if (isPost()) { + result.text = tr::lng_action_theme_changed_channel(tr::now, lt_emoji, text); + } else if (_from->isSelf()) { + result.text = tr::lng_action_you_theme_changed(tr::now, lt_emoji, text); + } else { + result.links.push_back(fromLink()); + result.text = tr::lng_action_theme_changed(tr::now, lt_from, fromLinkText(), lt_emoji, text); + } + } else { + if (isPost()) { + result.text = tr::lng_action_theme_disabled_channel(tr::now); + } else if (_from->isSelf()) { + result.text = tr::lng_action_you_theme_disabled(tr::now); + } else { + result.links.push_back(fromLink()); + result.text = tr::lng_action_theme_disabled(tr::now, lt_from, fromLinkText()); + } + } + return result; + }; + const auto messageText = action.match([&]( const MTPDmessageActionChatAddUser &data) { return prepareChatAddUserText(data); @@ -485,7 +510,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { }, [&](const MTPDmessageActionGroupCallScheduled &data) { return prepareCallScheduledText(data.vschedule_date().v); }, [&](const MTPDmessageActionSetChatTheme &data) { - return PreparedText{ tr::lng_message_empty(tr::now) }; // #TODO themes + return prepareSetChatTheme(data); }, [](const MTPDmessageActionEmpty &) { return PreparedText{ tr::lng_message_empty(tr::now) }; });