fix preview
This commit is contained in:
parent
852c0e2803
commit
3e400cea39
11
src/bot.js
11
src/bot.js
@ -78,7 +78,9 @@ class TgBotSender {
|
||||
async sendVideo (chatId, data, settings = {}, apiOptions = {}) {
|
||||
if (this.parent.mtproto !== null) {
|
||||
const mtprotoMID = await this.parent.mtproto.saveMedia(
|
||||
data, settings.caption ?? ""
|
||||
data, settings.caption ?? "", {
|
||||
thumb: settings.thumb,
|
||||
}
|
||||
);
|
||||
|
||||
return await this.bot.copyMessage(
|
||||
@ -157,6 +159,7 @@ class TgBotSender {
|
||||
.then(async (downloaded) => {
|
||||
//console.debug("downloaded:", downloaded);
|
||||
try {
|
||||
const videoInfo = await video.getVideoInfo();
|
||||
if (downloaded.format.type === "video") {
|
||||
const filesize = (typeof isStream !== "string" || this.parent.mtproto !== null) ?
|
||||
0 : await getFileSize(downloaded.data);
|
||||
@ -170,7 +173,10 @@ class TgBotSender {
|
||||
await this.sendVideo(
|
||||
msg.chat.id,
|
||||
downloaded.data,
|
||||
{ caption: info.title },
|
||||
{
|
||||
caption: info.title,
|
||||
thumb: await downloadFile(videoInfo.thumbnail),
|
||||
},
|
||||
{
|
||||
filename,
|
||||
contentType: isStream === true ? "application/octet-stream" : downloaded.format.mime,
|
||||
@ -193,7 +199,6 @@ class TgBotSender {
|
||||
} MB)`);
|
||||
}
|
||||
} else if (downloaded.format.type === "audio") {
|
||||
const videoInfo = await video.getVideoInfo();
|
||||
await this.sendAudio(
|
||||
msg.chat.id,
|
||||
downloaded.data,
|
||||
|
||||
@ -32,7 +32,6 @@ class MTProtoUser {
|
||||
writeStream.on("error", reject);
|
||||
writeStream.on("finish", resolve);
|
||||
});
|
||||
//fs.writeFileSync();
|
||||
}
|
||||
|
||||
const msg = await this.client.sendFile(config.mtproto.chatId, {
|
||||
@ -41,6 +40,14 @@ class MTProtoUser {
|
||||
thumb: options.thumb,
|
||||
//filename: options.filename,
|
||||
supportsStreaming: true,
|
||||
attributes: [
|
||||
new Api.DocumentAttributeVideo({
|
||||
duration: options.duration || 0,
|
||||
w: options.width || 1280,
|
||||
h: options.height || 720,
|
||||
supportsStreaming: true
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
return msg.id;
|
||||
|
||||
@ -30,9 +30,6 @@ async function downloadFile (fileUrl) {
|
||||
|
||||
file.on("finish", () => {
|
||||
file.close();
|
||||
/*setTimeout(() => {
|
||||
fs.rm(savePath, () => {});
|
||||
}, 60000);*/
|
||||
resolve(savePath);
|
||||
});
|
||||
}).on("error", (err) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user