Generate natural English-style email local-parts with digit suffixes.
Replace random alnum usernames with first/last name patterns ending in 2-4 digits across all email providers.
This commit is contained in:
1 parent
001dc014ea
commit
fc879c09ea
1 file changed
+92
-4
+92
-4
@@ -991,8 +991,7 @@ def yyds_get_message_detail(message_id, token=None, api_key=None, jwt=None):
|
||||
|
||||
|
||||
def yyds_generate_username(length=10):
|
||||
chars = string.ascii_lowercase + string.digits
|
||||
return "".join(secrets.choice(chars) for _ in range(length))
|
||||
return generate_username(length)
|
||||
|
||||
|
||||
def yyds_pick_domain(api_key=None, jwt=None):
|
||||
@@ -1085,9 +1084,98 @@ def yyds_get_oai_code(
|
||||
raise Exception(f"YYDS 在 {timeout}s 内未收到验证码邮件")
|
||||
|
||||
|
||||
# 常见英文名/姓/词根,拼出更像真人的邮箱 local-part
|
||||
_FIRST_NAMES = (
|
||||
"james", "john", "robert", "michael", "david", "william", "richard", "joseph",
|
||||
"thomas", "charles", "daniel", "matthew", "anthony", "mark", "steven", "paul",
|
||||
"andrew", "joshua", "kevin", "brian", "george", "edward", "ronald", "timothy",
|
||||
"jason", "jeffrey", "ryan", "jacob", "gary", "nicholas", "eric", "jonathan",
|
||||
"stephen", "larry", "justin", "scott", "brandon", "benjamin", "samuel", "raymond",
|
||||
"gregory", "frank", "alexander", "patrick", "jack", "dennis", "jerry", "tyler",
|
||||
"aaron", "jose", "adam", "nathan", "henry", "douglas", "zachary", "peter",
|
||||
"kyle", "noah", "ethan", "jeremy", "walter", "christian", "keith", "roger",
|
||||
"mary", "patricia", "jennifer", "linda", "elizabeth", "barbara", "susan", "jessica",
|
||||
"sarah", "karen", "lisa", "nancy", "betty", "margaret", "sandra", "ashley",
|
||||
"kimberly", "emily", "donna", "michelle", "dorothy", "carol", "amanda", "melissa",
|
||||
"deborah", "stephanie", "rebecca", "sharon", "laura", "cynthia", "kathleen", "amy",
|
||||
"angela", "shirley", "anna", "brenda", "pamela", "emma", "nicole", "helen",
|
||||
"samantha", "katherine", "christine", "debra", "rachel", "carolyn", "janet", "catherine",
|
||||
"maria", "heather", "diane", "ruth", "julie", "olivia", "joyce", "virginia",
|
||||
"victoria", "kelly", "lauren", "christina", "joan", "evelyn", "judith", "megan",
|
||||
"cheryl", "andrea", "hannah", "jacqueline", "martha", "gloria", "teresa", "ann",
|
||||
"sara", "madison", "frances", "kathryn", "janice", "jean", "abigail", "alice",
|
||||
"judy", "sophia", "grace", "denise", "amber", "doris", "marilyn", "danielle",
|
||||
"beverly", "isabella", "theresa", "diana", "natalie", "brittany", "charlotte", "marie",
|
||||
"kayla", "alexis", "lori",
|
||||
)
|
||||
_LAST_NAMES = (
|
||||
"smith", "johnson", "williams", "brown", "jones", "garcia", "miller", "davis",
|
||||
"rodriguez", "martinez", "hernandez", "lopez", "gonzalez", "wilson", "anderson", "thomas",
|
||||
"taylor", "moore", "jackson", "martin", "lee", "perez", "thompson", "white",
|
||||
"harris", "sanchez", "clark", "ramirez", "lewis", "robinson", "walker", "young",
|
||||
"allen", "king", "wright", "scott", "torres", "nguyen", "hill", "flores",
|
||||
"green", "adams", "nelson", "baker", "hall", "rivera", "campbell", "mitchell",
|
||||
"carter", "roberts", "gomez", "phillips", "evans", "turner", "diaz", "parker",
|
||||
"cruz", "edwards", "collins", "reyes", "stewart", "morris", "morales", "murphy",
|
||||
"cook", "rogers", "gutierrez", "ortiz", "morgan", "cooper", "peterson", "bailey",
|
||||
"reed", "kelly", "howard", "ramos", "kim", "cox", "ward", "richardson",
|
||||
"watson", "brooks", "chavez", "wood", "james", "bennett", "gray", "mendoza",
|
||||
"ruiz", "hughes", "price", "alvarez", "castillo", "sanders", "patel", "myers",
|
||||
"long", "ross", "foster", "jimenez",
|
||||
)
|
||||
_NAME_SEPARATORS = ("", ".", "_")
|
||||
|
||||
|
||||
def generate_username(length=10):
|
||||
chars = string.ascii_lowercase + string.digits
|
||||
return "".join(secrets.choice(chars) for _ in range(length))
|
||||
"""生成更像正常英文用户的邮箱名:姓名/词根 + 数字结尾。
|
||||
|
||||
length 仅作兼容参数(旧调用传 10),实际长度由名字与数字后缀决定,约 8–18。
|
||||
"""
|
||||
first = secrets.choice(_FIRST_NAMES)
|
||||
last = secrets.choice(_LAST_NAMES)
|
||||
sep = secrets.choice(_NAME_SEPARATORS)
|
||||
# 数字后缀:2–4 位更像真实用户(生日年份、学号尾号等)
|
||||
digit_len = secrets.choice((2, 2, 3, 3, 3, 4))
|
||||
if digit_len == 2:
|
||||
digits = f"{secrets.randbelow(90) + 10}" # 10-99
|
||||
elif digit_len == 3:
|
||||
digits = f"{secrets.randbelow(900) + 100}" # 100-999
|
||||
else:
|
||||
# 常见 19xx / 20xx 年份感,或纯 4 位
|
||||
if secrets.randbelow(100) < 45:
|
||||
year = secrets.choice((19, 20))
|
||||
yy = secrets.randbelow(26) if year == 20 else secrets.randbelow(90) + 10
|
||||
digits = f"{year}{yy:02d}"
|
||||
else:
|
||||
digits = f"{secrets.randbelow(9000) + 1000}"
|
||||
|
||||
style = secrets.randbelow(100)
|
||||
if style < 40:
|
||||
# firstlast + digits e.g. jameswilson87
|
||||
base = f"{first}{last}"
|
||||
elif style < 65:
|
||||
# first.sep.last + digits e.g. james.wilson87 / james_wilson42
|
||||
base = f"{first}{sep}{last}" if sep else f"{first}{last}"
|
||||
elif style < 80:
|
||||
# first + digits e.g. james87
|
||||
base = first
|
||||
elif style < 92:
|
||||
# first 首字母 + last + digits e.g. jwilson87
|
||||
base = f"{first[0]}{last}"
|
||||
else:
|
||||
# last + first 首字母 + digits e.g. wilsonj87
|
||||
base = f"{last}{first[0]}"
|
||||
|
||||
local = f"{base}{digits}".lower()
|
||||
# 邮箱 local 只保留 [a-z0-9._],去掉连续分隔符
|
||||
local = re.sub(r"[^a-z0-9._]", "", local)
|
||||
local = re.sub(r"[._]{2,}", ".", local).strip("._")
|
||||
if len(local) < 5:
|
||||
local = f"{first}{digits}"
|
||||
# 过长时截断名字部分,保留数字后缀
|
||||
if len(local) > 24:
|
||||
local = f"{local[:-digit_len][: 24 - digit_len]}{digits}"
|
||||
return local or f"user{digits}"
|
||||
|
||||
|
||||
def pick_domain(api_key=None):
|
||||
|
||||
Reference in new issue
Block a user