Skip to content

Commit

Permalink
fix: remove require.main
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Mar 24, 2024
1 parent fbdfcd2 commit 18f50bb
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions lib/routes/telegram/tglib/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import readline from 'node:readline/promises';
import { Api, TelegramClient } from 'telegram';
import { UserAuthParams } from 'telegram/client/auth';
import { StringSession } from 'telegram/sessions';
Expand Down Expand Up @@ -187,20 +186,3 @@ function streamDocument(obj, thumbSize = '', offset, limit) {
}

export { client, getMediaLink, decodeMedia, getFilename, streamDocument, streamThumbnail };

if (require.main === module) {
Promise.resolve().then(async () => {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const client = await getClient(
{
phoneNumber: () => rl.question('Please enter your phone number: '),
password: () => rl.question('Please enter your password: '),
phoneCode: () => rl.question('Please enter the code you received: '),
onError: (err) => process.stderr.write(err.toString()),
},
''
);
process.stdout.write(`TELEGRAM_SESSION=${client.session.save()}\n`);
process.exit(0);
});
}

0 comments on commit 18f50bb

Please sign in to comment.