Skip to content

Commit

Permalink
feat: add /dir temp cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
hlf20010508 committed Dec 27, 2023
1 parent ddd6c56 commit f4f8e1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions modules/global_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -142,4 +144,6 @@
```/dir $remote_path```
```/dir temp $remote_path```
```/dir temp cancel```
'''
19 changes: 13 additions & 6 deletions modules/handlers/dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f4f8e1a

Please sign in to comment.