Don't auto-send /start in blocked bots.

This commit is contained in:
John Preston 2025-01-09 22:00:49 +04:00
parent 199e7a1d46
commit afffdd5bbf

View file

@ -3599,17 +3599,22 @@ void HistoryWidget::historyLoaded() {
} }
bool HistoryWidget::clearMaybeSendStart() { bool HistoryWidget::clearMaybeSendStart() {
if (!_showAndMaybeSendStart) { if (!_showAndMaybeSendStart || !_history) {
return false;
} else if (!_history->peer->isFullLoaded()) {
_history->peer->updateFull();
return false; return false;
} }
_showAndMaybeSendStart = false; _showAndMaybeSendStart = false;
if (const auto user = _history ? _history->peer->asUser() : nullptr) { if (const auto user = _history ? _history->peer->asUser() : nullptr) {
if (user->blockStatus() == PeerData::BlockStatus::NotBlocked) {
if (const auto info = user->botInfo.get()) { if (const auto info = user->botInfo.get()) {
if (!info->startToken.isEmpty()) { if (!info->startToken.isEmpty()) {
return true; return true;
} }
} }
} }
}
return false; return false;
} }
@ -3975,11 +3980,9 @@ void HistoryWidget::preloadHistoryIfNeeded() {
preloadHistoryByScroll(); preloadHistoryByScroll();
checkReplyReturns(); checkReplyReturns();
} }
if (_history && _history->loadedAtTop() && _history->loadedAtBottom()) {
if (clearMaybeSendStart() && !_history->isDisplayedEmpty()) { if (clearMaybeSendStart() && !_history->isDisplayedEmpty()) {
sendBotStartCommand(); sendBotStartCommand();
} }
}
} }
void HistoryWidget::preloadHistoryByScroll() { void HistoryWidget::preloadHistoryByScroll() {
@ -8307,6 +8310,10 @@ void HistoryWidget::fullInfoUpdated() {
handlePeerUpdate(); handlePeerUpdate();
checkSuggestToGigagroup(); checkSuggestToGigagroup();
if (clearMaybeSendStart() && !_history->isDisplayedEmpty()) {
sendBotStartCommand();
}
} }
if (updateCmdStartShown()) { if (updateCmdStartShown()) {
refresh = true; refresh = true;