This commit is contained in:
手瓜一十雪 2024-08-10 22:40:40 +08:00
parent 08e679184b
commit e02bddc78f
2 changed files with 10 additions and 12 deletions

View File

@ -21,7 +21,7 @@ import {
import { promises as fs } from 'node:fs'; import { promises as fs } from 'node:fs';
import ffmpeg from 'fluent-ffmpeg'; import ffmpeg from 'fluent-ffmpeg';
import { calculateFileMD5, isGIF } from '@/common/utils/file'; import { calculateFileMD5, isGIF } from '@/common/utils/file';
import { defaultVideoThumb, getVideoInfo } from '@/common/utils/video'; import { getVideoInfo } from '@/common/utils/video';
import { encodeSilk } from '@/common/utils/audio'; import { encodeSilk } from '@/common/utils/audio';
import faceConfig from '@/core/external/face_config.json'; import faceConfig from '@/core/external/face_config.json';
import * as pathLib from 'node:path'; import * as pathLib from 'node:path';
@ -166,7 +166,7 @@ export class SendMsgElementConstructor {
} catch (e) { } catch (e) {
logger.logError('获取视频信息失败', e); logger.logError('获取视频信息失败', e);
} }
const createThumb = new Promise<string>((resolve, reject) => { const createThumb = new Promise<string | undefined>((resolve, reject) => {
const thumbFileName = `${md5}_0.png`; const thumbFileName = `${md5}_0.png`;
const thumbPath = pathLib.join(thumb, thumbFileName); const thumbPath = pathLib.join(thumb, thumbFileName);
ffmpeg(filePath) ffmpeg(filePath)
@ -179,9 +179,7 @@ export class SendMsgElementConstructor {
resolve(thumbPath); resolve(thumbPath);
}).catch(reject); }).catch(reject);
} else { } else {
fs.writeFile(thumbPath, defaultVideoThumb).then(() => { resolve(undefined);
resolve(thumbPath);
}).catch(reject);
} }
}) })
.screenshots({ .screenshots({
@ -195,10 +193,10 @@ export class SendMsgElementConstructor {
}); });
const thumbPath = new Map(); const thumbPath = new Map();
const _thumbPath = await createThumb; const _thumbPath = await createThumb;
const thumbSize = (await fs.stat(_thumbPath)).size; const thumbSize = _thumbPath ? (await fs.stat(_thumbPath)).size : 0;
// log("生成缩略图", _thumbPath) // log("生成缩略图", _thumbPath)
thumbPath.set(0, _thumbPath); thumbPath.set(0, _thumbPath);
const thumbMd5 = await calculateFileMD5(_thumbPath); const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : "";
const element: SendVideoElement = { const element: SendVideoElement = {
elementType: ElementType.VIDEO, elementType: ElementType.VIDEO,
elementId: '', elementId: '',

View File

@ -33,11 +33,11 @@ export class NapCatOneBot11Adapter {
msgListener.onInputStatusPush = async data => { msgListener.onInputStatusPush = async data => {
const uin = await this.core.ApiContext.UserApi.getUinByUidV2(data.fromUin); const uin = await this.core.ApiContext.UserApi.getUinByUidV2(data.fromUin);
this.context.logger.log(`[Notice] [输入状态] ${uin} ${data.statusText}`); this.context.logger.log(`[Notice] [输入状态] ${uin} ${data.statusText}`);
this.networkManager.emitEvent(new OB11InputStatusEvent( // this.networkManager.emitEvent(new OB11InputStatusEvent(
parseInt(uin), // parseInt(uin),
data.eventType, // data.eventType,
data.statusText // data.statusText
)); // ));
}; };
} }
} }