seawolf2357 commited on
Commit
4aaa28c
β€’
1 Parent(s): accae84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -34,10 +34,11 @@ class MyClient(discord.Client):
34
  subprocess.Popen(["python", "web.py"])
35
  logging.info("Web.py server has been started.")
36
 
 
37
  async def on_message(self, message):
38
  if message.author == self.user:
39
  return
40
- if message.channel.id != SPECIFIC_CHANNEL_ID and not isinstance(message.channel, discord.Thread):
41
  return
42
  if self.is_processing:
43
  return
@@ -48,6 +49,13 @@ class MyClient(discord.Client):
48
  finally:
49
  self.is_processing = False
50
 
 
 
 
 
 
 
 
51
  async def generate_response(message):
52
  global conversation_history # μ „μ—­ λ³€μˆ˜ μ‚¬μš©μ„ λͺ…μ‹œ
53
  user_input = message.content
 
34
  subprocess.Popen(["python", "web.py"])
35
  logging.info("Web.py server has been started.")
36
 
37
+
38
  async def on_message(self, message):
39
  if message.author == self.user:
40
  return
41
+ if not self.is_message_in_specific_channel(message):
42
  return
43
  if self.is_processing:
44
  return
 
49
  finally:
50
  self.is_processing = False
51
 
52
+ def is_message_in_specific_channel(self, message):
53
+ # λ©”μ‹œμ§€κ°€ μ§€μ •λœ μ±„λ„μ΄κ±°λ‚˜, ν•΄λ‹Ή μ±„λ„μ˜ μ“°λ ˆλ“œμΈ 경우 True λ°˜ν™˜
54
+ return message.channel.id == SPECIFIC_CHANNEL_ID or (
55
+ isinstance(message.channel, discord.Thread) and message.channel.parent_id == SPECIFIC_CHANNEL_ID
56
+ )
57
+
58
+
59
  async def generate_response(message):
60
  global conversation_history # μ „μ—­ λ³€μˆ˜ μ‚¬μš©μ„ λͺ…μ‹œ
61
  user_input = message.content