Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
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 (
|