mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Always show Bot Privacy Policy button.
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user