seawolf2357 commited on
Commit
6885f1d
·
verified ·
1 Parent(s): 341c469

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -39,18 +39,23 @@ class MyClient(discord.Client):
39
  logging.info("Web.py server has been started.")
40
 
41
  async def on_message(self, message):
42
- if message.author == self.user:
43
- return
44
- if not self.is_message_in_specific_channel(message):
45
- return
46
- if self.is_processing:
47
- return
48
- self.is_processing = True
49
- try:
50
- response = await generate_response(message)
51
- await message.channel.send(response)
52
- finally:
53
- self.is_processing = False
 
 
 
 
 
54
 
55
  def is_message_in_specific_channel(self, message):
56
  return message.channel.id == SPECIFIC_CHANNEL_ID or (
 
39
  logging.info("Web.py server has been started.")
40
 
41
  async def on_message(self, message):
42
+ logging.debug(f"Received message from {message.author}: {message.content}")
43
+ if message.author == self.user:
44
+ return
45
+ if not self.is_message_in_specific_channel(message):
46
+ logging.debug(f"Message not in specific channel: {message.channel}")
47
+ return
48
+ if self.is_processing:
49
+ logging.debug("Currently processing another message.")
50
+ return
51
+ self.is_processing = True
52
+ try:
53
+ response = await generate_response(message)
54
+ await message.channel.send(response)
55
+ except Exception as e:
56
+ logging.error(f"Error processing message: {e}", exc_info=True)
57
+ finally:
58
+ self.is_processing = False
59
 
60
  def is_message_in_specific_channel(self, message):
61
  return message.channel.id == SPECIFIC_CHANNEL_ID or (