1
Fork 0
mirror of https://github.com/allthingslinux/tux.git synced 2024-10-02 16:43:12 +00:00
tux/.archive/neofetch.py
kzndotsh 679de67165 style(neofetch.py, cog_loader.py, avatar.py, tldr.py): correct comment block formatting for consistency
refactor(neofetch.py): modify line separator for better visual appeal
2024-07-15 10:46:57 +00:00

92 lines
4.5 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import time
import discord
import psutil # for uptime
from discord import app_commands
from discord.ext import commands
gray = ""
red = ""
green = ""
yellow = ""
blue = ""
pink = ""
cyan = ""
white = ""
reset = ""
class Neofetch(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
@app_commands.command(name="neofetch", description="Make a neofetch.")
async def neofetch(self, interaction: discord.Interaction) -> None:
if interaction.guild is None:
await interaction.response.send_message(
content="This command cannot be used in direct messages.", ephemeral=True,
)
return
# base ascii art
base = """⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣾⣿⢿⣿⣶⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣟⣯⣷⢿⣻⣷⣻⡾⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⣽⣟⣾⢿⣻⡾⣯⡿⣯⡿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠋⠙⢽⣟⡟⠁⠀⠙⣿⢯⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣇⢸⣧⡸⠿⣀⢼⣿⠀⢸⣿⢷⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠜⢍⢊⢂⠢⠩⡙⠤⣿⣟⡿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣧⡣⣂⢂⠢⢡⠱⡘⣑⢼⣯⡿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠈⠲⢌⣍⡢⠕⠈⠁⠈⣿⣽⡿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⡍⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⢿⣻⣷⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⣯⡷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣟⢯⣿⣽⣆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣴⣿⣳⣯⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣷⡽⣾⣟⣧⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣼⣿⢳⣯⠃⠀⠀⠀⢀⠠⠀⠂⠄⠠⠀⠀⠀⠀⠀⢿⣽⡼⣯⡿⣧⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣸⡿⡇⣿⠇⠀⠀⠀⠂⠄⠂⡈⠄⠈⠄⡈⠄⠂⠀⠀⠈⣿⡇⣿⣻⣟⡇⠀⠀⠀
⠀⠀⠀⠀⠀⣿⣟⡇⣿⠀⠀⢀⠁⡈⠄⠁⠄⠂⡁⠄⠐⢀⠡⠐⠀⠀⠙⠃⢿⣯⢿⣻⠀⠀⠀
⠀⠀⠀⠀⢸⣿⣽⣧⡘⠀⠀⡂⠄⠐⡈⠐⡈⠠⠀⢂⠁⠄⠐⡈⢀⣼⣿⣿⣷⣮⢻⡿⠀⠀⠀
⠀⠀⠀⢀⠞⢅⠢⡙⢿⣦⣀⠂⠄⢁⠐⠠⠐⢀⠁⠄⠐⡀⢁⢰⢋⠺⣟⣾⢷⠻⡛⡣⡄⠀⠀
⢀⢔⠞⠍⢌⠢⡑⠄⠍⢿⣽⣷⣄⠂⠐⡀⠡⢀⠐⢈⠠⠀⠂⡼⡂⠕⠌⠍⢅⢑⢐⢐⢹⠀⠀
⢺⠠⠡⡑⢄⠑⠌⠌⠌⢌⢳⣿⣽⡆⠁⠄⢂⠠⠈⠠⠐⢈⠀⡗⡨⠨⠨⡈⡂⡂⡂⠢⠡⣣⡀
⢸⠡⡑⢌⠢⠡⠡⠡⡑⡐⡐⡹⣌⠠⠈⠄⠂⡀⠅⠂⡁⠄⣰⠣⠨⡈⡂⡂⡂⡂⠪⡈⡂⡂⣳
⡏⢌⢂⠢⠡⠡⠡⡑⡐⡐⡐⡐⠌⣷⣤⣌⣀⣐⣀⣥⣴⣾⡟⢌⢂⢂⠢⡂⠪⡈⣂⣢⠶⠚⠁
⠙⠲⠦⠥⢥⣅⡕⡐⡐⡐⡐⠌⢌⡾⠟⠟⠛⠛⠛⠛⠽⠾⣇⢂⢂⠢⡑⢌⢂⡶⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠑⠒⠶⠬⠞⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠢⣆⣑⡬⠖⠋⠀⠀⠀⠀⠀⠀"""
# get uptime in the format of days, hours, minutes
uptime = time.strftime("%d days, %H hours, %M minutes", time.gmtime(time.time() - psutil.boot_time()))
cpuusage = psutil.cpu_percent()
memusage = psutil.virtual_memory().percent
lines = f"""{yellow}tux{reset}@{yellow}{interaction.guild.name.lower().replace(" ", "")}{reset}
-----------------
Tux Stats{reset}
{red}OS{reset}: Tux Alpha
{yellow}Kernel{reset}: 6.9
{green}Uptime{reset}: {uptime}
{cyan}CPU{reset}: {cpuusage}%
{blue}Memory{reset}: {memusage}%
{pink}Ping{reset}: {round(self.bot.latency * 1000)}ms
-----------------
Server Stats{reset}
{red}Name{reset}: {interaction.guild.name}
{yellow}Owner{reset}: {interaction.guild.owner}
{green}Members{reset}: {interaction.guild.member_count}
{cyan}Roles{reset}: {len(interaction.guild.roles)}
{blue}Channels{reset}: {len(interaction.guild.channels)}
{pink}Emojis + Stickers{reset}: {len(interaction.guild.emojis) + len(interaction.guild.stickers)}
-----------------
"""
fetch = (
"\n".join([f"{base.splitlines()[i]} {lines.splitlines()[i]}" for i in range(len(lines.splitlines()))])
+ "\n"
+ "\n".join(base.splitlines()[len(lines.splitlines()) :])
)
await interaction.response.send_message(content=f"```ansi\n{fetch}\n```")
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Neofetch(bot))