mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Replaced use of raw MTP* bot commands with new transitional classes.
This commit is contained in:
@@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "mtproto/mtproto_dc_options.h"
|
||||
#include "data/notify/data_notify_settings.h"
|
||||
#include "data/data_peer_bot_command.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
@@ -1988,16 +1987,29 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
const auto &d = update.c_updateBotCommands();
|
||||
if (const auto peer = session().data().peerLoaded(peerFromMTP(d.vpeer()))) {
|
||||
const auto botId = UserId(d.vbot_id().v);
|
||||
const auto commands = Data::BotCommands{
|
||||
.userId = UserId(d.vbot_id().v),
|
||||
.commands = ranges::views::all(
|
||||
d.vcommands().v
|
||||
) | ranges::views::transform(
|
||||
Data::BotCommandFromTL
|
||||
) | ranges::to_vector,
|
||||
};
|
||||
|
||||
if (const auto user = peer->asUser()) {
|
||||
if (user->isBot() && user->id == peerFromUser(botId)) {
|
||||
if (Data::UpdateBotCommands(user->botInfo->commands, &d.vcommands())) {
|
||||
const auto equal = ranges::equal(
|
||||
user->botInfo->commands,
|
||||
commands.commands);
|
||||
user->botInfo->commands = commands.commands;
|
||||
if (!equal) {
|
||||
session().data().botCommandsChanged(user);
|
||||
}
|
||||
}
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
chat->setBotCommands(botId, d.vcommands());
|
||||
chat->setBotCommands({ commands });
|
||||
} else if (const auto megagroup = peer->asMegagroup()) {
|
||||
if (megagroup->mgInfo->updateBotCommands(botId, d.vcommands())) {
|
||||
if (megagroup->mgInfo->setBotCommands({ commands })) {
|
||||
session().data().botCommandsChanged(megagroup);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user