Telethon - 更改会话文件路径
Telethon - change session file path
我想重用现有的会话文件(phonenumber.session)文件,
但我想将它的默认路径(工作目录)更改为另一个目录,例如'/data/se.session'
在电视节目中有任何选择吗?
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Enter the code: '))
当使用 TLSharp 时,TelegramClient 构造函数获取会话文件路径作为输入..
查看电视节目源代码后,我发现 this、
session (`str` | `telethon.sessions.abstract.Session`, `None`):
The file name of the session file to be used if a string is
given (it may be a full path), or the Session instance to be
used otherwise. If it's `None`, the session will not be saved,
and you should call :meth:`.log_out()` when you're done.
Note that if you pass a string it will be a file in the current
working directory, although you can also pass absolute paths.
The session file contains enough information for you to login
without re-sending the code, so if you have to enter the code
more than once, maybe you're changing the working directory,
renaming or removing the file, or using random names.
通常,在创建 TelegramClient 对象时 - 将会话文件的完整路径传递给它
client = TelegramClient('path/to/session.session',api_id,app_hash)
我想重用现有的会话文件(phonenumber.session)文件,
但我想将它的默认路径(工作目录)更改为另一个目录,例如'/data/se.session'
在电视节目中有任何选择吗?
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
client.sign_in(phone, input('Enter the code: '))
当使用 TLSharp 时,TelegramClient 构造函数获取会话文件路径作为输入..
查看电视节目源代码后,我发现 this、
session (`str` | `telethon.sessions.abstract.Session`, `None`):
The file name of the session file to be used if a string is
given (it may be a full path), or the Session instance to be
used otherwise. If it's `None`, the session will not be saved,
and you should call :meth:`.log_out()` when you're done.
Note that if you pass a string it will be a file in the current
working directory, although you can also pass absolute paths.
The session file contains enough information for you to login
without re-sending the code, so if you have to enter the code
more than once, maybe you're changing the working directory,
renaming or removing the file, or using random names.
通常,在创建 TelegramClient 对象时 - 将会话文件的完整路径传递给它
client = TelegramClient('path/to/session.session',api_id,app_hash)