mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Always show Bot Privacy Policy button.
This commit is contained in:
parent
a2785867b2
commit
5f8c007a0c
4 changed files with 47 additions and 12 deletions
Telegram
Resources/langs
SourceFiles
|
@ -1315,6 +1315,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_profile_bot_settings" = "Bot Settings";
|
||||
"lng_profile_bot_help" = "Bot Help";
|
||||
"lng_profile_bot_privacy" = "Bot Privacy Policy";
|
||||
"lng_profile_bot_privacy_url" = "https://telegram.org/privacy-tpa";
|
||||
"lng_profile_common_groups#one" = "{count} group in common";
|
||||
"lng_profile_common_groups#other" = "{count} groups in common";
|
||||
"lng_profile_similar_channels#one" = "{count} similar channel";
|
||||
|
|
|
@ -331,7 +331,11 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
|||
d.vmenu_button());
|
||||
botInfo->inited = true;
|
||||
|
||||
if (changedCommands || changedButton) {
|
||||
const auto privacy = qs(d.vprivacy_policy_url().value_or_empty());
|
||||
const auto privacyChanged = (botInfo->privacyPolicyUrl != privacy);
|
||||
botInfo->privacyPolicyUrl = privacy;
|
||||
|
||||
if (changedCommands || changedButton || privacyChanged) {
|
||||
owner().botCommandsChanged(this);
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -31,6 +31,7 @@ struct BotInfo {
|
|||
|
||||
QString botMenuButtonText;
|
||||
QString botMenuButtonUrl;
|
||||
QString privacyPolicyUrl;
|
||||
|
||||
QString startToken;
|
||||
Dialogs::EntryState inlineReturnTo;
|
||||
|
|
|
@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/profile/info_profile_values.h"
|
||||
#include "info/profile/info_profile_widget.h"
|
||||
#include "inline_bots/bot_attach_web_view.h"
|
||||
#include "iv/iv_instance.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_mute.h"
|
||||
|
@ -1867,7 +1868,8 @@ void ActionsFiller::addDeleteContactAction(not_null<UserData*> user) {
|
|||
}
|
||||
|
||||
void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||
auto findBotCommand = [user](const QString &command) {
|
||||
const auto window = _controller->parentController();
|
||||
const auto findBotCommand = [user](const QString &command) {
|
||||
if (!user->isBot()) {
|
||||
return QString();
|
||||
}
|
||||
|
@ -1881,7 +1883,7 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
|||
}
|
||||
return QString();
|
||||
};
|
||||
auto hasBotCommandValue = [=](const QString &command) {
|
||||
const auto hasBotCommandValue = [=](const QString &command) {
|
||||
return user->session().changes().peerFlagsValue(
|
||||
user,
|
||||
Data::PeerUpdate::Flag::BotCommands
|
||||
|
@ -1889,21 +1891,24 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
|||
return !findBotCommand(command).isEmpty();
|
||||
});
|
||||
};
|
||||
auto sendBotCommand = [=, window = _controller->parentController()](
|
||||
const QString &command) {
|
||||
const auto makeOtherContext = [=] {
|
||||
return QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(window),
|
||||
.peer = user,
|
||||
});
|
||||
};
|
||||
const auto sendBotCommand = [=](const QString &command) {
|
||||
const auto original = findBotCommand(command);
|
||||
if (original.isEmpty()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
BotCommandClickHandler('/' + original).onClick(ClickContext{
|
||||
Qt::LeftButton,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(window),
|
||||
.peer = user,
|
||||
})
|
||||
makeOtherContext()
|
||||
});
|
||||
return true;
|
||||
};
|
||||
auto addBotCommand = [=](
|
||||
const auto addBotCommand = [=](
|
||||
rpl::producer<QString> text,
|
||||
const QString &command,
|
||||
const style::icon *icon = nullptr) {
|
||||
|
@ -1919,7 +1924,31 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
|||
u"help"_q,
|
||||
&st::infoIconInformation);
|
||||
addBotCommand(tr::lng_profile_bot_settings(), u"settings"_q);
|
||||
addBotCommand(tr::lng_profile_bot_privacy(), u"privacy"_q);
|
||||
//addBotCommand(tr::lng_profile_bot_privacy(), u"privacy"_q);
|
||||
const auto openUrl = [=](const QString &url) {
|
||||
Core::App().iv().openWithIvPreferred(
|
||||
&user->session(),
|
||||
url,
|
||||
makeOtherContext());
|
||||
};
|
||||
const auto openPrivacyPolicy = [=] {
|
||||
if (const auto info = user->botInfo.get()) {
|
||||
if (!info->privacyPolicyUrl.isEmpty()) {
|
||||
openUrl(info->privacyPolicyUrl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!sendBotCommand(u"privacy"_q)) {
|
||||
openUrl(tr::lng_profile_bot_privacy_url(tr::now));
|
||||
}
|
||||
};
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_profile_bot_privacy(),
|
||||
rpl::single(true),
|
||||
openPrivacyPolicy,
|
||||
nullptr);
|
||||
|
||||
}
|
||||
|
||||
void ActionsFiller::addReportAction() {
|
||||
|
|
Loading…
Add table
Reference in a new issue