245 lines
12 KiB
Python
245 lines
12 KiB
Python
import wavelink
|
|
import typing
|
|
import psutil
|
|
from typing import Any, Optional
|
|
from discord import Embed, Colour, Embed, Member
|
|
from discord.types.embed import EmbedType
|
|
from datetime import datetime
|
|
from korcen import korcen
|
|
|
|
from Christmas.Module import get_gpuserver_status
|
|
start_time = datetime.now()
|
|
|
|
class ChristmasEmbed(Embed):
|
|
def __init__(self, *,
|
|
color: int | Colour | None = 0xf4f9ff,
|
|
title: Any | None = None,
|
|
type: EmbedType = "rich",
|
|
url: Any | None = None,
|
|
description: Any | None = None,
|
|
timestamp: datetime | None = None,
|
|
):
|
|
super().__init__(
|
|
color=color,
|
|
title=title,
|
|
type=type,
|
|
url=url,
|
|
description=description,
|
|
timestamp=timestamp,
|
|
)
|
|
|
|
def set_footer(self, *, text: Any | None = "ν¬λμ΄β", icon_url: Any | None = "https://discord.com/assets/6dbfff5aae6b1de2b83f.svg") -> None:
|
|
super().set_footer(text=text)
|
|
|
|
class Default_Embed:
|
|
|
|
@staticmethod
|
|
def default_join_embed():
|
|
embed = ChristmasEmbed(title="π ν¬λμ΄λ₯Ό μΆκ°ν΄μ£Όμ
μ κ°μ¬ν΄μ!", description="λ΄μ μ¬μ©νκΈ° μ μ μ΄ μλ²μ κ΄λ¦¬μλΌλ©΄ λ€μμ μ μ°¨λ₯Ό λ°λΌμ£ΌμΈμ!")
|
|
embed.add_field(name="1. μ½κ΄ λμ", value="λ€μμ μ½κ΄μ μ½κ³ ``/μλ² κ°μ
``λͺ
λ Ήμ΄λ₯Ό μ€νν΄μ£ΌμΈμ", inline=False)
|
|
embed.add_field(name="2. μ€μ ", value="``/μ€μ `` λͺ
λ Ήμ΄λ₯Ό ν΅ν΄ ν¬λμ΄μ μ¬λ¬ κΈ°λ₯μ μ€μ ν μ μμ΄μ!", inline=False)
|
|
embed.add_field(name="3. λμλ§", value="``/λμλ§`` λͺ
λ Ήμ΄λ₯Ό ν΅ν΄ ν¬λμ΄μ λͺ
λ Ήμ΄λ₯Ό νμΈν μ μμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
|
|
@staticmethod
|
|
def register_sucess():
|
|
embed = ChristmasEmbed(title="π κ°μ
μ±κ³΅!", description="μλ²κ°μ
μ μ±κ³΅νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μ΄μ ν¬λμ΄λ₯Ό μ¦κ²¨λ³΄μΈμ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def register_failed():
|
|
embed = ChristmasEmbed(title="β κ°μ
μ€ν¨!", description="μλ²κ°μ
μ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μμμλ μ€λ₯λ‘ μΈν΄ κ°μ
μ μ€ν¨νμ΄μ! μ΄ νμμ΄ μ§μλλ€λ©΄ μλΉμ€ μλ²μ λ¬Έμν΄μ£ΌμΈμ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def already_register():
|
|
embed = ChristmasEmbed(title="β κ°μ
μ€ν¨!", description="μ΄λ―Έ κ°μ
λ μλ²μμ!")
|
|
embed.add_field(name="μλ΄", value="μ΄λ―Έ κ°μ
λ μλ²μμ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def cooldown(sec):
|
|
return "μ΄ λͺ
λ Ήμ΄λ " + str(sec) + "μ΄ λ€μ λ€μ μ¬μ©ν μ μμ΄μ!"
|
|
|
|
|
|
|
|
@staticmethod
|
|
def BotInfo(gpuserver: typing.Dict[str, typing.Any], bot, APIlatency) -> Embed:
|
|
current_time = datetime.now()
|
|
uptime = current_time - start_time
|
|
uptime = str(uptime).split(".")[0]
|
|
"""
|
|
gpuserver: [system_memory_usage,cuda_memory_usage,oom_count]
|
|
"""
|
|
embed = Embed(title="**λ΄ μ 보**", description="ν¬λμ΄μ μ 보μμ!")
|
|
embed.add_field(name="**λ΄ κ°μ**", value=f"λ΄ ID: {bot.user.id}\nλ΄ λ²μ : 0.0.9\nκ°λμκ°: {str(uptime)}", inline=False)
|
|
orin = psutil.virtual_memory().used
|
|
orin = orin / 1024 / 1024 / 1024
|
|
if gpuserver == None or gpuserver["status"] == "offline":
|
|
embed.add_field(name="**λ΄ μμ**", value=f"GPUμλ²1 λ©λͺ¨λ¦¬ μ¬μ©λ: **μ€λ₯**\nGPUμλ²1 CUDA λ©λͺ¨λ¦¬ μ¬μ©λ: **μ€λ₯**\nGPUμλ²1 λ©λͺ¨λ¦¬ μ€λ₯ νμ: **μ€λ₯**\n νμ¬ μ€λ λ©λͺ¨λ¦¬ μ¬μ©λ:{round(orin)}GB", inline=False)
|
|
else:
|
|
mem_usage = gpuserver["system_memory_usage"]
|
|
cuda_memory_usage = gpuserver["cuda_memory_usage"]
|
|
oom_count = gpuserver["oom_count"]
|
|
embed.add_field(name="**λ΄ μμ**", value=f"νμ¬ μ€λ λ©λͺ¨λ¦¬ μ¬μ©λ: {round(orin)}GB\n\nGPUμλ²1 λ©λͺ¨λ¦¬ μ¬μ©λ: {mem_usage}GB/128GB\nGPUμλ²1 GPU λ©λͺ¨λ¦¬ μ¬μ©λ: {cuda_memory_usage}GB/80GB\nGPUμλ²1 λ©λͺ¨λ¦¬ μ€λ₯ νμ: {oom_count}", inline=False)
|
|
embed.add_field(name="**λ΄ ν΅κ³**", value=f"ποΈ **{len(bot.guilds)}**κ°μ μλ²μμ λ΄μ μ¬μ©μ€μ΄μμ!\nπ€ **{len(bot.users)}**λͺ
μ μ μ μ ν¨κ»νλ μ€μ΄μμ!", inline=False)
|
|
if APIlatency is None:
|
|
embed.add_field(name="**λ΄ ν**", value=f"π **λμ€μ½λ κ²μ΄νΈμ¨μ΄ ν**: {round(bot.latency * 1000)}ms\nπ **AI κ²μ΄νΈμ¨μ΄ ν**: μ€λ₯", inline=False)
|
|
else:
|
|
embed.add_field(name="**λ΄ ν**", value=f"π **λμ€μ½λ κ²μ΄νΈμ¨μ΄ ν**: {round(bot.latency * 1000)}ms\nπ **AI κ²μ΄νΈμ¨μ΄ ν**: {APIlatency}ms", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
class Mail_Embed:
|
|
|
|
@staticmethod
|
|
def mail_confirm(title: str, description: str, receive_user: Member) -> Embed:
|
|
embed = ChristmasEmbed(title="β οΈ μ μ‘μ νμΈ", description="νΈμ§λ₯Ό μ λ§λ‘ μ μ‘νμκ² μ΅λκΉ?")
|
|
embed.add_field(name="β οΈ μ£Όμμ¬ν β οΈ", value="νΈμ§λ ν λ² μ μ‘νλ©΄ νλ²μ μμ κΈ°ν μ΄νμλ μ·¨μν μ μμ΄μ!\n λ΄μ©μ μ μ½κ³ ``μ μ‘``λ²νΌμ λλ¬μ£ΌμΈμ!", inline=False)
|
|
embed.add_field(name="λ°λμ΄", value=f"{receive_user.mention}", inline=False)
|
|
embed.add_field(name="μ λͺ©", value=title, inline=False)
|
|
embed.add_field(name="λ΄μ©", value=description, inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_confirm_edit(title: str, description: str, receive_user: Member) -> Embed:
|
|
embed = ChristmasEmbed(title="β οΈ μμ μ νμΈ", description="νΈμ§λ₯Ό μ λ§λ‘ μμ νμκ² μ΅λκΉ?")
|
|
embed.add_field(name="β οΈ μ£Όμμ¬ν β οΈ", value="μ΄λ²μ νΈμ§λ₯Ό μμ νλ©΄ λ€μλ μμ ν μ μκ² λμ!\n λ΄μ©μ μ μ½κ³ ``μ μ‘``λ²νΌμ λλ¬μ£ΌμΈμ!", inline=False)
|
|
embed.add_field(name="λ°λμ΄", value=f"{receive_user.mention}", inline=False)
|
|
embed.add_field(name="μ λͺ©", value=title, inline=False)
|
|
embed.add_field(name="λ΄μ©", value=description, inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_cant_edit():
|
|
embed = ChristmasEmbed(title="β νΈμ§ μμ μ€ν¨!", description="νΈμ§ μμ μ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="νΈμ§λ ν λ² μ μ‘νλ©΄ νλ²μ μμ κΈ°ν μ΄νμλ μ·¨μνκ±°λ μμ ν μ μμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
|
|
@staticmethod
|
|
def mail_sended(receive_user: Member) -> Embed:
|
|
embed = ChristmasEmbed(title="β
μ μ‘μλ£!", description="νΈμ§ μ μ‘μ μλ£νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="λ³΄λΈ νΈμ§λ 2023λ
12μ 25μΌλΆν° μ΄λ κ°λ₯ν΄μ!", inline=False)
|
|
embed.add_field(name="λ°λμ΄", value=f"{receive_user.mention}", inline=False)
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_edit_sended(receive_user: Member) -> Embed:
|
|
embed = ChristmasEmbed(title="β
μμ μλ£!", description="νΈμ§ μμ μ μλ£νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μμ λ νΈμ§λ 2023λ
12μ 25μΌλΆν° μ΄λ κ°λ₯ν΄μ!", inline=False)
|
|
embed.add_field(name="λ°λμ΄", value=f"{receive_user.mention}", inline=False)
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_notfound() -> Embed:
|
|
embed = ChristmasEmbed(title="β νΈμ§ μμ!", description="νΈμ§κ° μμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="λ°μ νΈμ§κ° μμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_already_sended() -> Embed:
|
|
embed = ChristmasEmbed(title="β νΈμ§ μ μ‘ μ€ν¨!", description="μ΄λ―Έ νΈμ§λ₯Ό 보λμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μ΄λ―Έ νΈμ§λ₯Ό 보λμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def mail_page(data) -> Embed:
|
|
embed = ChristmasEmbed(title="π¨ νΈμ§", description="νΈμ§λ₯Ό νμΈν΄λ³΄μΈμ!(μμ€λ± λ―Όκ°ν λ΄μ©μ΄ ν¬ν¨λ λ΄μ©μ μλμΌλ‘ μ€ν¬μΌλ¬μ²λ¦¬λμ!)")
|
|
username = data["username"]
|
|
userid = data["userid"]
|
|
title = data["title"]
|
|
description = data["content"]
|
|
if korcen.check(title) == True:
|
|
title = "||" + title + "||"
|
|
if korcen.check(description) == True:
|
|
description = "||" + description + "||"
|
|
embed.add_field(name="보λΈμ΄", value=f"{username}({userid})", inline=False)
|
|
embed.add_field(name="μ λͺ©", value=title, inline=False)
|
|
embed.add_field(name="λ΄μ©", value=description, inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
class Aiart_Embed:
|
|
|
|
@staticmethod
|
|
def failed_generate() -> Embed:
|
|
embed = ChristmasEmbed(title="β κ·Έλ¦Ό μμ± μ€ν¨!", description="κ·Έλ¦Ό μμ±μ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="κ·Έλ¦Ό μμ±μ μ€ν¨νμ΄μ! μ΄ νμμ΄ μ§μλλ€λ©΄ μλΉμ€ μλ²μ λ¬Έμν΄μ£ΌμΈμ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def sucess_generate(prompt: str, remove: str) -> Embed:
|
|
embed = ChristmasEmbed(title="β
κ·Έλ¦Ό μμ± μ±κ³΅!", description="κ·Έλ¦Ό μμ±μ μ±κ³΅νμ΄μ!")
|
|
embed.add_field(name="ν둬ν¬νΈ", value=prompt, inline=False)
|
|
embed.add_field(name="μ§μ΄ ν둬ν¬νΈ", value=remove, inline=False)
|
|
embed.set_image(url="attachment://image.png")
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def generating() -> Embed:
|
|
embed = ChristmasEmbed(title="κ·Έλ¦Ό μμ±μ€...", description="κ·Έλ¦Όμ μμ±νλ μ€μ΄μμ!")
|
|
embed.add_field(name="μλ΄", value="κ·Έλ¦Ό μμ±μλ μ΅λ 2λΆμ΄ μμλ μ μμ΄μ!(ν¬λμ΄λ λμ΄ μμ΄μ...)", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def evalate(tags, rating) -> ChristmasEmbed:
|
|
if tags == None:
|
|
embed = ChristmasEmbed(name="**μ€λ₯**", value="κ·Έλ¦Ό λΆμμ μ€ν¨νμ΄μ. λμ€μ λ€μ μλν΄μ£ΌμΈμ", inline=False)
|
|
return embed
|
|
else:
|
|
embed = ChristmasEmbed(title="**κ·Έλ¦Ό λΆμ μλ£**", description="κ·Έλ¦Ό λΆμμ΄ μλ£λμμ΄μ!")
|
|
embed.set_image(url="attachment://image.png")
|
|
embed.add_field(name="**λ±κΈ**", value=f"{rating}", inline=False)
|
|
texts = ""
|
|
for tag, score in tags:
|
|
percentage = score * 100
|
|
texts = texts + f"{tag} : {percentage:.1f}%\n"
|
|
embed.add_field(name="**λΆμλ μμ**", value=f"{texts}", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
class Music_Embed:
|
|
|
|
@staticmethod
|
|
def music_notenable():
|
|
embed = ChristmasEmbed(title="β μμ
μ¬μ μ€ν¨!", description="μμ
μ¬μμ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μ΄ μλ²μμλ μμ
μ μ¬μν μ μμ΄μ! \nλ§μ½ μλ²μ κ΄λ¦¬μλΌλ©΄ ``/μ€μ `` λͺ
λ Ήμ΄λ‘ μμ
κΈ°λ₯μ λ€μ νμ±νμ¬ν¬μ μμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def author_not_voice():
|
|
embed = ChristmasEmbed(title="β μμ
μ¬μ μ€ν¨!", description="μμ
μ¬μμ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μμ
μ μ¬μνλ €λ©΄ μμ±μ±λμ λ€μ΄κ°μΌ ν΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
@staticmethod
|
|
def author_diffrent_voice():
|
|
embed = ChristmasEmbed(title="β μμ
μ¬μ μ€ν¨!", description="μμ
μ¬μμ μ€ν¨νμ΄μ!")
|
|
embed.add_field(name="μλ΄", value="μ΄λ―Έ λ€λ₯Έ μ±λμ μ μλμ΄μμ΄μ!", inline=False)
|
|
embed.set_footer()
|
|
return embed
|
|
|
|
#@staticmethod
|
|
#def music_queue(music: wavelink.Playable):
|
|
#μμ
μ queueμ λ£μ
|
|
#embed = ChristmasEmbed(title="β
μμ
μ¬μ μ±κ³΅!", description="μμ
μ¬μμ μ±κ³΅νμ΄μ!")
|
|
|
|
#embed = |