0.0.4
This commit is contained in:
@@ -225,6 +225,18 @@ class DomainManager:
|
||||
return self._domains[1] # 返回qianyouduo.com作为默认
|
||||
return domain
|
||||
|
||||
def get_random_creatable_domain(self) -> str:
|
||||
"""
|
||||
随机获取一个可创建邮箱的域名(排除 gmail.com)
|
||||
|
||||
返回值:
|
||||
str: 随机选取的域名
|
||||
"""
|
||||
creatable = self.get_creatable_domains()
|
||||
if not creatable:
|
||||
raise ValueError("无可用域名用于创建邮箱")
|
||||
return random.choice(creatable)
|
||||
|
||||
|
||||
# 邮箱模块
|
||||
class Mail:
|
||||
@@ -298,12 +310,12 @@ class Mail:
|
||||
|
||||
# 创建随机邮箱
|
||||
@retry(max_retries=3, delay=1.0, backoff=1.0)
|
||||
def email_create_random(self, count: int = 8, pwd: str = 'Zpaily88', mail_type: int = 1) -> str:
|
||||
def email_create_random(self, count: int = 8, pwd: str = 'Zpaily88', mail_type: int | None = None) -> str:
|
||||
"""
|
||||
创建邮箱
|
||||
创建随机邮箱(随机域名,排除 gmail.com)
|
||||
:param count: 邮箱长度(默认8位)
|
||||
:param pwd: 邮箱密码(默认Zpaily88)
|
||||
:param mail_type: 邮箱类型(1表示qianyouduo.com 2表示rxybb.com 3表示cqrxy.vip 4表示0n.lv 默认1)
|
||||
:param mail_type: 指定邮箱类型编号;为 None 时随机选择可创建域名
|
||||
:return: 邮箱账号
|
||||
"""
|
||||
headers = {
|
||||
@@ -327,8 +339,12 @@ class Mail:
|
||||
url = "https://mail.qianyouduo.com/admin/api/v1/boxes"
|
||||
name = ''.join(random.choices(string.ascii_letters + string.digits, k=count)).lower()
|
||||
|
||||
# 使用域名管理器获取可创建的域名(排除gmail.com)
|
||||
mail_end = self.domain_manager.get_creatable_domain_by_type(mail_type)
|
||||
# 随机选择可创建域名(排除 gmail.com);如指定类型则按类型选择
|
||||
mail_end = (
|
||||
self.domain_manager.get_creatable_domain_by_type(mail_type)
|
||||
if mail_type is not None
|
||||
else self.domain_manager.get_random_creatable_domain()
|
||||
)
|
||||
data = {
|
||||
"name": name,
|
||||
"email": f"{name}@{mail_end}",
|
||||
@@ -343,12 +359,12 @@ class Mail:
|
||||
|
||||
# 异步创建随机邮箱
|
||||
@async_retry(max_retries=3, delay=1.0, backoff=1.0)
|
||||
async def _email_create_random(self, count: int = 8, pwd: str = 'Zpaily88', mail_type: int = 1) -> str:
|
||||
async def _email_create_random(self, count: int = 8, pwd: str = 'Zpaily88', mail_type: int | None = None) -> str:
|
||||
"""
|
||||
创建邮箱
|
||||
创建随机邮箱(随机域名,排除 gmail.com)
|
||||
:param count: 邮箱长度(默认8位)
|
||||
:param pwd: 邮箱密码(默认Zpaily88)
|
||||
:param mail_type: 邮箱类型(1表示qianyouduo.com 2表示rxybb.com 3表示cqrxy.vip 4表示0n.lv 默认1)
|
||||
:param mail_type: 指定邮箱类型编号;为 None 时随机选择可创建域名
|
||||
:return:邮箱账号
|
||||
"""
|
||||
headers = {
|
||||
@@ -372,8 +388,12 @@ class Mail:
|
||||
url = "https://mail.qianyouduo.com/admin/api/v1/boxes"
|
||||
name = ''.join(random.choices(string.ascii_letters + string.digits, k=count)).lower()
|
||||
|
||||
# 使用域名管理器获取可创建的域名(排除gmail.com)
|
||||
mail_end = self.domain_manager.get_creatable_domain_by_type(mail_type)
|
||||
# 随机选择可创建域名(排除 gmail.com);如指定类型则按类型选择
|
||||
mail_end = (
|
||||
self.domain_manager.get_creatable_domain_by_type(mail_type)
|
||||
if mail_type is not None
|
||||
else self.domain_manager.get_random_creatable_domain()
|
||||
)
|
||||
data = {
|
||||
"name": name,
|
||||
"email": f"{name}@{mail_end}",
|
||||
@@ -815,21 +835,21 @@ async def main():
|
||||
使用示例:展示新的域名管理系统的使用方法
|
||||
"""
|
||||
mail = Mail()
|
||||
mai = '0gz3vvd4@'+'qydgs.asia'
|
||||
res = mail.email_create(mai)
|
||||
print(f"创建的邮箱: {res}")
|
||||
# random_email = mail.email_create_random(count=8, mail_type=1)
|
||||
# print(f"创建的随机邮箱: {random_email}")
|
||||
# mai = '0gz3vvd4@'+'qydgs.asia'
|
||||
# res = mail.email_create(mai)
|
||||
# print(f"创建的邮箱: {res}")
|
||||
random_email = mail.email_create_random()
|
||||
print(f"创建的随机邮箱: {random_email}")
|
||||
|
||||
# 读取邮件
|
||||
# res = mail.email_read('0gz3vvd4@qydgs.asia', '@', 1, is_del=True)
|
||||
# print(f'读取的邮件: {res}')
|
||||
|
||||
# 删除邮箱
|
||||
res = mail.email_delete(mai)
|
||||
res = mail.email_delete(random_email)
|
||||
print(f"删除的邮箱: {res}")
|
||||
|
||||
mail_ = Mail()
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# asyncio.run(main())
|
||||
# asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user