Update index.rst

to avoid multiple errors and warnings
This commit is contained in:
Foad Sojoodi Farimani 2020-04-01 21:52:58 +02:00 committed by GitHub
parent 15f30ed942
commit 0409ce67ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,21 @@ Telethon's Documentation
.. code-block:: python .. code-block:: python
import sys
import os
os.chdir(sys.path[0])
session_name = "name"
if f"{session_name}.session" in os.listdir():
os.remove(f"{session_name}.session")
import nest_asyncio
nest_asyncio.apply()
from telethon.sync import TelegramClient, events from telethon.sync import TelegramClient, events
with TelegramClient('name', api_id, api_hash) as client: async with TelegramClient(session_name, api_id, api_hash) as client:
client.send_message('me', 'Hello, myself!') client.send_message('me', 'Hello, myself!')
print(client.download_profile_photo('me')) print(client.download_profile_photo('me'))