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

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

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.