fix(bym): BUG

- 修复了目录叠叠乐了
- 临时修复发收表情包会把指令一起发出来
This commit is contained in:
ycxom 2025-01-02 09:48:29 +08:00
parent c817a6d77d
commit 72e77947c3
3 changed files with 9 additions and 8 deletions

View file

@ -339,6 +339,7 @@ export class bym extends plugin {
const processed = await imageTool.processText(t, {
images: opt.images // 传入图片数组而不是单个图片
})
if (t.match(/^(GETIMG|DOWNIMG):/i)) continue
// 处理工具返回结果
if (processed && typeof processed === 'object') {

View file

@ -107,11 +107,11 @@ export async function downImg(e, image, t) {
}
const currentTime = moment().format("YYMMDDHHmmss");
const safeTag = kWord.replace(/[^a-zA-Z0-9\u4e00-\u9fa5-_]/g, '-');
const picPath = pathModule.join(PICTURES_DIR, 'pictures', `${currentTime}-${safeTag.substring(0, 200)}.${picType}`);
const picPath = pathModule.join(PICTURES_DIR, `${currentTime}-${safeTag.substring(0, 200)}.${picType}`);
logger.mark("DOWNIMG", picPath);
if (!fs.existsSync(pathModule.join(PICTURES_DIR, 'pictures'))) {
fs.mkdirSync(pathModule.join(PICTURES_DIR, 'pictures'), { recursive: true });
if (!fs.existsSync(pathModule.join(PICTURES_DIR))) {
fs.mkdirSync(pathModule.join(PICTURES_DIR), { recursive: true });
}
fs.writeFileSync(picPath, imageBuffer);
logger.info(`图片已保存,标签为:${kWord}`);

View file

@ -36,7 +36,7 @@ export class ImageProcessTool extends AbstractTool {
this.initializeImageList()
}
async func(opts) {
func = async function (opts) {
const { action, imageName, imageData } = opts
try {
@ -109,7 +109,7 @@ export class ImageProcessTool extends AbstractTool {
handler: async (match) => {
const imageName = match[1].trim()
await this.handleGetImage(imageName)
return true
return null
}
},
notImage: {
@ -156,7 +156,7 @@ export class ImageProcessTool extends AbstractTool {
} else if (options.image) {
await this.handleDownloadImage(baseName, options.image)
}
return true
return null
}
},
list: {
@ -194,7 +194,7 @@ export class ImageProcessTool extends AbstractTool {
await this.e.reply(`未找到匹配的表情包: ${imageName}`)
}
return true // 表示已处理
return null
} catch (error) {
throw error
}
@ -208,7 +208,7 @@ export class ImageProcessTool extends AbstractTool {
const text = `DOWNIMG: ${imageName}`
await downImg(this.e, imageData, text)
await this.initializeImageList()
return true
return null
} catch (error) {
throw error
}