mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-05 00:01:00 +00:00
Fixed entire usesless (huge update)
This commit is contained in:
parent
86142cddd1
commit
7e1a0d1f2e
@ -6,9 +6,11 @@ ai.usesless.com
|
|||||||
<p>this will create account.txt that contains mail and token</p>
|
<p>this will create account.txt that contains mail and token</p>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import usesless
|
from gpt4free import usesless
|
||||||
|
|
||||||
usesless.Account.create(logging=True)
|
|
||||||
|
token = usesless.Account.create(logging=True)
|
||||||
|
print(token)
|
||||||
```
|
```
|
||||||
|
|
||||||
### completion
|
### completion
|
||||||
|
@ -1,20 +1,32 @@
|
|||||||
|
import string
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import fake_useragent
|
import fake_useragent
|
||||||
import names
|
import random
|
||||||
|
|
||||||
from mailgw_temporary_email import Email
|
|
||||||
from password_generator import PasswordGenerator
|
from password_generator import PasswordGenerator
|
||||||
|
|
||||||
|
from utils import create_email, check_email
|
||||||
|
|
||||||
|
|
||||||
class Account:
|
class Account:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(logging: bool = False):
|
def create(logging: bool = False):
|
||||||
mail_client = Email()
|
is_custom_domain = input(
|
||||||
mail_client.register()
|
"Do you want to use your custom domain name for temporary email? [Y/n]: "
|
||||||
mail_address = mail_client.address
|
).upper()
|
||||||
|
|
||||||
|
if is_custom_domain == "Y":
|
||||||
|
mail_address = create_email(custom_domain=True, logging=logging)
|
||||||
|
elif is_custom_domain == "N":
|
||||||
|
mail_address = create_email(custom_domain=False, logging=logging)
|
||||||
|
else:
|
||||||
|
print("Please, enter either Y or N")
|
||||||
|
return
|
||||||
|
|
||||||
|
name = string.ascii_lowercase + string.digits
|
||||||
|
username = "".join(random.choice(name) for i in range(20))
|
||||||
|
|
||||||
pwo = PasswordGenerator()
|
pwo = PasswordGenerator()
|
||||||
pwo.minlen = 8
|
pwo.minlen = 8
|
||||||
@ -22,12 +34,9 @@ class Account:
|
|||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
|
||||||
if logging:
|
|
||||||
print(f"email: {mail_address}")
|
|
||||||
|
|
||||||
register_url = "https://ai.usesless.com/api/cms/auth/local/register"
|
register_url = "https://ai.usesless.com/api/cms/auth/local/register"
|
||||||
register_json = {
|
register_json = {
|
||||||
"username": names.get_first_name(),
|
"username": username,
|
||||||
"password": password,
|
"password": password,
|
||||||
"email": mail_address,
|
"email": mail_address,
|
||||||
}
|
}
|
||||||
@ -44,23 +53,28 @@ class Account:
|
|||||||
register = session.post(register_url, json=register_json, headers=headers)
|
register = session.post(register_url, json=register_json, headers=headers)
|
||||||
if logging:
|
if logging:
|
||||||
if register.status_code == 200:
|
if register.status_code == 200:
|
||||||
print("register success")
|
print("Registered successfully")
|
||||||
else:
|
else:
|
||||||
print("there's a problem with account creation, try again")
|
print(register.status_code)
|
||||||
|
print(register.json())
|
||||||
|
print("There was a problem with account registration, try again")
|
||||||
|
|
||||||
if register.status_code != 200:
|
if register.status_code != 200:
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
messages = mail_client.message_list()
|
messages = check_email(mail=mail_address, logging=logging)
|
||||||
|
|
||||||
|
# Check if method `message_list()` didn't return None or empty list.
|
||||||
if not messages or len(messages) == 0:
|
if not messages or len(messages) == 0:
|
||||||
|
# If it returned None or empty list sleep for 5 seconds to wait for new message.
|
||||||
continue
|
continue
|
||||||
message_id = messages[0]["id"]
|
|
||||||
message = mail_client.message(message_id)
|
message_text = messages[0]["content"]
|
||||||
verification_url = re.findall(
|
verification_url = re.findall(
|
||||||
r"http:\/\/ai\.usesless\.com\/api\/cms\/auth\/email-confirmation\?confirmation=\w.+\w\w",
|
r"http:\/\/ai\.usesless\.com\/api\/cms\/auth\/email-confirmation\?confirmation=\w.+\w\w",
|
||||||
message["text"],
|
message_text,
|
||||||
)[0]
|
)[0]
|
||||||
if verification_url:
|
if verification_url:
|
||||||
break
|
break
|
||||||
@ -70,13 +84,17 @@ class Account:
|
|||||||
login_request = session.post(
|
login_request = session.post(
|
||||||
url="https://ai.usesless.com/api/cms/auth/local", json=login_json
|
url="https://ai.usesless.com/api/cms/auth/local", json=login_json
|
||||||
)
|
)
|
||||||
token = login_request.json()["jwt"]
|
|
||||||
if logging:
|
|
||||||
print(f"token: {token}")
|
|
||||||
|
|
||||||
with open("accounts.txt", "w") as f:
|
token = login_request.json()["jwt"]
|
||||||
f.write(f"{mail_address}\n")
|
if logging and token:
|
||||||
f.write(f"{token}")
|
print(f"Token: {token}")
|
||||||
|
|
||||||
|
with open("account.json", "w") as file:
|
||||||
|
json.dump({"email": mail_address, "token": token}, file)
|
||||||
|
if logging:
|
||||||
|
print(
|
||||||
|
"\nNew account credentials has been successfully saved in 'account.json' file"
|
||||||
|
)
|
||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
1
gpt4free/usesless/account.json
Normal file
1
gpt4free/usesless/account.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"email": "enganese-test-email@1secmail.net", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Mzg1MDEsImlhdCI6MTY4NTExMDgzOSwiZXhwIjoxNzE2NjY4NDM5fQ.jfEQOFWYQP2Xx4U-toorPg3nh31mxl3L0D2hRROmjZA"}
|
10
gpt4free/usesless/test.py
Normal file
10
gpt4free/usesless/test.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Fix by @enganese
|
||||||
|
# Import Account class from __init__.py file
|
||||||
|
from gpt4free import usesless
|
||||||
|
|
||||||
|
# Create Account and enable logging to see all the log messages (it's very interesting, try it!)
|
||||||
|
# New account credentials will be automatically saved in account.json file in such template: {"email": "username@1secmail.com", "token": "token here"}
|
||||||
|
token = usesless.Account.create(logging=True)
|
||||||
|
|
||||||
|
# Print the new token
|
||||||
|
print(token)
|
140
gpt4free/usesless/utils/__init__.py
Normal file
140
gpt4free/usesless/utils/__init__.py
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
import pyperclip
|
||||||
|
import requests
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def check_email(mail, logging: bool = False):
|
||||||
|
username = mail.split("@")[0]
|
||||||
|
domain = mail.split("@")[1]
|
||||||
|
reqLink = f"https://www.1secmail.com/api/v1/?action=getMessages&login={username}&domain={domain}"
|
||||||
|
req = requests.get(reqLink)
|
||||||
|
req.encoding = req.apparent_encoding
|
||||||
|
req = req.json()
|
||||||
|
|
||||||
|
length = len(req)
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
os.system("cls" if os.name == "nt" else "clear")
|
||||||
|
time.sleep(1)
|
||||||
|
print("Your temporary mail:", mail)
|
||||||
|
|
||||||
|
if logging and length == 0:
|
||||||
|
print(
|
||||||
|
"Mailbox is empty. Hold tight. Mailbox is refreshed automatically every 5 seconds.",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
messages = []
|
||||||
|
id_list = []
|
||||||
|
|
||||||
|
for i in req:
|
||||||
|
for k, v in i.items():
|
||||||
|
if k == "id":
|
||||||
|
id_list.append(v)
|
||||||
|
|
||||||
|
x = "mails" if length > 1 else "mail"
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
print(
|
||||||
|
f"Mailbox has {length} {x}. (Mailbox is refreshed automatically every 5 seconds.)"
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in id_list:
|
||||||
|
msgRead = f"https://www.1secmail.com/api/v1/?action=readMessage&login={username}&domain={domain}&id={i}"
|
||||||
|
req = requests.get(msgRead)
|
||||||
|
req.encoding = req.apparent_encoding
|
||||||
|
req = req.json()
|
||||||
|
|
||||||
|
for k, v in req.items():
|
||||||
|
if k == "from":
|
||||||
|
sender = v
|
||||||
|
if k == "subject":
|
||||||
|
subject = v
|
||||||
|
if k == "date":
|
||||||
|
date = v
|
||||||
|
if k == "textBody":
|
||||||
|
content = v
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
print(
|
||||||
|
"Sender:",
|
||||||
|
sender,
|
||||||
|
"\nTo:",
|
||||||
|
mail,
|
||||||
|
"\nSubject:",
|
||||||
|
subject,
|
||||||
|
"\nDate:",
|
||||||
|
date,
|
||||||
|
"\nContent:",
|
||||||
|
content,
|
||||||
|
"\n",
|
||||||
|
)
|
||||||
|
messages.append(
|
||||||
|
{
|
||||||
|
"sender": sender,
|
||||||
|
"to": mail,
|
||||||
|
"subject": subject,
|
||||||
|
"date": date,
|
||||||
|
"content": content,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
os.system("cls" if os.name == "nt" else "clear")
|
||||||
|
return messages
|
||||||
|
|
||||||
|
|
||||||
|
def create_email(custom_domain: bool = False, logging: bool = False):
|
||||||
|
domainList = ["1secmail.com", "1secmail.net", "1secmail.org"]
|
||||||
|
domain = random.choice(domainList)
|
||||||
|
try:
|
||||||
|
if custom_domain:
|
||||||
|
custom_domain = input(
|
||||||
|
"\nIf you enter 'my-test-email' as your domain name, mail address will look like this: 'my-test-email@1secmail.com'"
|
||||||
|
"\nEnter the name that you wish to use as your domain name: "
|
||||||
|
)
|
||||||
|
|
||||||
|
newMail = f"https://www.1secmail.com/api/v1/?login={custom_domain}&domain={domain}"
|
||||||
|
reqMail = requests.get(newMail)
|
||||||
|
reqMail.encoding = reqMail.apparent_encoding
|
||||||
|
|
||||||
|
username = re.search(r"login=(.*)&", newMail).group(1)
|
||||||
|
domain = re.search(r"domain=(.*)", newMail).group(1)
|
||||||
|
mail = f"{username}@{domain}"
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
print("\nYour temporary email was created successfully:", mail)
|
||||||
|
return mail
|
||||||
|
|
||||||
|
else:
|
||||||
|
name = string.ascii_lowercase + string.digits
|
||||||
|
random_username = "".join(random.choice(name) for i in range(10))
|
||||||
|
newMail = f"https://www.1secmail.com/api/v1/?login={random_username}&domain={domain}"
|
||||||
|
|
||||||
|
reqMail = requests.get(newMail)
|
||||||
|
reqMail.encoding = reqMail.apparent_encoding
|
||||||
|
|
||||||
|
username = re.search(r"login=(.*)&", newMail).group(1)
|
||||||
|
domain = re.search(r"domain=(.*)", newMail).group(1)
|
||||||
|
mail = f"{username}@{domain}"
|
||||||
|
|
||||||
|
if logging:
|
||||||
|
print("\nYour temporary email was created successfully:", mail)
|
||||||
|
return mail
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
requests.post(
|
||||||
|
"https://www.1secmail.com/mailbox",
|
||||||
|
data={
|
||||||
|
"action": "deleteMailbox",
|
||||||
|
"login": f"{username}",
|
||||||
|
"domain": f"{domain}",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if logging:
|
||||||
|
print("\nKeyboard Interrupt Detected! \nTemporary mail was disposed!")
|
||||||
|
os.system("cls" if os.name == "nt" else "clear")
|
Loading…
Reference in New Issue
Block a user