Spaces:
Running
Running
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ class MyClient(discord.Client):
|
|
46 |
self.is_processing = True
|
47 |
try:
|
48 |
response = await generate_response(message)
|
49 |
-
await message.channel
|
50 |
finally:
|
51 |
self.is_processing = False
|
52 |
|
@@ -92,6 +92,15 @@ async def generate_response(message):
|
|
92 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
93 |
return f"{user_mention}, {full_response_text}"
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
if __name__ == "__main__":
|
96 |
discord_client = MyClient(intents=intents)
|
97 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
|
|
46 |
self.is_processing = True
|
47 |
try:
|
48 |
response = await generate_response(message)
|
49 |
+
await send_long_message(message.channel, response)
|
50 |
finally:
|
51 |
self.is_processing = False
|
52 |
|
|
|
92 |
conversation_history.append({"role": "assistant", "content": full_response_text})
|
93 |
return f"{user_mention}, {full_response_text}"
|
94 |
|
95 |
+
async def send_long_message(channel, message):
|
96 |
+
"""Discord 메시지 길이가 2000자를 초과하는 경우, 이를 나누어 보냅니다."""
|
97 |
+
if len(message) <= 2000:
|
98 |
+
await channel.send(message)
|
99 |
+
else:
|
100 |
+
parts = [message[i:i+2000] for i in range(0, len(message), 2000)]
|
101 |
+
for part in parts:
|
102 |
+
await channel.send(part)
|
103 |
+
|
104 |
if __name__ == "__main__":
|
105 |
discord_client = MyClient(intents=intents)
|
106 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|