MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / requestBotCommonGroups

Method requestBotCommonGroups

Telegram/SourceFiles/apiwrap.cpp:5111–5145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5109}
5110
5111void ApiWrap::requestBotCommonGroups(
5112 not_null<UserData*> bot,
5113 Fn<void()> done) {
5114 if (_botCommonGroupsRequests.contains(bot)) {
5115 return;
5116 }
5117 _botCommonGroupsRequests.emplace(bot, done);
5118 const auto finish = [=](std::vector<not_null<PeerData*>> list) {
5119 _botCommonGroups.emplace(bot, std::move(list));
5120 if (const auto callback = _botCommonGroupsRequests.take(bot)) {
5121 (*callback)();
5122 }
5123 };
5124 const auto limit = 100;
5125 request(MTPmessages_GetCommonChats(
5126 bot->inputUser(),
5127 MTP_long(0), // max_id
5128 MTP_int(limit)
5129 )).done([=](const MTPmessages_Chats &result) {
5130 const auto chats = result.match([](const auto &data) {
5131 return &data.vchats().v;
5132 });
5133 auto &owner = session().data();
5134 auto list = std::vector<not_null<PeerData*>>();
5135 list.reserve(chats->size());
5136 for (const auto &chat : *chats) {
5137 if (const auto peer = owner.processChat(chat)) {
5138 list.push_back(peer);
5139 }
5140 }
5141 finish(std::move(list));
5142 }).fail([=] {
5143 finish({});
5144 }).send();
5145}
5146
5147void ApiWrap::saveSelfBio(const QString &text) {
5148 if (_bio.requestId) {

Callers 2

ProccessCommonGroupsFunction · 0.80
ShowChoosePeerBoxFunction · 0.80

Calls 13

MTP_longFunction · 0.85
emplaceMethod · 0.80
inputUserMethod · 0.80
processChatMethod · 0.80
finishFunction · 0.70
MTP_intFunction · 0.50
containsMethod · 0.45
takeMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected