Fallback for sending audio files

This commit is contained in:
Inex Code 2020-11-13 00:26:02 +00:00
parent 877804cf42
commit f3635581d5

View file

@ -278,7 +278,6 @@ export class VkPuppet {
source: {
value: data.url,
filename: data.filename,
contentType:
},
});
log.info("File sent", attachment);
@ -288,9 +287,18 @@ export class VkPuppet {
attachment: [`doc${attachment.ownerId}_${attachment.id}`],
});
await this.puppet.eventSync.insert(room, data.eventId!, response.toString());
} catch (err) {
try {
const response = await p.client.api.messages.send({
peer_id: Number(room.roomId),
message: `File ${data.filename} was sent, but VK refused to recieve it. You may download it there:\n${data.url}`,
random_id: new Date().getTime(),
});
await this.puppet.eventSync.insert(room, data.eventId!, response.toString());
} catch (err) {
log.error("Error sending to vk", err.error || err.body || err);
}
}
} else {
try {
const response = await p.client.api.messages.send({