How can I see all my contacts and send them messages?
i use Telethon (API telegram python).
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import InputChannelEmpty
from telethon import TelegramClient
from telethon.tl.types.messages import Messages
from telethon.tl.types.contacts import Contacts
api_id = 1****
api_hash = '5fbd2d************************'
client = TelegramClient('arta0', api_id, api_hash)
client.connect()
3
Answers
Just add this line to your code:
And you should see the contacts in the result.
To send messages to contacts, you can use the
send_message
function defined in telegram_client.py and has an example in InteractiveTelegramClient.py.If you need more details comment below and I will try to reply.
Sending empty string didn’t worked for me:
So I think you should use ‘0’ instead:
I think in new update
client.invoke()
is not defined.I used following code and it worked for me.