Skip to content

Commit

Permalink
Merge pull request #5 from mc-cloud-town/Fix/file-sync-path-data-error
Browse files Browse the repository at this point in the history
fix emit event FileEncode file path
  • Loading branch information
a3510377 authored Feb 10, 2024
2 parents e4a23a7 + f170b59 commit 7d391e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chatbridgee/chatbridgee/file_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ def on_command_send(self, source: CommandSource = None, ctx: dict = {}) -> None:
source.reply(RText(tr("no_args").format(arg="filename"), color=RColor.red))
return

path = Path(config.file_sync_path) / f"{filename}{config.file_sync_extension}"
if not filename.endswith(config.file_sync_extension):
filename += config.file_sync_extension

path = Path(config.file_sync_path) / filename
if not path.is_file():
source.reply(RText("檔案未找到", color=RColor.red))
return

self.sio.emit("file_sync", FileEncode(path, path.read_bytes()).encode())
self.sio.emit("file_sync", FileEncode(filename, path.read_bytes()).encode())

source.reply("檔案傳送完成")

Expand Down

0 comments on commit 7d391e6

Please sign in to comment.