Closed zizhuangfly closed 3 months ago
Telegram isn't supposed to be used and TDLib can't be run in storage-less environment. Telegram apps must store state and continuous write and read access to a writable directory is required for this.
yep, I totally agree with you. the environment is not as fully storage as general pc or vps/server, but It is not completely without storage system. I can store the session/token file in somewhere (like kv store or something the system supplies) for later use, which I can store and copy to the target path before running TDLib so that telegram will take it as the same device and session as before. So the question is where I can find the session/token files after log in, maybe the file is a sqlite db or a collection of files, and it just does not matter. Hope I made it clear, if not, please tell me, I will try to explain with more details as I'm not so good at English. ps: I can succeed log in using TDLib in that system and that is to say the system supply a writable and readable storage for use, it is just not persistent but temporary for one-time use, which I can manually handle as above. Thank you!
This is not enough. There is nothing like "token" in TDLib. The full state must be persisted.
OK, so where the full state is stored, whatever the stored format. I can dig in and duplicate the state.
even if the state consist of some generated files and hardware recognize information like mac address, It's ok. please help.
You can't duplicate the state, Telegram can't work this way. You must use the modified by the previous run state for the next run.
OK, got it.
after reading the doc, I found the database_directory
and files_directory
parameters which are just what I am looking for.
I said "duplicate the state" actually means storing files for later use and then copy/download back, not manually manipulating the files. sorry for not expressing clearly.
this is what I'm gonna do: save another copy of the binlogs/sqlite db to somewhere after telegram.stop()
(as it's temporary and will disappear after restart) , and when restarting, copy back the backups from there before log in.
I've tried and it works.
could you tell me what is the default authenticate TTL before it expires and does it support to be configured through the api?
If you persist exact content of the database directory between launches with all modification done during run time, then it should be fine.
Everything is the same as in all Telegram apps. If session is active, then it is valid forever.
some more questions:
get_chat_history
or some other similar functions, then the msgs/files/stickers won't be auto downloaded/retrieved from server in the background by TDLib, is it true?use_file_database
, use_chat_info_database
, use_message_database
all to false
, then whether I call such involved query functions or not , TDLib won't save msgs in local cache/files, is it true?thank you so much for support! ♥️♥️
background: I use
tdlib
for my private usage, currently I run the program by jupyter notebook of online service for some scheduled job. question: the runtime is all fresh every time it runs, so when it's scheduled to run or restarted, it need to be supplied with confirmation code or password to login and authenticate, as telegram will treat is as a new device and fresh session. I suppose that there must be some session/token file being saved after login, which I can stores and supply to tdlib to avoid inputing codes, thus make the job run automatically without any human Interaction. so if that's the case, where is the session file stored? and how can I tell explicitly to tdlib to use it?