fix(yyds): fix Chinese garbled characters
This commit is contained in:
+19
-19
@@ -874,7 +874,7 @@ def http_post(url, **kwargs):
|
|||||||
|
|
||||||
def raise_if_cancelled(cancel_callback=None):
|
def raise_if_cancelled(cancel_callback=None):
|
||||||
if cancel_callback and cancel_callback():
|
if cancel_callback and cancel_callback():
|
||||||
raise RegistrationCancelled("鐢ㄦ埛鍋滄娉ㄥ唽")
|
raise RegistrationCancelled("用户停止注册")
|
||||||
|
|
||||||
|
|
||||||
def sleep_with_cancel(seconds, cancel_callback=None):
|
def sleep_with_cancel(seconds, cancel_callback=None):
|
||||||
@@ -1063,7 +1063,7 @@ def yyds_create_account(address=None, domain=None, api_key=None, jwt=None):
|
|||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get("success"):
|
if data.get("success"):
|
||||||
return data.get("data", {})
|
return data.get("data", {})
|
||||||
raise Exception(f"YYDS 鍒涘缓閭澶辫触: {data}")
|
raise Exception(f"YYDS 创建邮箱失败: {data}")
|
||||||
|
|
||||||
|
|
||||||
def yyds_get_token(address, api_key=None, jwt=None):
|
def yyds_get_token(address, api_key=None, jwt=None):
|
||||||
@@ -1081,7 +1081,7 @@ def yyds_get_token(address, api_key=None, jwt=None):
|
|||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get("success"):
|
if data.get("success"):
|
||||||
return data.get("data", {}).get("token")
|
return data.get("data", {}).get("token")
|
||||||
raise Exception(f"YYDS 鑾峰彇token澶辫触: {data}")
|
raise Exception(f"YYDS 获取token失败: {data}")
|
||||||
|
|
||||||
|
|
||||||
def yyds_get_messages(address, token=None, api_key=None, jwt=None):
|
def yyds_get_messages(address, token=None, api_key=None, jwt=None):
|
||||||
@@ -1117,7 +1117,7 @@ def yyds_get_message_detail(message_id, token=None, api_key=None, jwt=None):
|
|||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get("success"):
|
if data.get("success"):
|
||||||
return data.get("data", {})
|
return data.get("data", {})
|
||||||
raise Exception(f"YYDS 鑾峰彇閭欢璇︽儏澶辫触: {data}")
|
raise Exception(f"YYDS 获取邮件详情失败: {data}")
|
||||||
|
|
||||||
|
|
||||||
def yyds_generate_username(length=10):
|
def yyds_generate_username(length=10):
|
||||||
@@ -1128,7 +1128,7 @@ def yyds_generate_username(length=10):
|
|||||||
def yyds_pick_domain(api_key=None, jwt=None):
|
def yyds_pick_domain(api_key=None, jwt=None):
|
||||||
domains = yyds_get_domains(api_key=api_key, jwt=jwt)
|
domains = yyds_get_domains(api_key=api_key, jwt=jwt)
|
||||||
if not domains:
|
if not domains:
|
||||||
raise Exception("YYDS 娌℃湁杩斿洖浠讳綍鍙敤鍩熷悕")
|
raise Exception("YYDS 没有返回任何可用域名")
|
||||||
private = [d for d in domains if d.get("isVerified") and not d.get("isPublic")]
|
private = [d for d in domains if d.get("isVerified") and not d.get("isPublic")]
|
||||||
if private:
|
if private:
|
||||||
return private[0]["domain"]
|
return private[0]["domain"]
|
||||||
@@ -1138,7 +1138,7 @@ def yyds_pick_domain(api_key=None, jwt=None):
|
|||||||
verified = [d for d in domains if d.get("isVerified")]
|
verified = [d for d in domains if d.get("isVerified")]
|
||||||
if verified:
|
if verified:
|
||||||
return verified[0]["domain"]
|
return verified[0]["domain"]
|
||||||
raise Exception("YYDS 鏃犲凡楠岃瘉鍩熷悕鍙敤")
|
raise Exception("YYDS 无已验证域名可用")
|
||||||
|
|
||||||
|
|
||||||
def yyds_get_email_and_token(api_key=None, jwt=None):
|
def yyds_get_email_and_token(api_key=None, jwt=None):
|
||||||
@@ -1156,8 +1156,8 @@ def yyds_get_email_and_token(api_key=None, jwt=None):
|
|||||||
if not temp_token:
|
if not temp_token:
|
||||||
temp_token = yyds_get_token(address, api_key=key, jwt=token)
|
temp_token = yyds_get_token(address, api_key=key, jwt=token)
|
||||||
if not temp_token:
|
if not temp_token:
|
||||||
raise Exception("鑾峰彇 YYDS token 澶辫触")
|
raise Exception("获取 YYDS token 失败")
|
||||||
print(f"[*] 宸插垱寤?YYDS 閭: {address}")
|
print(f"[*] 已创建 YYDS 邮箱: {address}")
|
||||||
return address, temp_token
|
return address, temp_token
|
||||||
|
|
||||||
|
|
||||||
@@ -1178,7 +1178,7 @@ def yyds_get_oai_code(
|
|||||||
messages = yyds_get_messages(address, token=token, jwt=jwt)
|
messages = yyds_get_messages(address, token=token, jwt=jwt)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] YYDS 鎷夊彇閭欢鍒楄〃澶辫触: {exc}")
|
log_callback(f"[Debug] YYDS 拉取邮件列表失败: {exc}")
|
||||||
sleep_with_cancel(poll_interval, cancel_callback)
|
sleep_with_cancel(poll_interval, cancel_callback)
|
||||||
continue
|
continue
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
@@ -1193,7 +1193,7 @@ def yyds_get_oai_code(
|
|||||||
detail = yyds_get_message_detail(msg_id, token=token, jwt=jwt)
|
detail = yyds_get_message_detail(msg_id, token=token, jwt=jwt)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] YYDS 鑾峰彇閭欢璇︽儏澶辫触: {exc}")
|
log_callback(f"[Debug] YYDS 获取邮件详情失败: {exc}")
|
||||||
continue
|
continue
|
||||||
parts = []
|
parts = []
|
||||||
text_body = detail.get("text") or ""
|
text_body = detail.get("text") or ""
|
||||||
@@ -1205,11 +1205,11 @@ def yyds_get_oai_code(
|
|||||||
combined = "\n".join(parts)
|
combined = "\n".join(parts)
|
||||||
subject = detail.get("subject", "")
|
subject = detail.get("subject", "")
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] YYDS 鏀跺埌閭欢: {subject}")
|
log_callback(f"[Debug] YYDS 收到邮件: {subject}")
|
||||||
code = extract_verification_code(combined, subject)
|
code = extract_verification_code(combined, subject)
|
||||||
if code:
|
if code:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[*] YYDS 浠庨偖浠朵腑鎻愬彇鍒伴獙璇佺爜: {code}")
|
log_callback(f"[*] YYDS 从邮件中提取到验证码: {code}")
|
||||||
return code
|
return code
|
||||||
sleep_with_cancel(poll_interval, cancel_callback)
|
sleep_with_cancel(poll_interval, cancel_callback)
|
||||||
raise Exception(f"YYDS 在 {timeout}s 内未收到验证码邮件")
|
raise Exception(f"YYDS 在 {timeout}s 内未收到验证码邮件")
|
||||||
@@ -1223,7 +1223,7 @@ def generate_username(length=10):
|
|||||||
def pick_domain(api_key=None):
|
def pick_domain(api_key=None):
|
||||||
domains = get_domains(api_key=api_key)
|
domains = get_domains(api_key=api_key)
|
||||||
if not domains:
|
if not domains:
|
||||||
raise Exception("DuckMail 娌℃湁杩斿洖浠讳綍鍙敤鍩熷悕")
|
raise Exception("DuckMail 没有返回任何可用域名")
|
||||||
private = [d for d in domains if d.get("ownerId")]
|
private = [d for d in domains if d.get("ownerId")]
|
||||||
verified_private = [d for d in private if d.get("isVerified")]
|
verified_private = [d for d in private if d.get("isVerified")]
|
||||||
if verified_private:
|
if verified_private:
|
||||||
@@ -1231,7 +1231,7 @@ def pick_domain(api_key=None):
|
|||||||
public = [d for d in domains if d.get("isVerified")]
|
public = [d for d in domains if d.get("isVerified")]
|
||||||
if public:
|
if public:
|
||||||
return public[0]["domain"]
|
return public[0]["domain"]
|
||||||
raise Exception("DuckMail 鏃犲凡楠岃瘉鍩熷悕鍙敤")
|
raise Exception("DuckMail 无已验证域名可用")
|
||||||
|
|
||||||
|
|
||||||
def get_email_provider():
|
def get_email_provider():
|
||||||
@@ -1280,7 +1280,7 @@ def get_email_and_token(api_key=None):
|
|||||||
create_account(address, password, api_key=key, expires_in=0)
|
create_account(address, password, api_key=key, expires_in=0)
|
||||||
token = get_token(address, password)
|
token = get_token(address, password)
|
||||||
if not token:
|
if not token:
|
||||||
raise Exception("鑾峰彇 DuckMail token 澶辫触")
|
raise Exception("获取 DuckMail token 失败")
|
||||||
return address, token
|
return address, token
|
||||||
|
|
||||||
|
|
||||||
@@ -1445,7 +1445,7 @@ def duckmail_get_oai_code(
|
|||||||
messages = get_messages(dev_token)
|
messages = get_messages(dev_token)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] 鎷夊彇閭欢鍒楄〃澶辫触: {exc}")
|
log_callback(f"[Debug] 拉取邮件列表失败: {exc}")
|
||||||
sleep_with_cancel(poll_interval, cancel_callback)
|
sleep_with_cancel(poll_interval, cancel_callback)
|
||||||
continue
|
continue
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
@@ -1460,7 +1460,7 @@ def duckmail_get_oai_code(
|
|||||||
detail = get_message_detail(dev_token, msg_id)
|
detail = get_message_detail(dev_token, msg_id)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] 鑾峰彇閭欢璇︽儏澶辫触: {exc}")
|
log_callback(f"[Debug] 获取邮件详情失败: {exc}")
|
||||||
continue
|
continue
|
||||||
parts = []
|
parts = []
|
||||||
text_body = detail.get("text") or ""
|
text_body = detail.get("text") or ""
|
||||||
@@ -1472,11 +1472,11 @@ def duckmail_get_oai_code(
|
|||||||
combined = "\n".join(parts)
|
combined = "\n".join(parts)
|
||||||
subject = detail.get("subject", "")
|
subject = detail.get("subject", "")
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[Debug] 鏀跺埌閭欢: {subject}")
|
log_callback(f"[Debug] 收到邮件: {subject}")
|
||||||
code = extract_verification_code(combined, subject)
|
code = extract_verification_code(combined, subject)
|
||||||
if code:
|
if code:
|
||||||
if log_callback:
|
if log_callback:
|
||||||
log_callback(f"[*] 浠庨偖浠朵腑鎻愬彇鍒伴獙璇佺爜: {code}")
|
log_callback(f"[*] 从邮件中提取到验证码: {code}")
|
||||||
return code
|
return code
|
||||||
sleep_with_cancel(poll_interval, cancel_callback)
|
sleep_with_cancel(poll_interval, cancel_callback)
|
||||||
raise Exception(f"在 {timeout}s 内未收到验证码邮件")
|
raise Exception(f"在 {timeout}s 内未收到验证码邮件")
|
||||||
|
|||||||
Reference in New Issue
Block a user