Bulk delete contacts from your Telegram account

Как удалить сразу много контактов из вашего аккаунта Телеграм.

<?php

if (! file_exists ( 'madeline.php' )) {
	copy ( 'https://phar.madelineproto.xyz/madeline.php', 'madeline.php' );
}
include 'madeline.php';
error_reporting ( E_ALL & ~ E_NOTICE & ~ E_WARNING );
ini_set ( 'display_errors', '1' );

$settings = new \danog\MadelineProto\Settings ();

$MadelineProto = new \danog\MadelineProto\API ( 'session.madeline', $settings );

$MadelineProto->start ();
 $my_contacts = [
 380671000001,
 380671000002,
 380671000003,
];

$contacts = $MadelineProto->contacts->getContacts([] );
print_r(  $contacts['users'] );

$to_delete = [];

foreach ( $contacts['users'] as $contact ) {
    if ( $contact['mutual_contact'] ) {
        continue;
    }
    if ( empty( $contact['phone'] ) || ! in_array( $contact['phone'], $my_contacts ) ) {
        $to_delete[] = $contact['id'];
    }
}

if ( count( $to_delete  ) ) {
        $MadelineProto->contacts->deleteContacts( [ 'id' => $to_delete, ] );
}

echo ' All done!';