-
Notifications
You must be signed in to change notification settings - Fork 58
Sourcery Starbot ⭐ refactored Vinyzu/DiscordGenerator #102
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,13 +59,13 @@ def log_output(self): | |
| output = "" | ||
| for item in self.output_format.split(":"): | ||
| if "token" in item and self.token: | ||
| output += self.token + ":" | ||
| output += f"{self.token}:" | ||
| if "email" in item and self.email: | ||
| output += self.email + ":" | ||
| output += f"{self.email}:" | ||
| if "pass" in item: | ||
| output += self.browser.faker.password + ":" | ||
| output += f"{self.browser.faker.password}:" | ||
| if "proxy" in item and self.browser.proxy: | ||
| output += self.browser.proxy + ":" | ||
| output += f"{self.browser.proxy}:" | ||
|
|
||
| # Remove last : | ||
| output = output[:-1] | ||
|
|
@@ -102,7 +102,6 @@ async def generate_unclaimed(self): | |
| await self.page.click("[class *= 'checkbox']", timeout=10000) | ||
| except Exception as e: | ||
| self.logger.debug("No TOS Checkbox was detected") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
| await self.page.click('[class *= "gtm-click-class-register-button"]') | ||
|
|
||
| # Solving Captcha | ||
|
|
@@ -174,7 +173,6 @@ async def generate_unclaimed(self): | |
|
|
||
| await self.close() | ||
|
|
||
| # Catch Exceptions and save output anyways | ||
| except: | ||
| self.logger.error(f"Catched Exception, trying to save Token anyways... \n Error: \n {traceback.format_exc()}") | ||
| if self.output: | ||
|
|
@@ -213,7 +211,6 @@ async def generate_token(self): | |
| await tos_box.click() | ||
| except Exception as e: | ||
| self.logger.debug("No TOS Checkbox was detected") | ||
| pass | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ): |
||
| await self.page.click('[type="submit"]') | ||
|
|
||
| await self.page.solve_hcaptcha() | ||
|
|
@@ -269,7 +266,6 @@ async def generate_token(self): | |
|
|
||
| await self.close() | ||
|
|
||
| # Catch Exceptions and save output anyways | ||
| except: | ||
| self.logger.error(f"Catched Exception, trying to save Token anyways... \n Error: \n{traceback.format_exc()}") | ||
| if self.output: | ||
|
|
@@ -329,7 +325,7 @@ async def main(): | |
| if email not in ("1", "2"): | ||
| raise ValueError("Invalid Mode provided") | ||
| else: | ||
| email = True if email == "1" else False | ||
| email = email == "1" | ||
|
Comment on lines
-332
to
+328
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| email = False | ||
|
|
||
|
|
@@ -339,7 +335,7 @@ async def main(): | |
| if humanize not in ("1", "2"): | ||
| raise ValueError("Invalid Mode provided") | ||
| else: | ||
| humanize = True if humanize == "1" else False | ||
| humanize = humanize == "1" | ||
| else: | ||
| humanize = False | ||
|
|
||
|
|
@@ -349,9 +345,11 @@ async def main(): | |
| except: | ||
| raise ValueError("Invalid ThreadAmount provided") | ||
|
|
||
| proxy_file = input("[Drag&Drop] - [Proxy File]\n" + | ||
| "<?> Or Leave empty for Proxyless Mode\n" + "</> ").replace('"', "") | ||
| if proxy_file: | ||
| if proxy_file := input( | ||
| "[Drag&Drop] - [Proxy File]\n" | ||
| + "<?> Or Leave empty for Proxyless Mode\n" | ||
| + "</> " | ||
| ).replace('"', ""): | ||
| if not os.path.isfile(proxy_file): | ||
| raise ValueError("Provided ProxyPath isnt a file!") | ||
| proxies = open(proxy_file, 'r').readlines() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ async def get_headers(self, payload): | |
| super_props = {"os": platform.system(), "browser":"Firefox", "release_channel":"stable", "client_version": self.browser.browser.version, "os_version": str(platform.version()), "os_arch": "x64" if platform.machine().endswith('64') else "x86", "system_locale": self.browser.faker.locale, "client_build_number": DISCORD_BUILD_NUM, "client_event_source": None} | ||
| super_props = base64.b64encode(str(super_props).encode()).decode() | ||
|
|
||
| headers = { | ||
| return { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| "accept": "*/*", | ||
| "accept-encoding": "gzip, deflate, br", | ||
| "accept-language": "de,de-DE;q=0.9", | ||
|
|
@@ -42,7 +42,6 @@ async def get_headers(self, payload): | |
| "x-discord-locale": "en", | ||
| "x-super-properties": super_props, | ||
| } | ||
| return headers | ||
|
|
||
| async def humanize_token(self): | ||
| await self.page.goto("https://discord.com/channels/@me") | ||
|
|
@@ -122,7 +121,7 @@ async def humanize_token(self): | |
| return | ||
|
|
||
| self.log_output() | ||
| self.logger.info(f"Set Bio and ProfilePic!") | ||
| self.logger.info("Set Bio and ProfilePic!") | ||
|
Comment on lines
-125
to
+124
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| async def join_server(self): | ||
| await self.page.goto("https://discord.com/channels/@me") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,43 +16,41 @@ class TempMail: | |
| The content of the request is a json string and is returned as a string object | ||
| """ | ||
|
|
||
| def makeHTTPRequest(endpoint): | ||
| def makeHTTPRequest(self): | ||
| headers = { | ||
| "User-Agent": "TempMailPythonAPI/1.0", | ||
| "Accept": "application/json" | ||
| } | ||
| try: | ||
| connection = httpx.get(BASE_URL + endpoint, headers=headers) | ||
| connection = httpx.get(BASE_URL + self, headers=headers) | ||
| if connection.status_code >= 400: | ||
| raise Exception("HTTP Error: " + str(connection.status_code)) | ||
| raise Exception(f"HTTP Error: {str(connection.status_code)}") | ||
| except Exception as e: | ||
| print(e) | ||
| return None | ||
|
|
||
| response = connection.text | ||
|
|
||
| return response | ||
| return connection.text | ||
|
Comment on lines
-19
to
+32
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| """ | ||
| GenerateInbox will generate an inbox with an address and a token | ||
| and returns an Inbox object | ||
| > rush = False will generate a normal inbox with no rush (https://tempmail.lol/news/2022/08/03/introducing-rush-mode-for-tempmail/) | ||
| """ | ||
| def generateInbox(rush=False): | ||
| def generateInbox(self): | ||
| try: | ||
| random_domain = random.choice(DOMAINS) | ||
| s = TempMail.makeHTTPRequest(f"/generate/{random_domain}") | ||
| except: | ||
| print("Website responded with: " + s) | ||
| print(f"Website responded with: {s}") | ||
|
Comment on lines
-41
to
+44
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| data = json.loads(s) | ||
| return Inbox(data["address"], data["token"]) | ||
|
|
||
| """ | ||
| getEmail gets the emails from an inbox object | ||
| and returns a list of Email objects | ||
| """ | ||
| def getEmails(inbox): | ||
| s = TempMail.makeHTTPRequest("/auth/" + inbox.token) | ||
| def getEmails(self): | ||
| s = TempMail.makeHTTPRequest(f"/auth/{self.token}") | ||
|
Comment on lines
-54
to
+53
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| data = json.loads(s) | ||
|
|
||
| # Raise an exception if the token is invalid | ||
|
|
@@ -62,14 +60,20 @@ def getEmails(inbox): | |
|
|
||
| # if no emails are found, return an empty list | ||
| # else return a list of email | ||
| if data["email"] == None: | ||
| if data["email"] is None: | ||
| return ["None"] | ||
| else: | ||
| emails = [] | ||
| for email in data["email"]: | ||
| emails.append(Email( | ||
| email["from"], email["to"], email["subject"], email["body"], email["html"], email["date"])) | ||
| return emails | ||
| return [ | ||
| Email( | ||
| email["from"], | ||
| email["to"], | ||
| email["subject"], | ||
| email["body"], | ||
| email["html"], | ||
| email["date"], | ||
| ) | ||
| for email in data["email"] | ||
| ] | ||
|
|
||
| class Email: | ||
| def __init__(self, sender, recipient, subject, body, html, date): | ||
|
|
@@ -106,8 +110,7 @@ def date(self): | |
| return self._date | ||
|
|
||
| def __repr__(self): | ||
| return ("Email (sender={}, recipient={}, subject={}, body={}, html={}, date={} )" | ||
| .format(self.sender, self.recipient, self.subject, self.body, self.html, self.date)) | ||
| return f"Email (sender={self.sender}, recipient={self.recipient}, subject={self.subject}, body={self.body}, html={self.html}, date={self.date} )" | ||
|
Comment on lines
-109
to
+113
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| class Inbox: | ||
| def __init__(self, address, token): | ||
|
|
@@ -124,5 +127,4 @@ def token(self): | |
| return self._token | ||
|
|
||
| def __repr__(self): | ||
| return ("Inbox (address={}, token={} )" | ||
| .format(self.address, self.token)) | ||
| return f"Inbox (address={self.address}, token={self.token} )" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
Generator.log_outputrefactored with the following changes:use-fstring-for-concatenation)