Merge pull request #13 from muzimu/fix_yyds
fix(yyds): fix Chinese garbled characters
This commit is contained in:
+17
-17
@@ -1192,7 +1192,7 @@ def yyds_get_token(address, api_key=None, jwt=None):
|
||||
data = resp.json()
|
||||
if data.get("success"):
|
||||
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):
|
||||
@@ -1228,7 +1228,7 @@ def yyds_get_message_detail(message_id, token=None, api_key=None, jwt=None):
|
||||
data = resp.json()
|
||||
if data.get("success"):
|
||||
return data.get("data", {})
|
||||
raise Exception(f"YYDS 鑾峰彇閭欢璇︽儏澶辫触: {data}")
|
||||
raise Exception(f"YYDS 获取邮件详情失败: {data}")
|
||||
|
||||
|
||||
def yyds_generate_username(length=10):
|
||||
@@ -1239,7 +1239,7 @@ def yyds_generate_username(length=10):
|
||||
def yyds_pick_domain(api_key=None, jwt=None):
|
||||
domains = yyds_get_domains(api_key=api_key, jwt=jwt)
|
||||
if not domains:
|
||||
raise Exception("YYDS 娌℃湁杩斿洖浠讳綍鍙敤鍩熷悕")
|
||||
raise Exception("YYDS 没有返回任何可用域名")
|
||||
private = [d for d in domains if d.get("isVerified") and not d.get("isPublic")]
|
||||
if private:
|
||||
return private[0]["domain"]
|
||||
@@ -1249,7 +1249,7 @@ def yyds_pick_domain(api_key=None, jwt=None):
|
||||
verified = [d for d in domains if d.get("isVerified")]
|
||||
if verified:
|
||||
return verified[0]["domain"]
|
||||
raise Exception("YYDS 鏃犲凡楠岃瘉鍩熷悕鍙敤")
|
||||
raise Exception("YYDS 无已验证域名可用")
|
||||
|
||||
|
||||
def yyds_get_email_and_token(api_key=None, jwt=None):
|
||||
@@ -1267,8 +1267,8 @@ def yyds_get_email_and_token(api_key=None, jwt=None):
|
||||
if not temp_token:
|
||||
temp_token = yyds_get_token(address, api_key=key, jwt=token)
|
||||
if not temp_token:
|
||||
raise Exception("鑾峰彇 YYDS token 澶辫触")
|
||||
print(f"[*] 宸插垱寤?YYDS 閭: {address}")
|
||||
raise Exception("获取 YYDS token 失败")
|
||||
print(f"[*] 已创建 YYDS 邮箱: {address}")
|
||||
return address, temp_token
|
||||
|
||||
|
||||
@@ -1289,7 +1289,7 @@ def yyds_get_oai_code(
|
||||
messages = yyds_get_messages(address, token=token, jwt=jwt)
|
||||
except Exception as exc:
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] YYDS 鎷夊彇閭欢鍒楄〃澶辫触: {exc}")
|
||||
log_callback(f"[Debug] YYDS 拉取邮件列表失败: {exc}")
|
||||
sleep_with_cancel(poll_interval, cancel_callback)
|
||||
continue
|
||||
for msg in messages:
|
||||
@@ -1304,7 +1304,7 @@ def yyds_get_oai_code(
|
||||
detail = yyds_get_message_detail(msg_id, token=token, jwt=jwt)
|
||||
except Exception as exc:
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] YYDS 鑾峰彇閭欢璇︽儏澶辫触: {exc}")
|
||||
log_callback(f"[Debug] YYDS 获取邮件详情失败: {exc}")
|
||||
continue
|
||||
parts = []
|
||||
text_body = detail.get("text") or ""
|
||||
@@ -1316,11 +1316,11 @@ def yyds_get_oai_code(
|
||||
combined = "\n".join(parts)
|
||||
subject = detail.get("subject", "")
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] YYDS 鏀跺埌閭欢: {subject}")
|
||||
log_callback(f"[Debug] YYDS 收到邮件: {subject}")
|
||||
code = extract_verification_code(combined, subject)
|
||||
if code:
|
||||
if log_callback:
|
||||
log_callback(f"[*] YYDS 浠庨偖浠朵腑鎻愬彇鍒伴獙璇佺爜: {code}")
|
||||
log_callback(f"[*] YYDS 从邮件中提取到验证码: {code}")
|
||||
return code
|
||||
sleep_with_cancel(poll_interval, cancel_callback)
|
||||
raise Exception(f"YYDS 在 {timeout}s 内未收到验证码邮件")
|
||||
@@ -1334,7 +1334,7 @@ def generate_username(length=10):
|
||||
def pick_domain(api_key=None):
|
||||
domains = get_domains(api_key=api_key)
|
||||
if not domains:
|
||||
raise Exception("DuckMail 娌℃湁杩斿洖浠讳綍鍙敤鍩熷悕")
|
||||
raise Exception("DuckMail 没有返回任何可用域名")
|
||||
private = [d for d in domains if d.get("ownerId")]
|
||||
verified_private = [d for d in private if d.get("isVerified")]
|
||||
if verified_private:
|
||||
@@ -1342,7 +1342,7 @@ def pick_domain(api_key=None):
|
||||
public = [d for d in domains if d.get("isVerified")]
|
||||
if public:
|
||||
return public[0]["domain"]
|
||||
raise Exception("DuckMail 鏃犲凡楠岃瘉鍩熷悕鍙敤")
|
||||
raise Exception("DuckMail 无已验证域名可用")
|
||||
|
||||
|
||||
def get_email_provider():
|
||||
@@ -1391,7 +1391,7 @@ def get_email_and_token(api_key=None):
|
||||
create_account(address, password, api_key=key, expires_in=0)
|
||||
token = get_token(address, password)
|
||||
if not token:
|
||||
raise Exception("鑾峰彇 DuckMail token 澶辫触")
|
||||
raise Exception("获取 DuckMail token 失败")
|
||||
return address, token
|
||||
|
||||
|
||||
@@ -1556,7 +1556,7 @@ def duckmail_get_oai_code(
|
||||
messages = get_messages(dev_token)
|
||||
except Exception as exc:
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] 鎷夊彇閭欢鍒楄〃澶辫触: {exc}")
|
||||
log_callback(f"[Debug] 拉取邮件列表失败: {exc}")
|
||||
sleep_with_cancel(poll_interval, cancel_callback)
|
||||
continue
|
||||
for msg in messages:
|
||||
@@ -1571,7 +1571,7 @@ def duckmail_get_oai_code(
|
||||
detail = get_message_detail(dev_token, msg_id)
|
||||
except Exception as exc:
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] 鑾峰彇閭欢璇︽儏澶辫触: {exc}")
|
||||
log_callback(f"[Debug] 获取邮件详情失败: {exc}")
|
||||
continue
|
||||
parts = []
|
||||
text_body = detail.get("text") or ""
|
||||
@@ -1583,11 +1583,11 @@ def duckmail_get_oai_code(
|
||||
combined = "\n".join(parts)
|
||||
subject = detail.get("subject", "")
|
||||
if log_callback:
|
||||
log_callback(f"[Debug] 鏀跺埌閭欢: {subject}")
|
||||
log_callback(f"[Debug] 收到邮件: {subject}")
|
||||
code = extract_verification_code(combined, subject)
|
||||
if code:
|
||||
if log_callback:
|
||||
log_callback(f"[*] 浠庨偖浠朵腑鎻愬彇鍒伴獙璇佺爜: {code}")
|
||||
log_callback(f"[*] 从邮件中提取到验证码: {code}")
|
||||
return code
|
||||
sleep_with_cancel(poll_interval, cancel_callback)
|
||||
raise Exception(f"在 {timeout}s 内未收到验证码邮件")
|
||||
|
||||
Reference in New Issue
Block a user