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

Replaced use of raw MTP* bot commands with new transitional classes.

This commit is contained in:
23rd
2022-05-15 00:27:21 +03:00
committed by John Preston
parent 5f8608ed90
commit 13146e9c06
14 changed files with 136 additions and 145 deletions

View File

@@ -50,14 +50,9 @@ void MegagroupInfo::setLocation(const ChannelLocation &location) {
_location = location;
}
bool MegagroupInfo::updateBotCommands(const MTPVector<MTPBotInfo> &data) {
return Data::UpdateBotCommands(_botCommands, data);
}
bool MegagroupInfo::updateBotCommands(
UserId botId,
const MTPVector<MTPBotCommand> &data) {
return Data::UpdateBotCommands(_botCommands, botId, &data);
Data::ChatBotCommands::Changed MegagroupInfo::setBotCommands(
const std::vector<Data::BotCommands> &list) {
return _botCommands.update(list);
}
ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
@@ -908,7 +903,13 @@ void ApplyChannelUpdate(
SetTopPinnedMessageId(channel, pinned->v);
}
if (channel->isMegagroup()) {
if (channel->mgInfo->updateBotCommands(update.vbot_info())) {
auto commands = ranges::views::all(
update.vbot_info().v
) | ranges::views::transform(
Data::BotCommandsFromTL
) | ranges::to_vector;
if (channel->mgInfo->setBotCommands(std::move(commands))) {
channel->owner().botCommandsChanged(channel);
}
const auto stickerSet = update.vstickerset();