Skip to content

Commit

Permalink
feat: 群文件发送
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jul 16, 2024
1 parent fd01544 commit 22c9f7e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main/src/services/ForwardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,25 @@ export default class ForwardService {
chain.push('\n');
if ('gid' in pair.qq) {
useText('文件正在上传中…');
pair.qq.fs.upload(await message.downloadMedia({}), '/',
const file = await createTempFile();
tempFiles.push(file);
await message.downloadMedia({ outputFile: file.path });
pair.qq.fs.upload(file.path, '/',
fileNameAttribute ? fileNameAttribute.fileName : 'file')
.catch(err => pair.qq.sendMsg(`上传失败:\n${err.message}`));
.catch(err => {
message.reply({ message: `上传失败:\n${err.message}` });
posthog.capture('上传群文件失败', { error: err });
})
.finally(() => file.cleanup());
}
else if (pair.qq instanceof OicqFriend) {
useText('文件正在上传中…');
pair.qq.sendFile(await message.downloadMedia({}),
fileNameAttribute ? fileNameAttribute.fileName : 'file')
.catch(err => pair.qq.sendMsg(`上传失败:\n${err.message}`));
.catch(err => {
message.reply({ message: `上传失败:\n${err.message}` });
posthog.capture('上传好友文件失败', { error: err });
});
}
else {
await message.reply({
Expand Down

0 comments on commit 22c9f7e

Please sign in to comment.