2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Track bot commands separately in different chats.

This commit is contained in:
John Preston
2021-07-01 14:05:15 +03:00
parent 93d99d6173
commit b930bc0e6d
14 changed files with 149 additions and 94 deletions

View File

@@ -129,38 +129,9 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
botInfo->description = desc;
botInfo->text = Ui::Text::String(st::msgMinWidth);
}
auto &v = d.vcommands().v;
botInfo->commands.reserve(v.size());
auto changedCommands = false;
int32 j = 0;
for (const auto &command : v) {
command.match([&](const MTPDbotCommand &data) {
const auto command = qs(data.vcommand());
const auto description = qs(data.vdescription());
if (botInfo->commands.size() <= j) {
botInfo->commands.push_back({
.command = command,
.description = description,
});
changedCommands = true;
} else {
if (botInfo->commands[j].command != command) {
botInfo->commands[j].command = command;
changedCommands = true;
}
if (botInfo->commands[j].description != description) {
botInfo->commands[j].description = description;
changedCommands = true;
}
}
++j;
});
}
while (j < botInfo->commands.size()) {
botInfo->commands.pop_back();
changedCommands = true;
}
const auto changedCommands = Data::UpdateBotCommands(
botInfo->commands,
d.vcommands());
botInfo->inited = true;