feat: add exception handling

This commit is contained in:
0xMRTT 2023-06-08 20:38:15 +02:00
parent c027b2e6cc
commit 0281d1267d
Signed by: 0xMRTT
GPG Key ID: 910B287304120902

View File

@ -405,10 +405,16 @@ def run():
response = "".join(Completion.create(prompt))
try:
await bot.api.send_markdown_message(
room.room_id, f"> {prompt}\n\n{response}"
)
except Exception as e:
print(e)
await bot.api.send_markdown_message(
room.room_id, f"> {prompt}\n\n{e}"
)
@bot.listener.on_message_event
async def image(room, message):
match = botlib.MessageMatch(room, message, bot, PREFIX)
@ -473,6 +479,7 @@ def run():
return filename
try:
filename = await generate_image(prompt, style, ratio, negative)
@ -480,6 +487,12 @@ def run():
room_id=room.room_id,
image_filepath=filename)
except Exception as e:
print(e)
await bot.api.send_markdown_message(
room.room_id, f"> {prompt}\n\n{e}"
)
@bot.listener.on_message_event
async def bot_help(room, message):