mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -1315,6 +1315,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_profile_bot_settings" = "Bot Settings";
|
"lng_profile_bot_settings" = "Bot Settings";
|
||||||
"lng_profile_bot_help" = "Bot Help";
|
"lng_profile_bot_help" = "Bot Help";
|
||||||
"lng_profile_bot_privacy" = "Bot Privacy Policy";
|
"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#one" = "{count} group in common";
|
||||||
"lng_profile_common_groups#other" = "{count} groups in common";
|
"lng_profile_common_groups#other" = "{count} groups in common";
|
||||||
"lng_profile_similar_channels#one" = "{count} similar channel";
|
"lng_profile_similar_channels#one" = "{count} similar channel";
|
||||||
|
|
|
@ -331,7 +331,11 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||||
d.vmenu_button());
|
d.vmenu_button());
|
||||||
botInfo->inited = true;
|
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);
|
owner().botCommandsChanged(this);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -31,6 +31,7 @@ struct BotInfo {
|
||||||
|
|
||||||
QString botMenuButtonText;
|
QString botMenuButtonText;
|
||||||
QString botMenuButtonUrl;
|
QString botMenuButtonUrl;
|
||||||
|
QString privacyPolicyUrl;
|
||||||
|
|
||||||
QString startToken;
|
QString startToken;
|
||||||
Dialogs::EntryState inlineReturnTo;
|
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_values.h"
|
||||||
#include "info/profile/info_profile_widget.h"
|
#include "info/profile/info_profile_widget.h"
|
||||||
#include "inline_bots/bot_attach_web_view.h"
|
#include "inline_bots/bot_attach_web_view.h"
|
||||||
|
#include "iv/iv_instance.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "menu/menu_mute.h"
|
#include "menu/menu_mute.h"
|
||||||
|
@ -1867,7 +1868,8 @@ void ActionsFiller::addDeleteContactAction(not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsFiller::addBotCommandActions(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()) {
|
if (!user->isBot()) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -1881,7 +1883,7 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
};
|
};
|
||||||
auto hasBotCommandValue = [=](const QString &command) {
|
const auto hasBotCommandValue = [=](const QString &command) {
|
||||||
return user->session().changes().peerFlagsValue(
|
return user->session().changes().peerFlagsValue(
|
||||||
user,
|
user,
|
||||||
Data::PeerUpdate::Flag::BotCommands
|
Data::PeerUpdate::Flag::BotCommands
|
||||||
|
@ -1889,21 +1891,24 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||||
return !findBotCommand(command).isEmpty();
|
return !findBotCommand(command).isEmpty();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
auto sendBotCommand = [=, window = _controller->parentController()](
|
const auto makeOtherContext = [=] {
|
||||||
const QString &command) {
|
return QVariant::fromValue(ClickHandlerContext{
|
||||||
|
.sessionWindow = base::make_weak(window),
|
||||||
|
.peer = user,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const auto sendBotCommand = [=](const QString &command) {
|
||||||
const auto original = findBotCommand(command);
|
const auto original = findBotCommand(command);
|
||||||
if (original.isEmpty()) {
|
if (original.isEmpty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
BotCommandClickHandler('/' + original).onClick(ClickContext{
|
BotCommandClickHandler('/' + original).onClick(ClickContext{
|
||||||
Qt::LeftButton,
|
Qt::LeftButton,
|
||||||
QVariant::fromValue(ClickHandlerContext{
|
makeOtherContext()
|
||||||
.sessionWindow = base::make_weak(window),
|
|
||||||
.peer = user,
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
auto addBotCommand = [=](
|
const auto addBotCommand = [=](
|
||||||
rpl::producer<QString> text,
|
rpl::producer<QString> text,
|
||||||
const QString &command,
|
const QString &command,
|
||||||
const style::icon *icon = nullptr) {
|
const style::icon *icon = nullptr) {
|
||||||
|
@ -1919,7 +1924,31 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||||
u"help"_q,
|
u"help"_q,
|
||||||
&st::infoIconInformation);
|
&st::infoIconInformation);
|
||||||
addBotCommand(tr::lng_profile_bot_settings(), u"settings"_q);
|
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() {
|
void ActionsFiller::addReportAction() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue