From 67cca95a6863bdf963a3f152390fc1643b23b80a Mon Sep 17 00:00:00 2001 From: tmddn3070 Date: Wed, 6 Dec 2023 00:12:54 +0900 Subject: [PATCH] Update code: Changed description in ART.command --- Christmas/Cogs/Commands_Aiart.py | 2 +- Christmas/Cogs/Event.py | 4 ++-- Christmas/UI/Modal.py | 3 --- Christmas/__main__.py | 2 ++ Christmas/discord.py | 23 ++++++++++++++++++++++- Dockerfile | 9 ++++----- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Christmas/Cogs/Commands_Aiart.py b/Christmas/Cogs/Commands_Aiart.py index 40bc712..b40ac58 100644 --- a/Christmas/Cogs/Commands_Aiart.py +++ b/Christmas/Cogs/Commands_Aiart.py @@ -13,7 +13,7 @@ class CAiart(Cog): ART = SlashCommandGroup("그림", "그림 기능") - @ART.command(name="생성", description="루나가 그림을 그려줍니다.") + @ART.command(name="생성", description="크돌이가 그림을 그려줍니다.") @cooldown(1, 10, BucketType.user) async def _생성(self, ctx, ress: Option(str, name="해상도",description="그림의 해상도를 입력해주세요. (기본값: 512x512)", required=False, choices=["1:1", "2:3", "7:4","3:4"], default="1:1"), shows: Option(str, name="보기여부",description="생성된 그림을 나를 제외한 사람한테 보여줄지 말지를 지정합니다.", choices=["보여주기","보여주지 말기"],required=False, default="보여주기"), diff --git a/Christmas/Cogs/Event.py b/Christmas/Cogs/Event.py index 7ac2cf9..5fe14e2 100644 --- a/Christmas/Cogs/Event.py +++ b/Christmas/Cogs/Event.py @@ -7,7 +7,7 @@ import onnxruntime as rt from discord import ApplicationContext, DiscordException, Game, Guild from discord.ext.commands import Cog from discord.ext import tasks - +import sentry_sdk from discord.ext.commands import CommandOnCooldown from Christmas.UI.Embed import Default_Embed, Music_Embed from Christmas.config import ChristmasConfig @@ -25,7 +25,7 @@ class Event(Cog): if isinstance(exception, CommandOnCooldown): await ctx.respond(Default_Embed.cooldown(exception.retry_after), ephemeral=True) else: - print(exception) + sentry_sdk.capture_exception(exception) @Cog.listener() async def on_ready(self) -> None: print("Ready!") diff --git a/Christmas/UI/Modal.py b/Christmas/UI/Modal.py index 3bed122..44cc532 100644 --- a/Christmas/UI/Modal.py +++ b/Christmas/UI/Modal.py @@ -87,15 +87,12 @@ class Aiart(Modal): if re.search(r"\{[0-9]{18}\}", prompt): user_id = re.search(r"\{[0-9]{18}\}", prompt).group()[1:-1] user = await interaction.guild.fetch_member(int(user_id)) - print(user) if user == None: avatars = None else: avatars = user.avatar - print("OK") config = ChristmasConfig() #prompt: str, remove: str, res: list, isnsfw: bool, style1: float, style2: float, afterprocess: float - print(avatars) payload = await process_prompt(prompt, remove, self.res, self.allownsfw, self.style1, self.style2, self.afterprocess, avatars) config = ChristmasConfig() result = await post_gpu_server(f"{config.AI}/sdapi/v1/txt2img", payload) diff --git a/Christmas/__main__.py b/Christmas/__main__.py index 0f27e5b..9fedb37 100644 --- a/Christmas/__main__.py +++ b/Christmas/__main__.py @@ -1,3 +1,5 @@ +import sentry_sdk + from types import SimpleNamespace from typing import Any, cast diff --git a/Christmas/discord.py b/Christmas/discord.py index 878ee10..7f50b73 100644 --- a/Christmas/discord.py +++ b/Christmas/discord.py @@ -1,4 +1,9 @@ import os +import sentry_sdk +import asyncio +import logging +from sentry_sdk.integrations.asyncio import AsyncioIntegration +from sentry_sdk.integrations.logging import LoggingIntegration from types import SimpleNamespace from typing import Any, cast @@ -33,4 +38,20 @@ def apply_uvloop() -> None: pass else: uvloop.install() - asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) \ No newline at end of file + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) + +def inital_sentry_sdk() -> None: + logger = logging.getLogger('discord') + logger.setLevel(logging.DEBUG) + handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w') + handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) + logger.addHandler(handler) + sentry_logging = LoggingIntegration( + level=logging.WARNING, + event_level=logging.ERROR + ) + sentry_sdk.init( + dsn="https://ddb20b81432c3da07a42f0da207f9cf0@o4506343770357760.ingest.sentry.io/4506343772258304", + integrations=[sentry_logging, AsyncioIntegration()] + ) + print("inital sentry_sdk") \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 99b731e..dd38a27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ - FROM python:3.11.5-slim WORKDIR /app -COPY requirements.txt . - -RUN pip install --no-cache-dir -r requirements.txt +#COPY requirements.txt . +RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y +RUN pip install pandas py-cord koreanbots motor uvloop korcen nanoid pendulum Wavelink onnxruntime psutil meilisearch_python_sdk Pillow opencv-python aiogoogletrans sentry-sdk RUN pip uninstall -y discord.py py-cord RUN pip install --no-cache-dir py-cord[speed] py-cord[voice] RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime COPY . . -CMD ["python", "-m", "Christmas"] +CMD ["python", "-m", "Christmas"] \ No newline at end of file