feat(ascii): new ascii art for term and fix piracy embed color

This commit is contained in:
neoarz
2025-09-27 08:23:56 -04:00
parent 12349e39f6
commit 158d1903a9
5 changed files with 124 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
- [x] Add /idevice command - [x] Add /idevice command
- [x] Add /no apps command - [x] Add /no apps command
- [x] Add rest of the errors yikes - [x] Add rest of the errors yikes
- [ ] Add ddi mounting command - [x] Add ddi mounting command
- [ ] Add unit tests - [ ] Add unit tests

6
bot.py
View File

@@ -15,6 +15,7 @@ from discord.ext.commands import Context
from dotenv import load_dotenv from dotenv import load_dotenv
from database import DatabaseManager from database import DatabaseManager
from utils.ascii_art import ascii
load_dotenv() load_dotenv()
@@ -211,6 +212,7 @@ class DiscordBot(commands.Bot):
except Exception as e: except Exception as e:
self.logger.error(f"Error fetching application info: {e}") self.logger.error(f"Error fetching application info: {e}")
await self.init_db() await self.init_db()
await self.load_cogs() await self.load_cogs()
self.status_task.start() self.status_task.start()
@@ -382,6 +384,10 @@ def signal_handler(signum, frame):
bot = DiscordBot() bot = DiscordBot()
if __name__ == "__main__": if __name__ == "__main__":
os.system('clear' if os.name == 'posix' else 'cls')
print(ascii)
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)

View File

@@ -13,7 +13,7 @@ class Piracy(commands.Cog, name="piracy"):
) )
async def piracy(self, context: Context) -> None: async def piracy(self, context: Context) -> None:
embed = discord.Embed( embed = discord.Embed(
color=0x7289DA, color=0xE02B2B,
) )
embed.set_author(name="Piracy", icon_url="https://yes.nighty.works/raw/rVYXlf.png") 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") embed.set_image(url="https://yes.nighty.works/raw/lEhuWK.png")

3
utils/__init__.py Normal file
View File

@@ -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']

113
utils/ascii_art.py Normal file
View File

@@ -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