diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 0d33fc30c1..5d5bb784e6 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -432,7 +432,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_channel_usernames_description" = "Drag and drop links to change the order in which they will be displayed on the channel info page."; "lng_bot_username_title" = "Username"; -"lng_bot_username_description1" = "If you set a public link, other people will be able to find your bot."; +"lng_bot_username_description1" = "This link cannot be edited. You can acquire additional usernames on {link}."; +"lng_bot_username_description1_link" = "Fragment"; "lng_bot_usernames_activate_description" = "Do you want to show this link on the bot info page?"; "lng_bot_usernames_deactivate_description" = "Do you want to hide this link from the bot info page?"; "lng_bot_usernames_description" = "Drag and drop links to change the order in which they will be displayed on the bot info page."; diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 862a43e259..3e02454868 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_user.h" #include "lang/lang_keys.h" +#include "main/main_app_config_values.h" #include "main/main_session.h" #include "mtproto/sender.h" #include "settings/settings_common.h" @@ -49,6 +50,7 @@ public: UsernameEditor(not_null, not_null peer); void setInnerFocus(); + void setEnabled(bool value); [[nodiscard]] rpl::producer<> submitted() const; [[nodiscard]] rpl::producer<> save(); [[nodiscard]] rpl::producer checkInfoChanged() const; @@ -127,6 +129,10 @@ void UsernameEditor::setInnerFocus() { _username->setFocusFast(); } +void UsernameEditor::setEnabled(bool value) { + _username->setEnabled(value); +} + void UsernameEditor::resizeEvent(QResizeEvent *e) { _username->resize( width() - _padding.left() - _padding.right(), @@ -329,18 +335,31 @@ void UsernamesBox( const auto editor = box->addRow( object_ptr(box, peer), {}); + editor->setEnabled(!isBot); box->setFocusCallback([=] { editor->setInnerFocus(); }); AddUsernameCheckLabel(container, editor->checkInfoChanged()); - auto description = rpl::combine( - (isBot - ? tr::lng_bot_username_description1 - : tr::lng_username_description1)(Ui::Text::RichLangValue), - tr::lng_username_description2(Ui::Text::RichLangValue) - ) | rpl::map([](TextWithEntities d1, TextWithEntities d2) { - return d1.append("\n\n").append(std::move(d2)); - }); + auto description = [&]() -> rpl::producer { + if (!isBot) { + return rpl::combine( + tr::lng_username_description1(Ui::Text::RichLangValue), + tr::lng_username_description2(Ui::Text::RichLangValue) + ) | rpl::map([](TextWithEntities d1, TextWithEntities d2) { + return d1.append("\n\n").append(std::move(d2)); + }); + } + if (const auto url = AppConfig::FragmentLink(&peer->session())) { + const auto link = Ui::Text::Link( + tr::lng_bot_username_description1_link(tr::now), + *url); + return tr::lng_bot_username_description1( + lt_link, + rpl::single(link), + Ui::Text::RichLangValue); + } + return rpl::single({}); + }(); container->add(object_ptr( container, object_ptr( @@ -354,10 +373,9 @@ void UsernamesBox( box, peer, std::make_shared(box), - [=] { - box->scrollToY(0); - editor->setInnerFocus(); - }), + !isBot + ? [=] { box->scrollToY(0); editor->setInnerFocus(); } + : Fn(nullptr)), {}); const auto finish = [=] {