mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2026-09-05 16:40:42 +00:00
Document the magic sync module
This commit is contained in:
+8
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user