From d136c19f422b155143df19c7123119d497a0fb33 Mon Sep 17 00:00:00 2001 From: st1vms <96783398+st1vms@users.noreply.github.com> Date: Sun, 29 Oct 2023 13:21:51 +0100 Subject: [PATCH] Fixed email domains --- onesecmail_api/onesecmail_api.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/onesecmail_api/onesecmail_api.py b/onesecmail_api/onesecmail_api.py index fd7439b..b5d61f6 100644 --- a/onesecmail_api/onesecmail_api.py +++ b/onesecmail_api/onesecmail_api.py @@ -37,8 +37,6 @@ class MailMessage: html_body: str -__DOMAIN = "txcct.com" - __BASE_URL = "https://www.1secmail.com/api/v1/" @@ -48,15 +46,20 @@ def get_domain_list() -> list[str]: return http_get(__BASE_URL + endpoint, timeout=2).json() -def gen_random_emails(count: int = 1) -> list[str]: - """Generate random emails""" +def gen_random_emails(count: int = 1, domain: str = None) -> list[str]: + """Generate random emails, use `count` argument to change number of emails generated. + + Use `domain` argument to override generated email domain""" + if count <= 0: return ValueError("'count' must be positive") endpoint = f"?action=genRandomMailbox&count={count}" res = http_get(__BASE_URL + endpoint, timeout=2).json() if not res: return [] - return list(map(lambda e: e.split("@", maxsplit=1)[0] + f"@{__DOMAIN}", res)) + if not domain: + return res + return list(map(lambda e: e.split("@", maxsplit=1)[0] + f"@{domain}", res)) def fetch_mailbox(email: str) -> list[MailBoxMessage] | None: