Skip to content
Advertisement

Tag: telethon

how to delete contact by number telethon

Imports: Code: 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

Running a loop while using telethon

I’m making a telegram channel admin control script that needs checking channel in a loop. I also want some message handlers checking for messages. Here is a part of my code: If i use client.loop.run_until_complete(main()), message handler won’t work but main runs prefectly. and if I use client.run_until_disconnected() and run main in another loop using another thread, it stucks at

How to get entity of a channel using Telethon bot API?

I cannot get_dialogs with Telethon Bot since the method is only available for a client. Therefore when I try to access the entity with its id I receive an error. How do I access an entity(channel) if I cannot parse all channels and neither access them by id? I would like to parse messages from a private group and use

When starting client the code is asking for phone/bot token

While running my first code using Telethon library, it is asking for a bot token. This is the actual code: And on command prompt: Result: Please enter your phone (or bot token) If I give my API ID, it eventually throws the error: telethon.errors.rpcerrorlist.PhoneNumberInvalidError: The phone number is invalid (caused by SendCodeRequest) Why? I expect the client to start without

Advertisement