From c4e53b55ceba35217ea5a2a43d3e71b4081cd7e8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 30 Mar 2026 13:08:17 +0300 Subject: [PATCH] Showed slash button in field only when bots have registered commands. --- .../SourceFiles/history/history_widget.cpp | 4 +-- .../history_view_compose_controls.cpp | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index ba8f2f355a..95213cc94d 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5844,9 +5844,9 @@ bool HistoryWidget::updateCmdStartShown() { if (_history && _peer && (false - || (_peer->isChat() && _peer->asChat()->botStatus == Data::BotStatus::HasBots) + || (_peer->isChat() && !_peer->asChat()->botCommands().empty()) || (_peer->isMegagroup() - && _peer->asChannel()->mgInfo->botStatus == Data::BotStatus::HasBots))) { + && !_peer->asChannel()->mgInfo->botCommands().empty()))) { if (!isBotStart() && !isBlocked() && !_keyboard->hasMarkup() diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index e81e6b12bd..5128efc10a 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -3696,12 +3696,18 @@ bool ComposeControls::hasEnoughLinesForAi() const { bool ComposeControls::updateBotCommandShown() { auto shown = false; const auto peer = _history ? _history->peer.get() : nullptr; - if (_botCommandStart - && peer - && ((peer->isChat() && peer->asChat()->botStatus == Data::BotStatus::HasBots) - || (peer->isMegagroup() && peer->asChannel()->mgInfo->botStatus == Data::BotStatus::HasBots) - || (peer->isUser() && peer->asUser()->isBot()))) { - if (!HasSendText(_field)) { + if (_botCommandStart && peer) { + const auto hasBotCommands = [&] { + if (peer->isChat()) { + return !peer->asChat()->botCommands().empty(); + } else if (peer->isMegagroup()) { + return !peer->asChannel()->mgInfo->botCommands().empty(); + } else if (peer->isUser()) { + return peer->asUser()->isBot(); + } + return false; + }(); + if (hasBotCommands && !HasSendText(_field)) { shown = true; } } @@ -4187,6 +4193,16 @@ void ComposeControls::initWebpageProcess() { } }, _historyLifetime); + session().data().botCommandsChanges( + ) | rpl::filter([peer = _history->peer](not_null p) { + return (p == peer); + }) | rpl::on_next([=] { + if (updateBotCommandShown()) { + updateControlsVisibility(); + updateControlsGeometry(_wrap->size()); + } + }, _historyLifetime); + _header->previewReady(_preview->parsedValue()); }