seawolf2357 commited on
Commit
8d6074f
Β·
verified Β·
1 Parent(s): df8b20e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -37,31 +37,34 @@ class MyClient(discord.Client):
37
  await channel.send("μ €λŠ” 이미지 생성을 μˆ˜ν–‰ν•  수 있으며, μƒμ„±λœ 이미지에 λŒ€ν•œ μ„€λͺ…을 ν•œκΈ€λ‘œ μ œκ³΅ν•˜κ³  μƒν˜Έ λŒ€ν™”λ₯Ό ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 'ν”„λ‘¬ν”„νŠΈμ— ν•œκΈ€ λ˜λŠ” μ˜λ¬Έμ„ μž…λ ₯ ν•˜μ„Έμš”.")
38
 
39
  async def on_message(self, message):
40
- if message.author == self.user:
 
 
 
 
41
  return
42
 
43
- # λ©”μ‹œμ§€μ—μ„œ '!'λ₯Ό κΈ°μ€€μœΌλ‘œ λͺ…령어와 ν”„λ‘¬ν”„νŠΈ 뢄리
44
  if message.content.startswith('!'):
45
  command, *prompt_parts = message.content.split(' ')
46
  prompt = ' '.join(prompt_parts)
47
  else:
48
  prompt = message.content # λͺ…λ Ήμ–΄ 없이 ν”„λ‘¬ν”„νŠΈλ§Œ 있으면 κ·ΈλŒ€λ‘œ μ‚¬μš©
49
-
50
  if self.is_processing:
51
  await message.channel.send("이미지 생성이 이미 μ§„ν–‰ μ€‘μž…λ‹ˆλ‹€. μž μ‹œλ§Œ κΈ°λ‹€λ € μ£Όμ„Έμš”.")
52
  return
53
-
54
  self.is_processing = True
55
  try:
56
  image_path, used_seed, translated_prompt = await self.generate_image(prompt)
57
  user_id = message.author.id
58
  await message.channel.send(
59
- content=f"<@{user_id}> λ‹˜μ΄ μš”μ²­ν•˜μ‹  μ΄λ―Έμ§€μž…λ‹ˆλ‹€.\nμ‚¬μš©λœ μ‹œλ“œ: {used_seed}\n",
60
  file=discord.File(image_path)
61
- )
62
-
63
 
64
- # 이미지 생성 ν›„ μ„€λͺ… 제곡 및 λŒ€ν™”
65
  await initiate_conversation(prompt, message)
66
  except RuntimeError as e:
67
  await message.channel.send(f"이미지 생성 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}")
@@ -71,6 +74,7 @@ class MyClient(discord.Client):
71
  finally:
72
  self.is_processing = False
73
 
 
74
 
75
  async def generate_image(self, prompt):
76
  if not prompt:
 
37
  await channel.send("μ €λŠ” 이미지 생성을 μˆ˜ν–‰ν•  수 있으며, μƒμ„±λœ 이미지에 λŒ€ν•œ μ„€λͺ…을 ν•œκΈ€λ‘œ μ œκ³΅ν•˜κ³  μƒν˜Έ λŒ€ν™”λ₯Ό ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 'ν”„λ‘¬ν”„νŠΈμ— ν•œκΈ€ λ˜λŠ” μ˜λ¬Έμ„ μž…λ ₯ ν•˜μ„Έμš”.")
38
 
39
  async def on_message(self, message):
40
+ # μ§€μ •λœ 채널 ID
41
+ TARGET_CHANNEL_ID = 1269529561914413106
42
+
43
+ # λ©”μ‹œμ§€κ°€ μ§€μ •λœ μ±„λ„μ—μ„œ μ˜€μ§€ μ•Šμ•˜κ±°λ‚˜ 봇 μžμ‹ μ˜ λ©”μ‹œμ§€μΈ 경우 λ¬΄μ‹œ
44
+ if message.channel.id != TARGET_CHANNEL_ID or message.author == self.user:
45
  return
46
 
47
+ # λ©”μ‹œμ§€μ—μ„œ '!'λ₯Ό κΈ°μ€€μœΌλ‘œ λͺ…령어와 ν”„λ‘¬ν”„νŠΈ 뢄리
48
  if message.content.startswith('!'):
49
  command, *prompt_parts = message.content.split(' ')
50
  prompt = ' '.join(prompt_parts)
51
  else:
52
  prompt = message.content # λͺ…λ Ήμ–΄ 없이 ν”„λ‘¬ν”„νŠΈλ§Œ 있으면 κ·ΈλŒ€λ‘œ μ‚¬μš©
53
+
54
  if self.is_processing:
55
  await message.channel.send("이미지 생성이 이미 μ§„ν–‰ μ€‘μž…λ‹ˆλ‹€. μž μ‹œλ§Œ κΈ°λ‹€λ € μ£Όμ„Έμš”.")
56
  return
57
+
58
  self.is_processing = True
59
  try:
60
  image_path, used_seed, translated_prompt = await self.generate_image(prompt)
61
  user_id = message.author.id
62
  await message.channel.send(
63
+ content=f"<@{user_id}> λ‹˜μ΄ μš”μ²­ν•˜μ‹  μ΄λ―Έμ§€μž…λ‹ˆλ‹€.\nμ‚¬μš©λœ μ‹œλ“œ: {used_seed}\n",
64
  file=discord.File(image_path)
65
+ )
 
66
 
67
+ # 이미지 생성 ν›„ μ„€λͺ… 제곡 및 λŒ€ν™”
68
  await initiate_conversation(prompt, message)
69
  except RuntimeError as e:
70
  await message.channel.send(f"이미지 생성 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}")
 
74
  finally:
75
  self.is_processing = False
76
 
77
+
78
 
79
  async def generate_image(self, prompt):
80
  if not prompt: