From 598851f8695682ba7e3c42060e77cfedb0062fec Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sat, 6 May 2017 21:35:09 +1000 Subject: [PATCH] TelegramClient: Perform disconnection on class destruction --- telethon/telegram_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index d5190edc..d8889aeb 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -43,7 +43,7 @@ class TelegramClient: # Current TelegramClient version __version__ = '0.8' - # region Initialization + # region Default methods of class def __init__(self, session, api_id, api_hash, proxy=None): """Initializes the Telegram client with the specified API ID and Hash. @@ -82,6 +82,10 @@ class TelegramClient: # We need to be signed in before we can listen for updates self.signed_in = False + def __del__(self): + """Releases the Telegram client, performing disconnection.""" + self.disconnect() + # endregion # region Connecting