From 0409ce67ce0149da5621e79d9ab045cc22b16a39 Mon Sep 17 00:00:00 2001 From: Foad Sojoodi Farimani Date: Wed, 1 Apr 2020 21:52:58 +0200 Subject: [PATCH] Update index.rst to avoid multiple errors and warnings --- readthedocs/index.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/readthedocs/index.rst b/readthedocs/index.rst index 0776e3f2..36a4ff28 100644 --- a/readthedocs/index.rst +++ b/readthedocs/index.rst @@ -4,9 +4,21 @@ Telethon's Documentation .. 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 - 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!') print(client.download_profile_photo('me'))