XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

forefront_fix

401d7d89
unknown <alephzero255@gmail.com>
提交于

代码差异

1 个文件 +19 -15
Modified gpt4free/forefront/__init__.py +19 -15
@@ -1,13 +1,14 @@
1 1 from json import loads
2 from xtempmail import Email
3 2 from re import findall
4 from typing import Optional, Generator
5 from faker import Faker
6 3 from time import time, sleep
4 from typing import Generator, Optional
7 5 from uuid import uuid4
6
7 from mailgw_temporary_email import Email
8 8 from fake_useragent import UserAgent
9 9 from requests import post
10 10 from tls_client import Session
11
11 12 from .typing import ForeFrontResponse
12 13
13 14
@@ -15,13 +16,12 @@ class Account:
15 16 @staticmethod
16 17 def create(proxy: Optional[str] = None, logging: bool = False):
17 18 proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False
18 faker = Faker()
19 name = (faker.name().replace(' ', '_')).lower()
20 19
21 20 start = time()
22 21
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
25 25
26 26 client = Session(client_identifier='chrome110')
27 27 client.proxies = proxies
@@ -34,6 +34,7 @@ class Account:
34 34 'https://clerk.forefront.ai/v1/client/sign_ups?_clerk_js_version=4.38.4',
35 35 data={'email_address': mail_address},
36 36 )
37 print(response.json()['response']['id'])
37 38
38 39 try:
39 40 trace_token = response.json()['response']['id']
@@ -55,17 +56,21 @@ class Account:
55 56
56 57 if 'sign_up_attempt' not in response.text:
57 58 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
62 68 if verification_url:
63 69 break
64
65 if verification_url is None or not verification_url:
66 raise RuntimeError('Error while obtaining verfication URL!')
70
67 71 if logging:
68 72 print(verification_url)
73
69 74 response = client.get(verification_url)
70 75
71 76 response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4')
@@ -188,4 +193,3 @@ class Completion:
188 193 raise Exception('Unable to get the response, Please try again')
189 194
190 195 return final_response
191