refactor(route/telegram): use log instead of console to resolve eslint issue
This commit is contained in:
parent
e9e0950692
commit
56d4c5e4e7
|
|
@ -1,6 +1,9 @@
|
|||
import { TelegramClient } from 'telegram';
|
||||
import { StringSession } from 'telegram/sessions/index.js';
|
||||
import readline from 'readline';
|
||||
import debug from 'debug';
|
||||
|
||||
const log = debug('telegram:session');
|
||||
|
||||
function userInput(question) {
|
||||
const rl = readline.createInterface({
|
||||
|
|
@ -16,7 +19,7 @@ function userInput(question) {
|
|||
}
|
||||
|
||||
async function getSessionString() {
|
||||
const apiId = parseInt(await userInput('Please enter your API ID: '));
|
||||
const apiId = Number.parseInt(await userInput('Please enter your API ID: '));
|
||||
const apiHash = await userInput('Please enter your API Hash: ');
|
||||
const stringSession = new StringSession('');
|
||||
const client = new TelegramClient(stringSession, apiId, apiHash, {
|
||||
|
|
@ -26,16 +29,16 @@ async function getSessionString() {
|
|||
phoneNumber: async () => await userInput('Please enter your phone number: '),
|
||||
password: async () => await userInput('Please enter your password: '),
|
||||
phoneCode: async () => await userInput('Please enter the code you received: '),
|
||||
onError: (err) => console.log(err),
|
||||
onError: (err) => log('Error:', err),
|
||||
});
|
||||
|
||||
console.log('You are now connected.');
|
||||
log('You are now connected.');
|
||||
const sessionString = client.session.save();
|
||||
log('Your session string is:', sessionString);
|
||||
|
||||
console.log('Your session string is:', sessionString);
|
||||
await client.disconnect();
|
||||
return sessionString;
|
||||
}
|
||||
|
||||
// Run the function
|
||||
getSessionString().catch(console.error);
|
||||
getSessionString().catch((error) => log('Error:', error));
|
||||
|
|
|
|||
|
|
@ -8819,7 +8819,7 @@ snapshots:
|
|||
|
||||
extract-zip@2.0.1:
|
||||
dependencies:
|
||||
debug: 4.3.4
|
||||
debug: 4.3.7
|
||||
get-stream: 5.2.0
|
||||
yauzl: 2.10.0
|
||||
optionalDependencies:
|
||||
|
|
@ -10536,7 +10536,7 @@ snapshots:
|
|||
proxy-agent@6.4.0:
|
||||
dependencies:
|
||||
agent-base: 7.1.1
|
||||
debug: 4.3.4
|
||||
debug: 4.3.7
|
||||
http-proxy-agent: 7.0.2
|
||||
https-proxy-agent: 7.0.5
|
||||
lru-cache: 7.18.3
|
||||
|
|
|
|||
Loading…
Reference in New Issue