From 158d1903a904b2ac23dbcea4075f1cff76d8086a Mon Sep 17 00:00:00 2001 From: neoarz Date: Sat, 27 Sep 2025 08:23:56 -0400 Subject: [PATCH] feat(ascii): new ascii art for term and fix piracy embed color --- TODO.md | 2 +- bot.py | 6 ++ cogs/miscellaneous/piracy.py | 2 +- utils/__init__.py | 3 + utils/ascii_art.py | 113 +++++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 utils/__init__.py create mode 100644 utils/ascii_art.py diff --git a/TODO.md b/TODO.md index bc0ef07..80da761 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,7 @@ - [x] Add /idevice command - [x] Add /no apps command - [x] Add rest of the errors yikes - - [ ] Add ddi mounting command + - [x] Add ddi mounting command - [ ] Add unit tests diff --git a/bot.py b/bot.py index fdeb9bb..6481414 100644 --- a/bot.py +++ b/bot.py @@ -15,6 +15,7 @@ from discord.ext.commands import Context from dotenv import load_dotenv from database import DatabaseManager +from utils.ascii_art import ascii load_dotenv() @@ -210,6 +211,7 @@ class DiscordBot(commands.Bot): self.logger.info(f"Bot owner: {app_info.owner.name} (ID: {app_info.owner.id})") except Exception as e: self.logger.error(f"Error fetching application info: {e}") + await self.init_db() await self.load_cogs() @@ -382,6 +384,10 @@ def signal_handler(signum, frame): bot = DiscordBot() if __name__ == "__main__": + os.system('clear' if os.name == 'posix' else 'cls') + + print(ascii) + signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) diff --git a/cogs/miscellaneous/piracy.py b/cogs/miscellaneous/piracy.py index 1930ab3..fd02dc1 100644 --- a/cogs/miscellaneous/piracy.py +++ b/cogs/miscellaneous/piracy.py @@ -13,7 +13,7 @@ class Piracy(commands.Cog, name="piracy"): ) async def piracy(self, context: Context) -> None: embed = discord.Embed( - color=0x7289DA, + color=0xE02B2B, ) embed.set_author(name="Piracy", icon_url="https://yes.nighty.works/raw/rVYXlf.png") embed.set_image(url="https://yes.nighty.works/raw/lEhuWK.png") diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..9cffff4 --- /dev/null +++ b/utils/__init__.py @@ -0,0 +1,3 @@ +from .ascii_art import ascii, ascii_plain, gradient_text, gradient_text_selective + +__all__ = ['ascii', 'ascii_plain', 'gradient_text', 'gradient_text_selective'] \ No newline at end of file diff --git a/utils/ascii_art.py b/utils/ascii_art.py new file mode 100644 index 0000000..369f429 --- /dev/null +++ b/utils/ascii_art.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 +# From https://github.com/neoarz/Velora/blob/main/Velora/ui/ascii.py + +import math + +def gradient_text(text, start_color, end_color): + def rgb_interp(start, end, t): + return tuple(int(start[i] + (end[i] - start[i]) * t) for i in range(3)) + lines = text.splitlines() + gradient_lines = [] + total_chars = sum(len(line) for line in lines if line.strip()) + idx = 0 + for line in lines: + colored_line = "" + for char in line: + if char.strip(): + t = idx / (total_chars - 1) + r, g, b = rgb_interp(start_color, end_color, t) + colored_line += f"\033[38;2;{r};{g};{b}m{char}\033[0m" + idx += 1 + else: + colored_line += char + gradient_lines.append(colored_line) + return "\n".join(gradient_lines) + +def gradient_text_selective(text, start_color, end_color, gradient_word, white_prefix=""): + def rgb_interp(start, end, t): + return tuple(int(start[i] + (end[i] - start[i]) * t) for i in range(3)) + + lines = text.splitlines() + result_lines = [] + + for line in lines: + if gradient_word in line and white_prefix in line: + prefix_start = line.find(white_prefix) + word_start = line.find(gradient_word) + + if prefix_start != -1 and word_start != -1: + before_prefix = line[:prefix_start] + prefix_part = line[prefix_start:word_start] + word_part = gradient_word + after_word = line[word_start + len(gradient_word):] + + colored_before = "" + total_chars = sum(1 for char in before_prefix if char.strip()) + idx = 0 + for char in before_prefix: + if char.strip(): + t = idx / max(1, total_chars - 1) + r, g, b = rgb_interp(start_color, end_color, t) + colored_before += f"\033[38;2;{r};{g};{b}m{char}\033[0m" + idx += 1 + else: + colored_before += char + + white_prefix_colored = f"\033[38;2;255;255;255m{prefix_part}\033[0m" + + colored_word = "" + word_chars = [char for char in word_part if char.strip()] + for i, char in enumerate(word_part): + if char.strip(): + t = i / max(1, len(word_chars) - 1) + r, g, b = rgb_interp(start_color, end_color, t) + colored_word += f"\033[38;2;{r};{g};{b}m{char}\033[0m" + else: + colored_word += char + + result_lines.append(colored_before + white_prefix_colored + colored_word + after_word) + else: + colored_line = "" + total_chars = sum(1 for char in line if char.strip()) + idx = 0 + for char in line: + if char.strip(): + t = idx / max(1, total_chars - 1) + r, g, b = rgb_interp(start_color, end_color, t) + colored_line += f"\033[38;2;{r};{g};{b}m{char}\033[0m" + idx += 1 + else: + colored_line += char + result_lines.append(colored_line) + else: + colored_line = "" + total_chars = sum(1 for char in line if char.strip()) + idx = 0 + for char in line: + if char.strip(): + t = idx / max(1, total_chars - 1) + r, g, b = rgb_interp(start_color, end_color, t) + colored_line += f"\033[38;2;{r};{g};{b}m{char}\033[0m" + idx += 1 + else: + colored_line += char + result_lines.append(colored_line) + + return "\n".join(result_lines) + + +_ascii_art = """ +███████╗██╗ ██╗███╗ ██╗████████╗██████╗ ███████╗██╗ +██╔════╝╚██╗ ██╔╝████╗ ██║╚══██╔══╝██╔══██╗██╔════╝██║ +███████╗ ╚████╔╝ ██╔██╗ ██║ ██║ ██████╔╝█████╗ ██║ +╚════██║ ╚██╔╝ ██║╚██╗██║ ██║ ██╔══██╗██╔══╝ ██║ +███████║ ██║ ██║ ╚████║ ██║ ██║ ██║███████╗███████╗ +╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ +""" + +_start_rgb = (255, 69, 0) # Red-orange +_end_rgb = (255, 165, 0) # Orange + +ascii = gradient_text_selective(_ascii_art, _start_rgb, _end_rgb, "neoarz", "Made by ") + +ascii_plain = _ascii_art \ No newline at end of file