Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/wechat/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ export async function downloadImage(item: MessageItem): Promise<string | null> {

/**
* Extract text content from a message item.
* Returns text_item.text or empty string.
* Handles text items and voice items (using ASR transcription).
*/
export function extractText(item: MessageItem): string {
if (item.type === MessageItemType.VOICE) {
const voiceText = item.voice_item?.voice_text || item.voice_item?.text;
if (voiceText) {
return `[语音] ${voiceText}`;
}
}
return item.text_item?.text ?? '';
}

Expand Down
2 changes: 2 additions & 0 deletions src/wechat/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export interface ImageItem {

export interface VoiceItem {
cdn_media: CDNMedia;
media?: { encrypt_query_param: string; aes_key?: string };
voice_text?: string;
text?: string;
}

export interface FileItem {
Expand Down