seawolf2357 commited on
Commit
262fbfb
โ€ข
1 Parent(s): 2db254d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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
- # Load environment variables
15
  load_dotenv()
16
 
17
- # Logging configuration
18
  logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s:%(message)s', handlers=[logging.StreamHandler()])
19
 
20
- # Intents configuration
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
- # Inference API client configuration
28
  hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
29
 
30
- # YouTube API configuration
31
  API_KEY = os.getenv("YOUTUBE_API_KEY")
32
  youtube_service = build('youtube', 'v3', developerKey=API_KEY)
33
 
34
- # Specific channel ID
35
  SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
36
 
37
- # Webhook URL configuration
38
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY1MDYzMjA0MzA1MjY4NTUzMDUxMzUi_pc"
39
 
40
- # Maximum retries for sending data
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
- # Start web.py
53
  subprocess.Popen(["python", "web.py"])
54
  logging.info("Web.py ์„œ๋ฒ„๊ฐ€ ์‹œ์ž‘๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
55
 
56
- # Create aiohttp client session
57
  self.session = aiohttp.ClientSession()
58
 
59
- # Send initial message when bot starts
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
- # Close aiohttp client session
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()