|
@@ -233,6 +233,7 @@ interface FileToMediaInterface {
|
|
asImage?: boolean;
|
|
asImage?: boolean;
|
|
workers?: number;
|
|
workers?: number;
|
|
}
|
|
}
|
|
|
|
+
|
|
/** @hidden */
|
|
/** @hidden */
|
|
async function _fileToMedia(
|
|
async function _fileToMedia(
|
|
client: TelegramClient,
|
|
client: TelegramClient,
|
|
@@ -259,6 +260,7 @@ async function _fileToMedia(
|
|
return { fileHandle: undefined, media: undefined, image: undefined };
|
|
return { fileHandle: undefined, media: undefined, image: undefined };
|
|
}
|
|
}
|
|
const isImage = utils.isImage(file);
|
|
const isImage = utils.isImage(file);
|
|
|
|
+ console.log("as image?", isImage);
|
|
if (asImage == undefined) {
|
|
if (asImage == undefined) {
|
|
asImage = isImage && !forceDocument;
|
|
asImage = isImage && !forceDocument;
|
|
}
|
|
}
|
|
@@ -296,6 +298,15 @@ async function _fileToMedia(
|
|
|
|
|
|
if (file instanceof Api.InputFile || file instanceof Api.InputFileBig) {
|
|
if (file instanceof Api.InputFile || file instanceof Api.InputFileBig) {
|
|
fileHandle = file;
|
|
fileHandle = file;
|
|
|
|
+ } else if (
|
|
|
|
+ typeof file == "string" &&
|
|
|
|
+ (file.startsWith("https://") || file.startsWith("http://"))
|
|
|
|
+ ) {
|
|
|
|
+ if (asImage) {
|
|
|
|
+ media = new Api.InputMediaPhotoExternal({ url: file });
|
|
|
|
+ } else {
|
|
|
|
+ media = new Api.InputMediaPhotoExternal({ url: file });
|
|
|
|
+ }
|
|
} else if (!(typeof file == "string") || (await fs.lstat(file)).isFile()) {
|
|
} else if (!(typeof file == "string") || (await fs.lstat(file)).isFile()) {
|
|
if (typeof file == "string") {
|
|
if (typeof file == "string") {
|
|
createdFile = new CustomFile(
|
|
createdFile = new CustomFile(
|
|
@@ -327,12 +338,6 @@ async function _fileToMedia(
|
|
onProgress: progressCallback,
|
|
onProgress: progressCallback,
|
|
workers: workers,
|
|
workers: workers,
|
|
});
|
|
});
|
|
- } else if (file.startsWith("https://") || file.startsWith("http://")) {
|
|
|
|
- if (asImage) {
|
|
|
|
- media = new Api.InputMediaPhotoExternal({ url: file });
|
|
|
|
- } else {
|
|
|
|
- media = new Api.InputMediaPhotoExternal({ url: file });
|
|
|
|
- }
|
|
|
|
} else {
|
|
} else {
|
|
throw new Error(`"Not a valid path nor a url ${file}`);
|
|
throw new Error(`"Not a valid path nor a url ${file}`);
|
|
}
|
|
}
|
|
@@ -410,6 +415,7 @@ async function _fileToMedia(
|
|
image: asImage,
|
|
image: asImage,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
+
|
|
/** @hidden */
|
|
/** @hidden */
|
|
export async function sendFile(
|
|
export async function sendFile(
|
|
client: TelegramClient,
|
|
client: TelegramClient,
|