From 23dade9b9e4d9c78c29b8c2c8ff2c46e54c1e028 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 8 Feb 2026 01:58:46 +0000 Subject: [PATCH] Added and updated repositories 2026-02-08 01:58:46 --- ZetGoHack/nullmod/Gradientor.py | 61 ++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/ZetGoHack/nullmod/Gradientor.py b/ZetGoHack/nullmod/Gradientor.py index 91ba9cb..1c8ad0d 100644 --- a/ZetGoHack/nullmod/Gradientor.py +++ b/ZetGoHack/nullmod/Gradientor.py @@ -4,9 +4,9 @@ #░░░█░░░█░░░░█░░█░█░█░█ #░░░███░███░░█░░███░███ -# meta developer: @ZetGo +# meta developer: @nullmod -__version__ = (1, 0, 0) +__version__ = (1, 0, 1) import io import math @@ -94,9 +94,9 @@ def set_gradient(im: io.BytesIO, gradient: Image.Image) -> io.BytesIO: buffer.seek(0) return buffer -def crop_by_bbox(img: Image.Image): +def crop_by_bbox(img: Image.Image, bbox: tuple = None): img_w, img_h = img.size - x, y, w, h = BBOX_TGA_TGD + x, y, w, h = bbox or BBOX_TGA_TGD left = int(round(x * img_w)) top = int(round(y * img_h)) @@ -132,7 +132,7 @@ BBOX_TGA_TGD = ( ) -@loader.translatable_docstring +@loader.tds class Gradientor(loader.Module): strings = { "name": "Gradientor", @@ -148,11 +148,17 @@ class Gradientor(loader.Module): async def client_ready(self): self.colors = self.get("PROFILE_COLORS", None) - if not self.colors: + if not self.colors or not self.colors.get("light", None): raw_colors = (await self.client(GetPeerProfileColorsRequest(0))).colors self.colors = { - str(col.color_id): hexes_to_rgbs(col.dark_colors.bg_colors) for col - in raw_colors + "dark": { + str(col.color_id): hexes_to_rgbs(col.dark_colors.bg_colors) for col + in raw_colors + }, + "light": { + str(col.color_id): hexes_to_rgbs(col.colors.bg_colors) for col + in raw_colors + }, } self.set("PROFILE_COLORS", self.colors) @@ -160,12 +166,14 @@ class Gradientor(loader.Module): @loader.command( ru_doc="[фотография/reply] - создать аватарку с градиентом из цвета профиля\n" "--update-cache - обновить кеш профиля, если вы только что сменили фон профиля\n" - "--linear - использовать линейный градиент" + "--linear - использовать линейный градиент\n" + "--light - использовать светлую тему" ) async def makepp(self, message: Message): """[photo/reply] - create a profile picture with a gradient from profile color\n --update-cache - update profile cache if you just changed profile background\n - --linear - use linear gradient""" + --linear - use linear gradient\n + --light - use light theme""" reply: Message = await message.get_reply_message() args = utils.get_args(message) @@ -174,13 +182,25 @@ class Gradientor(loader.Module): args.remove("--update-cache") else: upd_cache = False - + if "--linear" in args: force_linear = True args.remove("--linear") else: force_linear = False + if "--light" in args: + theme = "light" + args.remove("--light") + else: + theme = "dark" + + if "--full" in args: + _full = True + args.remove("--full") + else: + _full = False + user = None background_only = False @@ -202,10 +222,10 @@ class Gradientor(loader.Module): user = reply.sender else: user = self.client.hikka_me - + if not user.premium: color1, color2 = (28, 28, 28), (28, 28, 28) - + elif user.emoji_status and isinstance(user.emoji_status, EmojiStatusCollectible): color1, color2 = ( user.emoji_status.edge_color, user.emoji_status.center_color @@ -216,20 +236,21 @@ class Gradientor(loader.Module): elif user.profile_color: color_variant = user.profile_color.color - color1, color2 = self.colors.get( + color1, color2 = self.colors.get(theme).get( str(color_variant), ((28, 28, 28), (28, 28, 28)) ) else: color1, color2 = (28, 28, 28), (28, 28, 28) - + await utils.answer(message, self.strings["gradient_creating"]) gradient = get_gradient((1280, 1280), color1, color2, "linear" if force_linear else "radial") - gradient = crop_by_bbox(gradient) + if not _full: + gradient = crop_by_bbox(gradient) - if not background_only: + if not background_only and not _full: p_b = await photo_source.download_media(bytes) p_b_io = io.BytesIO(p_b) p_b_io.seek(0) @@ -240,7 +261,7 @@ class Gradientor(loader.Module): result = io.BytesIO() gradient.save(result, format='PNG') result.seek(0) - + result.name = "grad @nullmod.png" - - await utils.answer(message, self.strings["gradient_created"], file=result, force_document=True) + + await utils.answer(message, self.strings["gradient_created"], file=result, force_document=True) \ No newline at end of file