-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support new service https://tempmail.lol/
- Loading branch information
Denis Pitkov
committed
Feb 26, 2023
1 parent
560ee44
commit 17d0132
Showing
19 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .inboxkitten import InboxKitten | ||
from .tempmailplus import TempMailPlus, TempMailPlusDomains | ||
from .gmailnator import GmailNator | ||
from .tempmaillol import TempMailLol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import re | ||
import requests | ||
from ..mail import letter | ||
from datetime import datetime | ||
|
||
|
||
class Letter(letter.Letter): | ||
def __init__(self, url, headers, timestamp, proxies): | ||
super().__init__(headers['to'], *re.findall(r'(.*) <(.*)>', headers['from'])[0], headers['subject'], datetime.fromtimestamp(timestamp), proxies) | ||
def __init__(self, url, headers, timestamp, session): | ||
if '<' in headers['from']: | ||
name, from_email = re.findall(r'(.*) <(.*)>', headers['from'])[0] | ||
else: | ||
name = from_email = headers['from'] | ||
super().__init__(headers['to'], name, from_email, headers['subject'], datetime.fromtimestamp(timestamp)) | ||
self._letter_id = '-'.join(re.findall(r'https://(.*)\.api\.mailgun\.net/v3/domains/inboxkitten\.com/messages/(.*)', url)[0]) | ||
self._s = session | ||
|
||
@property | ||
def letter(self): | ||
if self._letter: | ||
return self._letter | ||
r = requests.get(f'https://inboxkitten.com/api/v1/mail/getHtml?mailKey={self._letter_id}', proxies=self._proxies) | ||
r = self._s.get(f'https://inboxkitten.com/api/v1/mail/getHtml?mailKey={self._letter_id}') | ||
if r.status_code == 200: | ||
self._letter = re.sub(r'<script[^>]*>([\s\S]*?)</script>', '', r.text) | ||
return self._letter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
account_generator_helper/temp_mail/tempmaillol/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from .letter import Letter | ||
from ..exceptions import NotSetEmail, ProblemWithGetEmail | ||
from ..mail import Mail | ||
|
||
|
||
class TempMailLol(Mail): | ||
""" | ||
Class for work with https://tempmail.lol/ | ||
""" | ||
|
||
def __init__(self, proxy=None): | ||
super().__init__(proxy) | ||
self.__token = None | ||
|
||
def get_email(self, community_addresses: bool = True): | ||
""" | ||
Get random email address from https://tempmail.lol/ | ||
:community_addresses: Community addresses use domains people have given to the website | ||
""" | ||
r = self._s.get('https://api.tempmail.lol/generate/rush' if community_addresses else 'https://api.tempmail.lol/generate') | ||
if not r.ok: | ||
raise ProblemWithGetEmail() | ||
self.__token = r.json()['token'] | ||
return self.set_email(r.json()['address']) | ||
|
||
def get_inbox(self): | ||
if not self._email or not self.__token: | ||
raise NotSetEmail() | ||
|
||
r = self._s.get(f'https://api.tempmail.lol/auth/{self.__token}') | ||
if r.status_code == 200: | ||
return [Letter(_letter['to'], _letter['from'], _letter['subject'], _letter['date'], _letter['body']) for _letter in r.json().get('email', [])] | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from ..mail import letter | ||
from datetime import datetime | ||
|
||
|
||
class Letter(letter.Letter): | ||
def __init__(self, to, from_email, subject, timestamp, body): | ||
super().__init__(to, from_email, from_email, subject, datetime.fromtimestamp(timestamp / 1000)) | ||
self.__body = body | ||
|
||
@property | ||
def letter(self): | ||
return self.__body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import requests | ||
from ..mail import letter | ||
from datetime import datetime | ||
|
||
|
||
class Letter(letter.Letter): | ||
def __init__(self, to, mail, proxies): | ||
super().__init__(to, mail['from_name'], mail['from_mail'], mail['subject'], datetime.strptime(mail['time'], '%Y-%m-%d %H:%M:%S'), proxies) | ||
def __init__(self, to, mail, session): | ||
super().__init__(to, mail['from_name'], mail['from_mail'], mail['subject'], datetime.strptime(mail['time'], '%Y-%m-%d %H:%M:%S')) | ||
self._letter_id = mail['mail_id'] | ||
self._s = session | ||
|
||
@property | ||
def letter(self): | ||
if self._letter: | ||
return self._letter | ||
r = requests.get(f'https://tempmail.plus/api/mails/{self._letter_id}?email={self._email}', proxies=self._proxies) | ||
r = self._s.get(f'https://tempmail.plus/api/mails/{self._letter_id}?email={self._email}') | ||
if r.status_code == 200: | ||
self._letter = r.json()['text'] | ||
return self._letter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from account_generator_helper import TempMailLol | ||
|
||
|
||
mail = TempMailLol() | ||
print('Mail :', mail.get_email()) # Mail : [email protected] | ||
|
||
|
||
for _letter in mail.get_inbox(): | ||
print('Letter :', _letter) # Letter : (Letter ..) | ||
print('Letter content :', _letter.letter) # Letter content : ... | ||
|
||
|
||
@mail.letter_handler() | ||
def new_mail(letter): | ||
print('New mail :', letter) | ||
|
||
|
||
@mail.letter_handler(from_email='[email protected]') | ||
def test_from(letter): | ||
print('Test from :', letter) | ||
|
||
|
||
@mail.letter_handler(re_subject='.* test .*') | ||
def test_re_subject(letter): | ||
print('Test re subject :', letter) | ||
|
||
|
||
@mail.letter_handler(from_email='[email protected]', subject='Test letter') | ||
def test_handler(letter): | ||
print('Test handler :', letter) | ||
|
||
|
||
mail.poling() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
certifi==2021.10.8 | ||
certifi==2022.12.7 | ||
charset-normalizer==2.0.12 | ||
idna==3.3 | ||
requests==2.27.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters