Document the magic sync module

This commit is contained in:
Lonami Exo
2018-06-25 21:14:58 +02:00
parent 551b0044ce
commit d65f8ecc0d
15 changed files with 389 additions and 278 deletions
+8 -15
View File
@@ -34,10 +34,7 @@ Creating a client
.. code:: python
import asyncio
loop = asyncio.get_event_loop()
from telethon import TelegramClient
from telethon import TelegramClient, sync
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
@@ -45,7 +42,7 @@ Creating a client
api_hash = '0123456789abcdef0123456789abcdef'
client = TelegramClient('session_name', api_id, api_hash)
loop.run_until_complete(client.start())
client.start()
Doing stuff
@@ -53,18 +50,14 @@ Doing stuff
.. code:: python
async def main():
me = await client.get_me()
print(me.stringify())
print(client.get_me().stringify())
await client.send_message('username', 'Hello! Talking to you from Telethon')
await client.send_file('username', '/home/myself/Pictures/holidays.jpg')
client.send_message('username', 'Hello! Talking to you from Telethon')
client.send_file('username', '/home/myself/Pictures/holidays.jpg')
await client.download_profile_photo('me')
messages = await client.get_messages('username')
await messages[0].download_media()
loop.run_until_complete(main())
client.download_profile_photo('me')
messages = client.get_messages('username')
messages[0].download_media()
Next steps