Don't autostart blocked bots.

This commit is contained in:
levlam 2023-04-24 16:03:08 +03:00
parent dc9396a84f
commit 868d894779
3 changed files with 9 additions and 1 deletions

View File

@ -306,7 +306,8 @@ class LinkManager::InternalLinkBotStart final : public InternalLink {
const Td *td = G()->td().get_actor_unsafe();
auto dialog_id = td->messages_manager_->resolve_dialog_username(bot_username_);
if (dialog_id.is_valid() && dialog_id.get_type() == DialogType::User &&
td->messages_manager_->get_dialog_has_last_message(dialog_id)) {
td->messages_manager_->get_dialog_has_last_message(dialog_id) &&
!td->messages_manager_->is_dialog_blocked(dialog_id)) {
autostart = true;
}
}

View File

@ -17720,6 +17720,11 @@ void MessagesManager::block_message_sender_from_replies_on_server(MessageId mess
->send(message_id, need_delete_message, need_delete_all_messages, report_spam);
}
bool MessagesManager::is_dialog_blocked(DialogId dialog_id) const {
const Dialog *d = get_dialog(dialog_id);
return d != nullptr && d->is_blocked;
}
void MessagesManager::get_blocked_dialogs(int32 offset, int32 limit,
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise) {
if (offset < 0) {

View File

@ -615,6 +615,8 @@ class MessagesManager final : public Actor {
void block_message_sender_from_replies(MessageId message_id, bool need_delete_message, bool need_delete_all_messages,
bool report_spam, Promise<Unit> &&promise);
bool is_dialog_blocked(DialogId dialog_id) const;
void get_blocked_dialogs(int32 offset, int32 limit, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
void on_get_blocked_dialogs(int32 offset, int32 limit, int32 total_count,