diff --git a/README.md b/README.md index c822f3a..15132ca 100755 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ If you don't follow these steps, the bot may not works. - `/dir` to show current OneDrive directory. - `/dir $remote_path` to set OneDrive directory. - `/dir temp $remote_path` to set temporary OneDrive directory. +- `/dir temp cancel` to restore OneDrive directory to the previous one. - `/dir reset` to reset OneDrive directory to default. - `/help` for help. diff --git a/modules/global_var.py b/modules/global_var.py index 9219f40..8d2ea15 100644 --- a/modules/global_var.py +++ b/modules/global_var.py @@ -59,6 +59,8 @@ To set OneDrive directory. ```/dir temp $remote_path``` To set temporary OneDrive directory. +```/dir temp cancel``` +To restore OneDrive directory to the previous one. ```/dir reset``` To reset OneDrive directory to default. @@ -142,4 +144,6 @@ ```/dir $remote_path``` ```/dir temp $remote_path``` + +```/dir temp cancel``` ''' \ No newline at end of file diff --git a/modules/handlers/dir.py b/modules/handlers/dir.py index fda00ca..f6e9b45 100644 --- a/modules/handlers/dir.py +++ b/modules/handlers/dir.py @@ -40,16 +40,23 @@ async def dir_handler(event): await event.respond(f'Directory set to `{Dir.path}`') else: await event.respond('Directory path should start with /') - # /dir temp $remote_path + elif len(cmd) == 3: sub_cmd = cmd[1] if sub_cmd == 'temp': - remote_path = cmd[2].strip().strip('*') - if remote_path.startswith('/'): - Dir.set_temp_path(remote_path) - await event.respond(f'Temporary directory set to `{Dir.path}`') + sub_cmd = cmd[2] + # /dir temp $remote_path + if sub_cmd != 'cancel': + remote_path = cmd[2].strip().strip('*') + if remote_path.startswith('/'): + Dir.set_temp_path(remote_path) + await event.respond(f'Temporary directory set to `{Dir.path}`') + else: + await event.respond('Directory path should start with /') + # /dir temp cancel else: - await event.respond('Directory path should start with /') + Dir.check_temp() + await event.respond(f'Directory restored to `{Dir.path}') else: raise CMDException('Sub command of /dir temp wrong.') else: