Fix TelegramClient initialize with None session

This commit is contained in:
Lindsay Zhou 2024-03-30 15:59:54 +08:00
parent 75d609ab2a
commit be7e10e246
No known key found for this signature in database
GPG Key ID: ECBDA6E4719D5816

View File

@ -285,7 +285,7 @@ class TelegramBaseClient(abc.ABC):
self._log = _Loggers() self._log = _Loggers()
# Determine what session object we have # Determine what session object we have
if isinstance(session, (str, pathlib.Path)) or session is None: if isinstance(session, (str, pathlib.Path)):
try: try:
session = SQLiteSession(str(session)) session = SQLiteSession(str(session))
except ImportError: except ImportError:
@ -298,6 +298,8 @@ class TelegramBaseClient(abc.ABC):
'you use another session storage' 'you use another session storage'
) )
session = MemorySession() session = MemorySession()
elif session is None:
session = MemorySession()
elif not isinstance(session, Session): elif not isinstance(session, Session):
raise TypeError( raise TypeError(
'The given session must be a str or a Session instance.' 'The given session must be a str or a Session instance.'