Skip to content
Advertisement

how to delete contact by number telethon

Imports:

JavaScript

Code:

JavaScript

That code first add an phone_number to our contacts list and after we can easily get their username.

After we delete that contact as we just needed their username.

But some users don’t have set username so we get username as None.

Now how to remove that contact ? Currently I use client(functions.contacts.DeleteContactsRequest(id=[username])), which will fail if username is None.

Advertisement

Answer

According to the docs, you can make an InputUser and then give it to DeleteContactRequest.

As you already have the user, you can:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement