From 96d8ca94cf15c3ee09b0a136b26326e812413720 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 14 Jun 2017 13:56:42 +0200 Subject: [PATCH] Move TelegramClient.list_sessions to *Session.list_session --- telethon/telegram_client.py | 9 --------- telethon/tl/session.py | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 4deb98cd..009a07a5 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -1,7 +1,5 @@ -import platform from datetime import timedelta from mimetypes import guess_type -from os import listdir, path from threading import Event, RLock, Thread from time import sleep @@ -364,13 +362,6 @@ class TelegramClient(TelegramBareClient): except UnauthorizedError: return None - @staticmethod - def list_sessions(): - """Lists all the sessions of the users who have ever connected - using this client and never logged out""" - return [path.splitext(path.basename(f))[0] - for f in listdir('.') if f.endswith('.session')] - # endregion # region Dialogs ("chats") requests diff --git a/telethon/tl/session.py b/telethon/tl/session.py index 70319da6..3f42f51c 100644 --- a/telethon/tl/session.py +++ b/telethon/tl/session.py @@ -145,6 +145,14 @@ class JsonSession: except OSError: return False + @staticmethod + def list_sessions(): + """Lists all the sessions of the users who have ever connected + using this client and never logged out + """ + return [os.path.splitext(os.path.basename(f))[0] + for f in os.listdir('.') if f.endswith('.session')] + @staticmethod def try_load_or_create_new(session_user_id): """Loads a saved session_user_id.session or creates a new one.