From 192e679c6d6abaed197294c36f1de82822576156 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 18 Jun 2023 02:06:49 +0800 Subject: [PATCH] docs with changes --- Difficult_Rocket/client/__init__.py | 1 - Difficult_Rocket/command/api.py | 11 +++++++---- docs/src/change_log/dr_sdk.md | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index 479dc2b..91a3e7c 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -308,7 +308,6 @@ class ClientWindow(Window): @_call_screen_after def on_command(self, command: line.CommandText): - print(command.find('/')) self.logger.info(tr().window.command.text().format(command)) if command.find('stop'): # self.dispatch_event('on_exit') diff --git a/Difficult_Rocket/command/api.py b/Difficult_Rocket/command/api.py index b9b770a..78a236e 100644 --- a/Difficult_Rocket/command/api.py +++ b/Difficult_Rocket/command/api.py @@ -44,10 +44,13 @@ class CommandText: i += 1 def find(self, text: str) -> bool: - find = self.text.find(text) - if find != -1: - self.text = self.text[find + len(text):] - return True + print(f'text: {text} startswith: {self.text.startswith(text)} find: {self.text.find(text)}') + startswitch = self.text.startswith(text) + if startswitch: + find = self.text.find(text) + if find != -1: + self.text = self.text[find + len(text):] if not self.text[find+len(text)] == ' ' else self.text[find + len(text) + 1:] + return True return False def re_find(self, text: str) -> Union[str, bool]: diff --git a/docs/src/change_log/dr_sdk.md b/docs/src/change_log/dr_sdk.md index 1829b9d..821e925 100644 --- a/docs/src/change_log/dr_sdk.md +++ b/docs/src/change_log/dr_sdk.md @@ -11,6 +11,21 @@ - issue #33 (https://github.com/shenjackyuanjie/Difficult-Rocket/issues/33) - 修复了实际上并不会加载 `.otf` 格式的字体文件的问题 +### 修改 + +- 现在输入命令之后不会输出一个 `True`/`False` 了 + - (实际上是用来检测命令是不是用 `/` 开头的) + - Now, the command will not output a `True`/`False` + - (Actually used to detect whether the command starts with `/`) +- `CommandText` + - `find` + - 现在会先用 `str.startswith` 检测是否以要求的字符串开头 + - 实际上就是丐版 `re.match` + - 并且会在匹配上之后 如果匹配内容后面第一个字符是空格 则会截取掉空格 + - Now, it will first use `str.startswith` to detect whether it starts with the required string + - Actually a poor version of `re.match` + - And after matching, if the first character after the matching content is a space, the space will be intercepted + ## DR sdk 0.8.3.0 ### 删除