Skip to content

Commit

Permalink
feat: napcat 语音
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Dec 29, 2024
1 parent f12e33b commit 0cd317a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,18 @@ export default class ForwardService {
url = (refetchMessage.message.find(it => it.type === 'record') as PttElem).url;
}
if (url) {
let bufSilk: Buffer;
if (this.oicq instanceof NapCatClient) {
const ret = await this.oicq.callApi('download_file', { url });
bufSilk = await fsP.readFile(ret.file);
fsP.unlink(ret.file);
}
else {
bufSilk = await fetchFile(url);
}
const temp = await createTempFile({ postfix: '.ogg' });
tempFiles.push(temp);
await silk.decode(await fetchFile(url), temp.path);
await silk.decode(bufSilk, temp.path);
files.push(temp.path);
}
else {
Expand Down

0 comments on commit 0cd317a

Please sign in to comment.