(self, points: list[CaptchaPoint | dict[str, Any]])
| 74 | return ticket, randstr |
| 75 | |
| 76 | def build_click_answer(self, points: list[CaptchaPoint | dict[str, Any]]) -> list[dict[str, Any]]: |
| 77 | if not points: |
| 78 | raise BadRequestError("缺少点击点位,没法组装腾讯 verify 的 ans") |
| 79 | |
| 80 | normalized: list[tuple[int, int, int]] = [] |
| 81 | for index, item in enumerate(points, start=1): |
| 82 | point = item if isinstance(item, CaptchaPoint) else CaptchaPoint.model_validate(item) |
| 83 | order = int(point.order or index) |
| 84 | normalized.append( |
| 85 | ( |
| 86 | order, |
| 87 | self._js_round(point.x), |
| 88 | self._js_round(point.y), |
| 89 | ) |
| 90 | ) |
| 91 | |
| 92 | normalized.sort(key=lambda item: (item[0], item[1], item[2])) |
| 93 | answer: list[dict[str, Any]] = [] |
| 94 | for elem_id, (_, x, y) in enumerate(normalized, start=1): |
| 95 | answer.append( |
| 96 | { |
| 97 | "elem_id": elem_id, |
| 98 | "type": "DynAnswerType_POS", |
| 99 | "data": f"{x},{y}", |
| 100 | } |
| 101 | ) |
| 102 | return answer |
| 103 | |
| 104 | def extract_points_from_ocr(self, ocr_payload: dict[str, Any]) -> list[CaptchaPoint]: |
| 105 | raw_points = ocr_payload.get("points") |
no test coverage detected