Move TelegramClient.list_sessions to *Session.list_session

This commit is contained in:
Lonami Exo
2017-06-14 13:56:42 +02:00
parent 56bf5f7c87
commit 96d8ca94cf
2 changed files with 8 additions and 9 deletions

View File

@@ -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.