fix: param mismatch in calling createValidSendXxxElement

This commit is contained in:
Wesley F. Young 2024-10-04 20:06:54 +08:00
parent fa3f61c68c
commit 60f0841a4b

View File

@ -14,6 +14,7 @@ import { OutgoingMessage, SendMessagePing } from '../types/action/message';
import { Bubble, Message as LaanaMessage, Peer as LaanaPeer, Peer_Type } from '../types/entity/message'; import { Bubble, Message as LaanaMessage, Peer as LaanaPeer, Peer_Type } from '../types/entity/message';
import { File } from '../types/entity/file'; import { File } from '../types/entity/file';
import faceConfig from '@/core/external/face_config.json'; import faceConfig from '@/core/external/face_config.json';
import { MessageContext } from '@/onebot/api';
export type SentMessageFileCacheRecord = { export type SentMessageFileCacheRecord = {
originalType: File['uri']['oneofKind'], originalType: File['uri']['oneofKind'],
@ -40,6 +41,14 @@ export class LaanaMessageUtils {
) { ) {
} }
// TODO: deprecate MessageContext
private createEmptyMessageContext(): MessageContext {
return {
deleteAfterSentFiles: [],
peer: { chatType: ChatType.KCHATTYPEC2C, guildId: '', peerUid: '' },
};
}
l2r: Laana2RawConverters = { l2r: Laana2RawConverters = {
bubble: async (msgContent, params) => { bubble: async (msgContent, params) => {
function at(atUid: string, atNtUid: string, atType: AtType, atName: string): SendTextElement { function at(atUid: string, atNtUid: string, atType: AtType, atName: string): SendTextElement {
@ -159,6 +168,7 @@ export class LaanaMessageUtils {
} else if (content.oneofKind === 'image') { } else if (content.oneofKind === 'image') {
const cacheId = await this.laana.utils.file.resolveCacheIdFromLaanaFile(content.image); const cacheId = await this.laana.utils.file.resolveCacheIdFromLaanaFile(content.image);
elements.push(await this.core.apis.FileApi.createValidSendPicElement( elements.push(await this.core.apis.FileApi.createValidSendPicElement(
this.createEmptyMessageContext(),
await this.laana.utils.file.toLocalPath(cacheId) await this.laana.utils.file.toLocalPath(cacheId)
)); ));
fileCacheRecords.push({ fileCacheRecords.push({
@ -178,6 +188,7 @@ export class LaanaMessageUtils {
return { return {
elements: [ elements: [
await this.core.apis.FileApi.createValidSendFileElement( await this.core.apis.FileApi.createValidSendFileElement(
this.createEmptyMessageContext(),
await this.laana.utils.file.toLocalPath(cacheId), await this.laana.utils.file.toLocalPath(cacheId),
msgContent.name, msgContent.name,
), ),
@ -194,6 +205,7 @@ export class LaanaMessageUtils {
return { return {
elements: [ elements: [
await this.core.apis.FileApi.createValidSendPicElement( await this.core.apis.FileApi.createValidSendPicElement(
this.createEmptyMessageContext(),
await this.laana.utils.file.toLocalPath(cacheId), await this.laana.utils.file.toLocalPath(cacheId),
msgContent.displayText, // TODO: make display text optional msgContent.displayText, // TODO: make display text optional
// TODO: add 'sub type' field // TODO: add 'sub type' field
@ -224,6 +236,7 @@ export class LaanaMessageUtils {
return { return {
elements: [ elements: [
await this.core.apis.FileApi.createValidSendVideoElement( await this.core.apis.FileApi.createValidSendVideoElement(
this.createEmptyMessageContext(),
await this.laana.utils.file.toLocalPath(cacheId), await this.laana.utils.file.toLocalPath(cacheId),
// TODO: add file name and thumb path // TODO: add file name and thumb path
), ),