Skip to content

Commit 69f260e

Browse files
authored
Merge pull request xtekky#475 from AlephZero255/fix_for_forefront.git
forefront fix
2 parents 4825a84 + 401d7d8 commit 69f260e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

gpt4free/forefront/__init__.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
from json import loads
2-
from xtempmail import Email
32
from re import findall
4-
from typing import Optional, Generator
5-
from faker import Faker
63
from time import time, sleep
4+
from typing import Generator, Optional
75
from uuid import uuid4
6+
7+
from mailgw_temporary_email import Email
88
from fake_useragent import UserAgent
99
from requests import post
1010
from tls_client import Session
11+
1112
from .typing import ForeFrontResponse
1213

1314

1415
class Account:
1516
@staticmethod
1617
def create(proxy: Optional[str] = None, logging: bool = False):
1718
proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
18-
faker = Faker()
19-
name = (faker.name().replace(' ', '_')).lower()
2019

2120
start = time()
2221

23-
mail_client = Email(name=name)
24-
mail_address = mail_client.email
22+
mail_client = Email()
23+
mail_client.register()
24+
mail_address = mail_client.address
2525

2626
client = Session(client_identifier='chrome110')
2727
client.proxies = proxies
@@ -34,6 +34,7 @@ def create(proxy: Optional[str] = None, logging: bool = False):
3434
'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
3535
data={'email_address': mail_address},
3636
)
37+
print(response.json()['response']['id'])
3738

3839
try:
3940
trace_token = response.json()['response']['id']
@@ -55,17 +56,21 @@ def create(proxy: Optional[str] = None, logging: bool = False):
5556

5657
if 'sign_up_attempt' not in response.text:
5758
return 'Failed to create account!'
58-
verification_url = None
59-
new_message = mail_client.get_new_message(5)
60-
for msg in new_message:
61-
verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', msg.text)[0]
59+
60+
while True:
61+
sleep(5)
62+
message_id = mail_client.message_list()[0]['id']
63+
message = mail_client.message(message_id)
64+
65+
new_message: Message = message
66+
verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message["text"])[0]
67+
6268
if verification_url:
6369
break
64-
65-
if verification_url is None or not verification_url:
66-
raise RuntimeError('Error while obtaining verfication URL!')
70+
6771
if logging:
6872
print(verification_url)
73+
6974
response = client.get(verification_url)
7075

7176
response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
@@ -188,4 +193,3 @@ def create(
188193
raise Exception('Unable to get the response, Please try again')
189194

190195
return final_response
191-

0 commit comments

Comments
 (0)