the session file as (.session) but its not saving and i got no error. what should i do about this?
@client.on(events.NewMessage(chats=(-1001963929324)))
async def handle_new_message(event):
if event.message:
# Respond to the message with the predefined message
await client.send_message('sepi_rosho',"Test Acc1")
await client.forward_messages('pashmak_abdo', event.message)
# Start the client
client.start()
client.session.save()
client.run_until_disconnected()
you don't need to save it manually, disconnect properly, the .session is genrate as client.session.filename
thats the point. it doesnt generate but next time i run my code, it doesnt want me to login again. im wondering where that session files whould save
it has to be in client.session.filename. as long as you don't face runtime error that database is not accessible, you're just checking wrong
it should save in the same directory right?
it should, unless you pass directory to TelegramClient
show your TelegramClient part of code
they're literally different directories doe or am i seeing it wrong, just print the import os print(os.getcwd()) in your code and navigate there.
im running the code in my vps i got this screen shot from my pc
your system is to blame them.. as long as you don't pass :memory: as session name, it has no reason to not create it. see if the session exists while the script is running, and do the prints and stuff
code works fine but there is no session file in that directory even when the code is running
well that's weird, telethon writes to the database, system deleting it with no error poping while running is unrealistic session creation happens once you make an instance. you don't need to start or save the code you show can't have such issues afaik, confirm it better, you may be running it from a different workdir, if it started to happen recently
i found the problem and its kinda crazy when you run the code through vs code, it saves the session files in another directory but when you manully enter your folder and run it using cmd and 'py' command, the session file will create in the same directory
yeah, this is expected. that's why i said print your cwd. you can use os.chdir to change cwd where your .py file
yeah thanks for helping me
Обсуждают сегодня