Spaces:
Runtime error
Runtime error
seawolf2357
commited on
Commit
โข
262fbfb
1
Parent(s):
2db254d
Update app.py
Browse files
app.py
CHANGED
@@ -11,33 +11,33 @@ from youtube_transcript_api import YouTubeTranscriptApi
|
|
11 |
from youtube_transcript_api.formatters import TextFormatter
|
12 |
from dotenv import load_dotenv
|
13 |
|
14 |
-
#
|
15 |
load_dotenv()
|
16 |
|
17 |
-
#
|
18 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s:%(message)s', handlers=[logging.StreamHandler()])
|
19 |
|
20 |
-
#
|
21 |
intents = discord.Intents.default()
|
22 |
intents.message_content = True
|
23 |
intents.messages = True
|
24 |
intents.guilds = True
|
25 |
intents.guild_messages = True
|
26 |
|
27 |
-
#
|
28 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
|
29 |
|
30 |
-
# YouTube API
|
31 |
API_KEY = os.getenv("YOUTUBE_API_KEY")
|
32 |
youtube_service = build('youtube', 'v3', developerKey=API_KEY)
|
33 |
|
34 |
-
#
|
35 |
SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
36 |
|
37 |
-
#
|
38 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
|
39 |
|
40 |
-
#
|
41 |
MAX_RETRIES = 3
|
42 |
|
43 |
class MyClient(discord.Client):
|
@@ -49,14 +49,14 @@ class MyClient(discord.Client):
|
|
49 |
async def on_ready(self):
|
50 |
logging.info(f'{self.user}๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค!')
|
51 |
|
52 |
-
#
|
53 |
subprocess.Popen(["python", "web.py"])
|
54 |
logging.info("Web.py ์๋ฒ๊ฐ ์์๋์์ต๋๋ค.")
|
55 |
|
56 |
-
#
|
57 |
self.session = aiohttp.ClientSession()
|
58 |
|
59 |
-
#
|
60 |
channel = self.get_channel(SPECIFIC_CHANNEL_ID)
|
61 |
if channel:
|
62 |
await channel.send("์ ํ๋ธ ๋น๋์ค URL์ ์
๋ ฅํ๋ฉด, ์๋ง๊ณผ ๋๊ธ์ ๊ธฐ๋ฐ์ผ๋ก ๋ต๊ธ์ ์์ฑํฉ๋๋ค.")
|
@@ -90,7 +90,7 @@ class MyClient(discord.Client):
|
|
90 |
)
|
91 |
|
92 |
async def close(self):
|
93 |
-
#
|
94 |
if self.session:
|
95 |
await self.session.close()
|
96 |
await super().close()
|
|
|
11 |
from youtube_transcript_api.formatters import TextFormatter
|
12 |
from dotenv import load_dotenv
|
13 |
|
14 |
+
# ํ๊ฒฝ ๋ณ์ ๋ก๋
|
15 |
load_dotenv()
|
16 |
|
17 |
+
# ๋ก๊น
์ค์
|
18 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s:%(message)s', handlers=[logging.StreamHandler()])
|
19 |
|
20 |
+
# ์ธํ
ํธ ์ค์
|
21 |
intents = discord.Intents.default()
|
22 |
intents.message_content = True
|
23 |
intents.messages = True
|
24 |
intents.guilds = True
|
25 |
intents.guild_messages = True
|
26 |
|
27 |
+
# ์ถ๋ก API ํด๋ผ์ด์ธํธ ์ค์
|
28 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
|
29 |
|
30 |
+
# YouTube API ์ค์
|
31 |
API_KEY = os.getenv("YOUTUBE_API_KEY")
|
32 |
youtube_service = build('youtube', 'v3', developerKey=API_KEY)
|
33 |
|
34 |
+
# ํน์ ์ฑ๋ ID
|
35 |
SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
36 |
|
37 |
+
# ์นํ
URL ์ค์
|
38 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
|
39 |
|
40 |
+
# ์ ์ก ์คํจ ์ ์ฌ์๋ ํ์
|
41 |
MAX_RETRIES = 3
|
42 |
|
43 |
class MyClient(discord.Client):
|
|
|
49 |
async def on_ready(self):
|
50 |
logging.info(f'{self.user}๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค!')
|
51 |
|
52 |
+
# web.py ํ์ผ ์คํ
|
53 |
subprocess.Popen(["python", "web.py"])
|
54 |
logging.info("Web.py ์๋ฒ๊ฐ ์์๋์์ต๋๋ค.")
|
55 |
|
56 |
+
# aiohttp ํด๋ผ์ด์ธํธ ์ธ์
์์ฑ
|
57 |
self.session = aiohttp.ClientSession()
|
58 |
|
59 |
+
# ๋ด์ด ์์๋ ๋ ์๋ด ๋ฉ์์ง๋ฅผ ์ ์ก
|
60 |
channel = self.get_channel(SPECIFIC_CHANNEL_ID)
|
61 |
if channel:
|
62 |
await channel.send("์ ํ๋ธ ๋น๋์ค URL์ ์
๋ ฅํ๋ฉด, ์๋ง๊ณผ ๋๊ธ์ ๊ธฐ๋ฐ์ผ๋ก ๋ต๊ธ์ ์์ฑํฉ๋๋ค.")
|
|
|
90 |
)
|
91 |
|
92 |
async def close(self):
|
93 |
+
# aiohttp ํด๋ผ์ด์ธํธ ์ธ์
์ข
๋ฃ
|
94 |
if self.session:
|
95 |
await self.session.close()
|
96 |
await super().close()
|