MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / _extract_otp_code

Method _extract_otp_code

src/services/temp_mail.py:261–278  ·  view source on GitHub ↗

提取验证码并返回是否语义命中。 优先语义匹配(code is 123456),降低误匹配邮件正文中随机 6 位数字的概率。

(self, content: str, pattern: str)

Source from the content-addressed store, hash-verified

259 return any(keyword in blob for keyword in otp_keywords)
260
261 def _extract_otp_code(self, content: str, pattern: str) -> Tuple[Optional[str], bool]:
262 """
263 提取验证码并返回是否语义命中。
264 优先语义匹配(code is 123456),降低误匹配邮件正文中随机 6 位数字的概率。
265 """
266 text = str(content or "")
267 if not text:
268 return None, False
269
270 semantic_match = re.search(OTP_CODE_SEMANTIC_PATTERN, text, re.IGNORECASE)
271 if semantic_match:
272 return semantic_match.group(1), True
273
274 simple_match = re.search(pattern, text)
275 if simple_match:
276 return simple_match.group(1), False
277
278 return None, False
279
280 def _admin_headers(self) -> Dict[str, str]:
281 """构造 admin 请求头"""

Callers 1

get_verification_codeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected