From 18f50bb4daeffa01c48de5d69c05fb80800efd6d Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 24 Mar 2024 21:11:38 +0800 Subject: [PATCH] fix: remove require.main --- lib/routes/telegram/tglib/client.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lib/routes/telegram/tglib/client.ts b/lib/routes/telegram/tglib/client.ts index d135afb4587636..6d01710f96e3f9 100644 --- a/lib/routes/telegram/tglib/client.ts +++ b/lib/routes/telegram/tglib/client.ts @@ -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'; @@ -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); - }); -}