Conversation
DeepSource reviewed changes in the commit range For detailed review results, please see the PR on DeepSource ↗ PR Report Card
Code Review Summary
How are these analyzer statuses calculated?Administrators can configure which issue categories are reported and cause analysis to be marked as failed when detected. This helps prevent bad and insecure code from being introduced in the codebase. If you're an administrator, you can modify this in the repository's settings. |
|
|
| @@ -0,0 +1,585 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
导入的 annotations 没有被使用,应当删除。
| from __future__ import annotations |
| super().__init__(frame) | ||
|
|
||
| default_cfg = { | ||
| "提示词": "r", |
|
|
||
| reporter: str | ||
| target: str | ||
| created_ts: float |
There was a problem hiding this comment.
created_ts 可以考虑更换为 created_unix_time。
| self.name, std_cfg, default_cfg, self.version | ||
| ) | ||
|
|
||
| self.funclib = None |
| self._q: Deque[_ReportCase] = deque() | ||
| self._q_event = threading.Event() | ||
| self._q_lock = threading.Lock() |
| try: | ||
| raw = {"rawtext": [{"text": text}]} | ||
| raw_s = json.dumps(raw, ensure_ascii=False) | ||
| cmd = f'/tellraw @a[name="{player_name}"] {raw_s}' |
| def _ws_has_receipt(resp: Any, *, allow_empty: bool = False) -> bool: | ||
| """判断 ws 指令是否收到回执""" | ||
| if isinstance(resp, list): | ||
| if not resp: | ||
| return bool(allow_empty) | ||
| first = resp[0] | ||
| if isinstance(first, dict): | ||
| return bool(first.get("Success", False)) | ||
| return bool(allow_empty) | ||
|
|
||
| try: | ||
| out = getattr(resp, "OutputMessages", None) | ||
| if out: | ||
| return bool(out[0].Success) | ||
| except Exception: | ||
| return bool(allow_empty) | ||
|
|
||
| return bool(allow_empty) |
There was a problem hiding this comment.
可以保证 Success 和 OutputMessages 一定存在。
| return KillAuraReport._ws_has_receipt(resp, allow_empty=False) | ||
|
|
||
| @staticmethod | ||
| def _ws_get_first_parameter(resp: Any) -> Optional[Any]: |
There was a problem hiding this comment.
可以保证 Success 和 OutputMessages 一定存在。
| if not isinstance(first, dict): | ||
| return None | ||
| params = first.get("Parameters") | ||
| if isinstance(params, list) and params: |
There was a problem hiding this comment.
if isinstance(params, list) and params: 中的 params 最好显式地替换为 len(params) > 0。
| def _querytarget_self_pos(self) -> Optional[Tuple[float, float, float]]: | ||
| """querytarget @s 获取机器人坐标""" | ||
| try: | ||
| resp = self.game_ctrl.sendwscmd_with_resp("/querytarget @s", 2) | ||
| parameter = self._ws_get_first_parameter(resp) | ||
| result_list = self._parse_querytarget_parameter(parameter) | ||
| if not result_list: | ||
| return None | ||
|
|
||
| one = result_list[0] | ||
| if not isinstance(one, dict): | ||
| return None | ||
|
|
||
| pos = one.get("position") | ||
| if not isinstance(pos, dict): | ||
| return None | ||
|
|
||
| x = pos.get("x") | ||
| y = pos.get("y") | ||
| z = pos.get("z") | ||
| if not all(isinstance(v, (int, float)) for v in (x, y, z)): | ||
| return None | ||
|
|
||
| return (float(x), float(y), float(z)) | ||
| except Exception: | ||
| return None |
There was a problem hiding this comment.
非前置插件不应使用 querytarget 命令获取坐标。
请使用前置插件 前置_循环获取玩家坐标 进行替代。
There was a problem hiding this comment.
看起来你在不正确的位置发送了评论(因为这里是关于 querytarget 的)。
当然,我测试了 kick 命令,kick @a 和 kick @a[tag=abc] 都是不能用的(这意味着我之前的说法仍然是正确的?)
There was a problem hiding this comment.
看起来你在不正确的位置发送了评论(因为这里是关于
querytarget的)。 当然,我测试了kick命令,kick @a和kick @a[tag=abc]都是不能用的(这意味着我之前的说法仍然是正确的?)
我是说name是能用的,kick @a不行但是kick @a[name=abc]可以🙃
There was a problem hiding this comment.
居然还存在这样的用法吗,看起来这太抽象了。
不过既然你已经知道名称了,那么再使用 @a[name=abc] 的目的是什么?
举报使用杀戮光环的玩家并对其检测。