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 fe57c02b99 feat(neofetch.py): add new neofetch command to display system and server stats
chore(.pre-commit-config.yaml): add new pre-commit hooks for trailing commas and gitleaks
refactor(cog_loader.py): improve error logging for cog loading failures
style(.pre-commit-config.yaml, cog_loader.py): apply code formatting rules

style(dev.py, eval.py, git.py, mail.py, random.py): improve code readability by breaking down long lines of code into multiple lines
refactor(eval.py): add trailing comma to logger.warning for better code formatting
refactor(git.py): simplify import statement for Issue from githubkit.versions.latest.models
refactor(mail.py): add line breaks for better readability and code consistency
refactor(random.py): add line breaks in function parameters and conditions for better readability

style(xkcd.py, config.py, export.py): refactor function arguments to multi-line for better readability

style: reformat code for better readability in audit.py, commands.py, gate.py, member.py, run.py, temp_vc.py, tty_roles.py, purge.py
refactor: improve code readability by breaking down complex expressions and function calls into multiple lines

style: reformat code for better readability and PEP8 compliance in multiple files

refactor: simplify list declaration in guide.py for better readability

refactor: improve function parameter formatting in multiple files for better readability

refactor: improve string formatting in multiple files for better readability

refactor: improve function declaration formatting in multiple files for better readability

refactor: improve embed creation in rolecount.py for better readability

style(snippets.py, tldr.py, tools.py, wiki.py): reformat code for better readability
refactor(tools.py): simplify dictionary initialization for encodings and decodings
perf(tldr.py, tools.py): reduce subprocess.run arguments to improve performance
fix(wiki.py): correct the order of error handling and embed creation for better error management

refactor(case.py): improve readability by breaking down long function signatures into multiple lines
style(case.py): add trailing commas to improve code formatting and ease of future changes

style(case.py): improve readability by breaking down long function parameters into multiple lines
refactor(case.py): add trailing commas in dictionary to make future changes cleaner and more readable

style(guild_config.py): refactor function definitions to improve readability and adhere to PEP8 line length standards

style: apply PEP 8 style guide to improve readability and maintainability
refactor: add trailing commas to improve diff readability in future changes
fix(event_handler.py): add missing comma in message string to fix syntax error

style: apply black formatting to improve code readability and maintain consistency across the codebase
2024-07-02 03:41: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))