try to fix unidentified image error
This commit is contained in:
parent
ad6aff49b9
commit
2617d3257c
2 changed files with 14 additions and 4 deletions
|
@ -67,10 +67,19 @@ async def _(msg: Bot.MessageSession):
|
|||
if block['type'] == 'text':
|
||||
chain.append(Plain(block['content']))
|
||||
elif block['type'] == 'latex':
|
||||
chain.append(Image(PILImage.open(io.BytesIO(await generate_latex(block['content'])))))
|
||||
content = await generate_latex(block['content'])
|
||||
try:
|
||||
img = PILImage.open(io.BytesIO(content))
|
||||
chain.append(Image(img))
|
||||
except Exception as e:
|
||||
chain.append(Plain(msg.locale.t('ask.message.text2img.error', text=content)))
|
||||
elif block['type'] == 'code':
|
||||
chain.append(Image(PILImage.open(
|
||||
io.BytesIO(await generate_code_snippet(block['content']['code'], block['content']['language'])))))
|
||||
content = block['content']['code']
|
||||
try:
|
||||
chain.append(Image(PILImage.open(io.BytesIO(await generate_code_snippet(content,
|
||||
block['content']['language'])))))
|
||||
except Exception as e:
|
||||
chain.append(Plain(msg.locale.t('ask.message.text2img.error', text=content)))
|
||||
|
||||
if await check_bool(res):
|
||||
rickroll(msg)
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"ask.help": "通过 ChatGPT 回答问题。",
|
||||
"ask.help.regex": "问:<question> 通过 ChatGPT 回答问题",
|
||||
"ask.help.desc": "有事为什么不问问小可呢?",
|
||||
"ask.message.cooldown": "距离上次执行已过去 ${time} 秒,本命令的冷却时间为 60 秒。"
|
||||
"ask.message.cooldown": "距离上次执行已过去 ${time} 秒,本命令的冷却时间为 60 秒。",
|
||||
"ask.message.text2img.error": "错误:无法正确将以下内容转换为图片,尝试原文输出:\n${text}"
|
||||
}
|
||||
|
|
Reference in a new issue