forked from dfrnoch/nitro-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
107 lines (96 loc) · 3.65 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from time import localtime, strftime, sleep
from colorama import Fore
import requests
import random
import string
import os
class SapphireGen:
def __init__(this, code_type: str, prox=None, codes=None):
this.type = code_type
this.codes = codes
this.proxies = prox
this.session = requests.Session()
this.prox_api = (
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt"
)
def __proxies__(this):
req = this.session.get(this.prox_api).text
if req != None:
open("./data/proxies.txt", "a+").truncate(0)
for proxy in req.split("\n"):
proxy = proxy.strip()
proxy = f"https://{proxy}"
open("./data/proxies.txt", "a").write(f"{proxy}\n")
def generate(this, scrape=None):
if scrape == "True":
this.__proxies__()
else:
pass
os.system("clear")
for _ in range(int(this.codes)):
try:
if this.proxies == "True":
prox = {
"http": random.choice(
open("./data/proxies.txt", "r").read().splitlines()
)
}
else:
prox = None
if this.type == "boost":
code = "".join(
[
random.choice(string.ascii_letters + string.digits)
for i in range(24)
]
)
else:
code = "".join(
[
random.choice(string.ascii_letters + string.digits)
for i in range(16)
]
)
req = this.session.get(
f"https://discordapp.com/api/entitlements/gift-codes/{code}",
proxies=prox,
timeout=10,
).status_code
if req == 200:
print(
f"{Fore.GREEN}[{strftime('%H:%M', localtime())}] discord.gift/{code} | valid"
)
open("./data/valid.txt", "a").write(f"{code}\n")
if req == 404:
print(
f"{Fore.RED}[{strftime('%H:%M', localtime())}] discord.gift/{code} | invalid"
)
if req == 429:
print(
f"{Fore.YELLOW}[{strftime('%H:%M', localtime())}] discord.gift/{code} | ratelimited"
)
except Exception as e:
print(f"{Fore.RED}[{strftime('%H:%M', localtime())}] {e}")
print(
f"{Fore.LIGHTMAGENTA_EX}[{strftime('%H:%M', localtime())}] Successfully checked {this.codes} codes."
)
sleep(1.5)
os.system("clear")
if __name__ == "__main__":
while True:
code_type = input(
f"{Fore.LIGHTMAGENTA_EX}[{strftime('%H:%M', localtime())}] Code Type (boost, classic): "
)
prox = input(
f"{Fore.LIGHTMAGENTA_EX}[{strftime('%H:%M', localtime())}] Proxies (True, False): "
)
if prox == "True":
scrape_proxy = input(
f"{Fore.LIGHTMAGENTA_EX}[{strftime('%H:%M', localtime())}] Scrape proxies (True, False): "
)
else:
scrape_proxy = False
codes = input(
f"{Fore.LIGHTMAGENTA_EX}[{strftime('%H:%M', localtime())}] Number of codes: "
)
SapphireGen(code_type, prox, codes).generate(scrape=scrape_proxy)