2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 06:55:58 +00:00

Use UserData::isBot where applicable.

This commit is contained in:
John Preston
2019-07-18 10:51:11 +02:00
parent a7d9aa947b
commit 873b77cf40
29 changed files with 105 additions and 95 deletions

View File

@@ -298,36 +298,42 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
int32 cnt = 0;
if (_chat) {
if (_chat->noParticipantInfo()) {
Auth().api().requestFullPeer(_chat);
_chat->session().api().requestFullPeer(_chat);
} else if (!_chat->participants.empty()) {
for (const auto user : _chat->participants) {
if (!user->botInfo) continue;
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
if (!user->isBot()) {
continue;
} else if (!user->botInfo->inited) {
user->session().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) {
continue;
}
if (user->botInfo->commands.isEmpty()) continue;
bots.insert(user, true);
cnt += user->botInfo->commands.size();
}
}
} else if (_user && _user->botInfo) {
} else if (_user && _user->isBot()) {
if (!_user->botInfo->inited) {
Auth().api().requestFullPeer(_user);
_user->session().api().requestFullPeer(_user);
}
cnt = _user->botInfo->commands.size();
bots.insert(_user, true);
} else if (_channel && _channel->isMegagroup()) {
if (_channel->mgInfo->bots.empty()) {
if (!_channel->mgInfo->botStatus) {
Auth().api().requestBots(_channel);
_channel->session().api().requestBots(_channel);
}
} else {
for_const (auto user, _channel->mgInfo->bots) {
if (!user->botInfo) continue;
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
for (const auto user : _channel->mgInfo->bots) {
if (!user->isBot()) {
continue;
} else if (!user->botInfo->inited) {
user->session().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) {
continue;
}
if (user->botInfo->commands.isEmpty()) continue;
bots.insert(user, true);
cnt += user->botInfo->commands.size();
}
@@ -338,12 +344,16 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
int32 botStatus = _chat ? _chat->botStatus : ((_channel && _channel->isMegagroup()) ? _channel->mgInfo->botStatus : -1);
if (_chat) {
for (const auto &user : _chat->lastAuthors) {
if (!user->botInfo) continue;
if (!bots.contains(user)) continue;
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
if (!user->isBot()) {
continue;
} else if (!bots.contains(user)) {
continue;
} else if (!user->botInfo->inited) {
user->session().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) {
continue;
}
if (user->botInfo->commands.isEmpty()) continue;
bots.remove(user);
for (auto j = 0, l = user->botInfo->commands.size(); j != l; ++j) {
if (!listAllSuggestions) {