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: { source: {
value: data.url, value: data.url,
filename: data.filename, filename: data.filename,
contentType:
}, },
}); });
log.info("File sent", attachment); log.info("File sent", attachment);
@ -288,9 +287,18 @@ export class VkPuppet {
attachment: [`doc${attachment.ownerId}_${attachment.id}`], attachment: [`doc${attachment.ownerId}_${attachment.id}`],
}); });
await this.puppet.eventSync.insert(room, data.eventId!, response.toString()); 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) { } catch (err) {
log.error("Error sending to vk", err.error || err.body || err); log.error("Error sending to vk", err.error || err.body || err);
} }
}
} else { } else {
try { try {
const response = await p.client.api.messages.send({ const response = await p.client.api.messages.send({