diff --git a/.gitignore b/.gitignore index 145c1b5..45b11a6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ private.py # other logs/tuxbot.log +utils/images/tmp/* # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/bot.py b/bot.py index 65ea046..f06583f 100755 --- a/bot.py +++ b/bot.py @@ -20,7 +20,7 @@ Je suis TuxBot, le bot qui vit de l'OpenSource ! ;) """ build = git.Repo(search_parent_directories=True).head.object.hexsha -version = (2, 1, 0) +version = (2, 0, 0) log = logging.getLogger(__name__) @@ -73,7 +73,7 @@ class TuxBot(commands.AutoShardedBot): self.fallbacks = Config('./configs/fallbacks.cfg') self.cluster = self.fallbacks.find('True', key='This', first=True) - self.version = Version(*version, pre_release='rc1', build=build) + self.version = Version(*version, pre_release='rc2', build=build) self.owner: discord.User = discord.User self.owners: List[discord.User] = [] diff --git a/cogs/Useful.py b/cogs/Useful.py index 87c9006..d44d2d3 100644 --- a/cogs/Useful.py +++ b/cogs/Useful.py @@ -8,6 +8,11 @@ import re import socket import time from socket import AF_INET6 +from io import BytesIO +from PIL import Image +from PIL import ImageFont +from PIL import ImageDraw +from PIL import ImageOps import aiohttp import discord @@ -358,11 +363,44 @@ class Useful(commands.Cog): @_cb.command(name='generate', aliases=['new', 'get'], category='misc') async def _cb_generate(self, ctx: commands.Context): + await ctx.channel.trigger_typing() + number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999) while not self.luhn_checker(number): number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999) + number = str(number) + cvv = ''.join(random.choice("abcdefghij") for _ in range(3)) - await ctx.send(''.join(str(digit) for digit in str(number))) + with Image.open("utils/images/blank_credit_card.png") as blank: + cc_font = ImageFont.truetype('utils/fonts/credit_card.ttf', 26) + user_font = ImageFont.truetype('utils/fonts/credit_card.ttf', 20) + draw = ImageDraw.Draw(blank) + + cvv_text = Image.new('L', (500, 50)) + cvv_draw = ImageDraw.Draw(cvv_text) + cvv_draw.text((0, 0), cvv, font=user_font, fill=255) + cvv_rotated = cvv_text.rotate(23, expand=1) + + draw.text( + (69, 510), + ' '.join([number[i:i+4] for i in range(0, len(number), 4)]), + (210, 210, 210), + font=cc_font + ) + + draw.text( + (69, 550), + ctx.author.name.upper(), + (210, 210, 210), + font=user_font + ) + blank.paste(ImageOps.colorize(cvv_rotated, (0, 0, 0), (0, 0, 0)), (470, 0), cvv_rotated) + + output = BytesIO() + blank.save(output, 'png') + output.seek(0) + + await ctx.send(file=discord.File(fp=output, filename="credit_card.png")) def setup(bot: TuxBot): diff --git a/requirements.txt b/requirements.txt index a428aba..41b86e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ psycopg2 configparser psutil tcp_latency -yarl \ No newline at end of file +yarl +pillow \ No newline at end of file diff --git a/utils/fonts/credit_card.ttf b/utils/fonts/credit_card.ttf new file mode 100644 index 0000000..00abec8 Binary files /dev/null and b/utils/fonts/credit_card.ttf differ diff --git a/utils/images/blank_credit_card.png b/utils/images/blank_credit_card.png new file mode 100644 index 0000000..b8a1802 Binary files /dev/null and b/utils/images/blank_credit_card.png differ