diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 975517ce2..222f4bddc 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -491,7 +491,13 @@ HistoryWidget::HistoryWidget( _botCommandStart->hide(); session().attachWebView().requestBots(); - session().attachWebView().attachBotsUpdates( + rpl::merge( + session().attachWebView().attachBotsUpdates(), + session().changes().peerUpdates( + Data::PeerUpdate::Flag::Rights + ) | rpl::filter([=](const Data::PeerUpdate &update) { + return update.peer == _peer; + }) | rpl::to_empty ) | rpl::start_with_next([=] { refreshAttachBotsMenu(); }, lifetime()); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 5cb150426..bdd18e38c 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -1044,17 +1044,32 @@ std::unique_ptr MakeAttachBotsMenu( not_null peer, Fn actionFactory, Fn attach) { + if (!Data::CanSend(peer, ChatRestriction::SendInline)) { + return nullptr; + } auto result = std::make_unique( parent, st::dropdownMenuWithIcons); const auto bots = &peer->session().attachWebView(); const auto raw = result.get(); - raw->addAction(tr::lng_attach_photo_or_video(tr::now), [=] { - attach(true); - }, &st::menuIconPhoto); - raw->addAction(tr::lng_attach_document(tr::now), [=] { - attach(false); - }, &st::menuIconFile); + auto minimal = 0; + if (Data::CanSend(peer, ChatRestriction::SendPhotos, false)) { + ++minimal; + raw->addAction(tr::lng_attach_photo_or_video(tr::now), [=] { + attach(true); + }, &st::menuIconPhoto); + } + const auto fileTypes = ChatRestriction::SendVideos + | ChatRestriction::SendGifs + | ChatRestriction::SendStickers + | ChatRestriction::SendMusic + | ChatRestriction::SendFiles; + if (Data::CanSendAnyOf(peer, fileTypes)) { + ++minimal; + raw->addAction(tr::lng_attach_document(tr::now), [=] { + attach(false); + }, &st::menuIconFile); + } for (const auto &bot : bots->attachBots()) { if (!PeerMatchesTypes(peer, bot.user, bot.types)) { continue; @@ -1082,7 +1097,7 @@ std::unique_ptr MakeAttachBotsMenu( }, action->lifetime()); raw->addAction(std::move(action)); } - if (raw->actions().size() < 3) { + if (raw->actions().size() <= minimal) { return nullptr; } return result;