Added check of bot info with correct lang code to bot management box.

This commit is contained in:
23rd 2023-04-21 00:13:11 +03:00
parent 66e7f1d490
commit efa19d5782

View file

@ -1809,18 +1809,30 @@ void Controller::saveTitle() {
).fail(std::move(onFail) ).fail(std::move(onFail)
).send(); ).send();
} else if (_isBot) { } else if (_isBot) {
_api.request(MTPbots_GetBotInfo(
MTP_flags(MTPbots_GetBotInfo::Flag::f_bot),
_peer->asUser()->inputUser,
MTPstring() // Lang code.
)).done([=](const MTPbots_BotInfo &result) {
const auto was = qs(result.data().vname());
const auto now = *_savingData.title;
if (was == now) {
return continueSave();
}
using Flag = MTPbots_SetBotInfo::Flag; using Flag = MTPbots_SetBotInfo::Flag;
_api.request(MTPbots_SetBotInfo( _api.request(MTPbots_SetBotInfo(
MTP_flags(Flag::f_bot | Flag::f_name), MTP_flags(Flag::f_bot | Flag::f_name),
_peer->asUser()->inputUser, _peer->asUser()->inputUser,
MTPstring(), // Lang code. MTPstring(), // Lang code.
MTP_string(*_savingData.title), // Name. MTP_string(now), // Name.
MTPstring(), // About. MTPstring(), // About.
MTPstring() // Description. MTPstring() // Description.
)).done([=] { )).done([=] {
continueSave(); continueSave();
}).fail(std::move(onFail) }).fail(std::move(onFail)
).send(); ).send();
}).fail(std::move(onFail)
).send();
} else { } else {
continueSave(); continueSave();
} }
@ -1836,13 +1848,23 @@ void Controller::saveDescription() {
continueSave(); continueSave();
}; };
if (_isBot) { if (_isBot) {
_api.request(MTPbots_GetBotInfo(
MTP_flags(MTPbots_GetBotInfo::Flag::f_bot),
_peer->asUser()->inputUser,
MTPstring() // Lang code.
)).done([=](const MTPbots_BotInfo &result) {
const auto was = qs(result.data().vabout());
const auto now = *_savingData.description;
if (was == now) {
return continueSave();
}
using Flag = MTPbots_SetBotInfo::Flag; using Flag = MTPbots_SetBotInfo::Flag;
_api.request(MTPbots_SetBotInfo( _api.request(MTPbots_SetBotInfo(
MTP_flags(Flag::f_bot | Flag::f_about), MTP_flags(Flag::f_bot | Flag::f_about),
_peer->asUser()->inputUser, _peer->asUser()->inputUser,
MTPstring(), // Lang code. MTPstring(), // Lang code.
MTPstring(), // Name. MTPstring(), // Name.
MTP_string(*_savingData.description), // About. MTP_string(now), // About.
MTPstring() // Description. MTPstring() // Description.
)).done([=] { )).done([=] {
successCallback(); successCallback();
@ -1850,6 +1872,9 @@ void Controller::saveDescription() {
_controls.description->showError(); _controls.description->showError();
cancelSave(); cancelSave();
}).send(); }).send();
}).fail([=] {
continueSave();
}).send();
return; return;
} }
_api.request(MTPmessages_EditChatAbout( _api.request(MTPmessages_EditChatAbout(