2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 23:45:44 +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

@@ -46,6 +46,10 @@ void MegagroupInfo::setLocation(const ChannelLocation &location) {
_location = location;
}
bool MegagroupInfo::updateBotCommands(const MTPVector<MTPBotInfo> &data) {
return Data::UpdateBotCommands(_botCommands, data);
}
ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id)
, inputChannel(
@@ -803,15 +807,6 @@ void ApplyChannelUpdate(
const auto chat = channel->owner().chat(migratedFrom->v);
Data::ApplyMigration(chat, channel);
}
for (const auto &item : update.vbot_info().v) {
auto &owner = channel->owner();
item.match([&](const MTPDbotInfo &info) {
if (const auto user = owner.userLoaded(info.vuser_id().v)) {
user->setBotInfo(item);
session->api().fullPeerUpdated().notify(user);
}
});
}
channel->setAbout(qs(update.vabout()));
channel->setMembersCount(update.vparticipants_count().value_or_empty());
channel->setAdminsCount(update.vadmins_count().value_or_empty());
@@ -867,6 +862,9 @@ void ApplyChannelUpdate(
SetTopPinnedMessageId(channel, pinned->v);
}
if (channel->isMegagroup()) {
if (channel->mgInfo->updateBotCommands(update.vbot_info())) {
channel->owner().botCommandsChanged(channel);
}
const auto stickerSet = update.vstickerset();
const auto set = stickerSet ? &stickerSet->c_stickerSet() : nullptr;
const auto newSetId = (set ? set->vid().v : 0);