Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove remaining circular dependencies #28

Merged
merged 12 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unmom
  • Loading branch information
rojvv committed Nov 19, 2022
commit edfd5efbfb4f70936ef0ae0337e7243a55b8d399
14 changes: 10 additions & 4 deletions src/client/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export async function downloadFileV2(

export function downloadMedia(
client: AbstractTelegramClient,
messageOrMedia: Api.Message | Api.TypeMessageMedia,
messageOrMedia: CustomMessage | Api.Message | Api.TypeMessageMedia,
outputFile?: OutFile,
thumb?: number | Api.TypePhotoSize,
progressCallback?: ProgressCallback,
Expand All @@ -362,13 +362,19 @@ export function downloadMedia(
let media;

if (messageOrMedia instanceof Api.Message) {
const mom = new CustomMessage(messageOrMedia);
const message = new CustomMessage(messageOrMedia);
media = message.media;
date = message.date;
msgData = message.inputChat ? [message.inputChat, message.id] : undefined;
} else if (messageOrMedia instanceof CustomMessage) {
media = messageOrMedia.media;
date = messageOrMedia.date;
msgData = mom.inputChat ? [mom.inputChat, messageOrMedia.id] : undefined;
msgData = messageOrMedia.inputChat
? [messageOrMedia.inputChat, messageOrMedia.id]
: undefined;
} else {
media = messageOrMedia;
date = Date.now();
date = new Date().getTime();
}
if (typeof media == "string") {
throw new Error("not implemented");
Expand Down
2 changes: 1 addition & 1 deletion src/client/telegram_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class TelegramClient extends TelegramBaseClient
}

downloadMedia(
messageOrMedia: Api.Message | Api.TypeMessageMedia,
messageOrMedia: CustomMessage | Api.Message | Api.TypeMessageMedia,
downloadParams?: types.DownloadMediaInterface,
): Promise<Buffer | string | undefined> | Buffer {
return downloadMethods.downloadMedia(
Expand Down