2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Handle updateBotCommands.

This commit is contained in:
John Preston
2021-07-05 20:59:06 +03:00
parent 8f5ac0420e
commit 8fc7ba7ac1
7 changed files with 54 additions and 6 deletions

View File

@@ -120,6 +120,15 @@ bool UpdateBotCommands(
return result;
}
bool UpdateBotCommands(
base::flat_map<UserId, std::vector<BotCommand>> &commands,
UserId botId,
const MTPVector<MTPBotCommand> &data) {
return data.v.isEmpty()
? commands.remove(botId)
: UpdateBotCommands(commands[botId], data);
}
bool UpdateBotCommands(
base::flat_map<UserId, std::vector<BotCommand>> &commands,
const MTPVector<MTPBotInfo> &data) {
@@ -132,12 +141,7 @@ bool UpdateBotCommands(
if (!filled.emplace(id).second) {
LOG(("API Error: Two BotInfo for a single bot."));
return;
}
if (data.vcommands().v.isEmpty()) {
if (commands.remove(id)) {
result = true;
}
} else if (UpdateBotCommands(commands[id], data.vcommands())) {
} else if (UpdateBotCommands(commands, id, data.vcommands())) {
result = true;
}
});