def restart(update: Update, context: CallbackContext):
    restart_message = sendMessage("Restarting, Please wait!", context.bot, update)
    # Save restart message ID and chat ID in order to edit it after restarting
    with open(".restartmsg", "w") as f:
        f.truncate(0)
        f.write(f"{restart_message.chat.id}\n{restart_message.message_id}\n")
    fs_utils.clean_all()
    os.execl(executable, executable, "-m", "pmb")
Example #2
0
def restart(update: Update, context: CallbackContext):
    restart_msg = sendMessage('Restarting, Please Wait...', context.bot,
                              update)
    LOGGER.info(f'Restarting the Bot...')
    fs_utils.clean_all()
    killAll()
    if DYNAMIC_CONFIG:
        time.sleep(3)
        restart_msg.edit_text(f'Syncing to Google Drive...')
        sync.handler(configList)
        restart_msg.edit_text(f'Sync Completed!\n{configList}')
    if not DYNAMIC_CONFIG:
        time.sleep(5)
    # Save restart message info in order to reply to it after restarting
    restart_msg_dat = f"{restart_msg.chat_id} {restart_msg.message_id}"
    open('restart_msg.txt', 'wt').write(restart_msg_dat)
    execl(executable, executable, "-m", "pmb")