feat: add exception handling
This commit is contained in:
parent
c027b2e6cc
commit
0281d1267d
@ -405,10 +405,16 @@ def run():
|
|||||||
|
|
||||||
response = "".join(Completion.create(prompt))
|
response = "".join(Completion.create(prompt))
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
await bot.api.send_markdown_message(
|
await bot.api.send_markdown_message(
|
||||||
room.room_id, f"> {prompt}\n\n{response}"
|
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
|
@bot.listener.on_message_event
|
||||||
async def image(room, message):
|
async def image(room, message):
|
||||||
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
||||||
@ -473,6 +479,7 @@ def run():
|
|||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
try:
|
||||||
filename = await generate_image(prompt, style, ratio, negative)
|
filename = await generate_image(prompt, style, ratio, negative)
|
||||||
|
|
||||||
|
|
||||||
@ -480,6 +487,12 @@ def run():
|
|||||||
room_id=room.room_id,
|
room_id=room.room_id,
|
||||||
image_filepath=filename)
|
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
|
@bot.listener.on_message_event
|
||||||
async def bot_help(room, message):
|
async def bot_help(room, message):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user