import traceback, sys, pathlib, telethon, telethon.sync sys.argv[0]='bot.py' try: exec(pathlib.Path("bot.py").read_text()) except: traceback.print_exc() input("Press Enter to exit.")