Enhance image processing logic in message.js

Refactor image handling to support base64 and HTTP URLs.
This commit is contained in:
ikechan8370 2025-08-26 22:10:14 +08:00 committed by GitHub
parent 602e192bff
commit dc1ab30b6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -200,7 +200,14 @@ export async function toYunzai (e, contents) {
break
}
case 'image': {
msgs.push(segment.image((/** @type {import('chaite').ImageContent} **/ content).image))
const imageContent = (/** @type {import('chaite').ImageContent} **/ content).image
if (imageContent.startsWith('http')) {
msgs.push(segment.image(imageContent))
} else if (!imageContent.startsWith('base64')) {
msgs.push(`base64://${imageContent}`)
} else {
msgs.push(segment.image(imageContent))
}
break
}
case 'audio': {