fix(node): do not override .start()
This commit is contained in:
parent
d5d5615a4d
commit
343c925b72
3 changed files with 11 additions and 23 deletions
|
@ -31,7 +31,11 @@ tg.run(
|
|||
{{#if botToken}}
|
||||
{ botToken: env.BOT_TOKEN },
|
||||
{{else}}
|
||||
{},
|
||||
{
|
||||
phone: () => tg.input('Phone > '),
|
||||
code: () => tg.input('Code > '),
|
||||
password: () => tg.input('2FA password > '),
|
||||
},
|
||||
{{/if}}
|
||||
(user) => {
|
||||
console.log('Logged in as', user.username)
|
||||
|
|
|
@ -31,7 +31,11 @@ tg.run(
|
|||
{{#if botToken}}
|
||||
{ botToken: env.BOT_TOKEN },
|
||||
{{else}}
|
||||
{},
|
||||
{
|
||||
phone: () => tg.input('Phone > '),
|
||||
code: () => tg.input('Code > '),
|
||||
password: () => tg.input('2FA password > '),
|
||||
},
|
||||
{{/if}}
|
||||
(user) => {
|
||||
console.log('Logged in as', user.username)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createRequire } from 'module'
|
||||
import { createInterface, Interface as RlInterface } from 'readline'
|
||||
|
||||
import { TelegramClient, TelegramClientOptions, User } from '@mtcute/client'
|
||||
import { TelegramClient, TelegramClientOptions } from '@mtcute/client'
|
||||
import { HtmlMessageEntityParser } from '@mtcute/html-parser'
|
||||
import { MarkdownMessageEntityParser } from '@mtcute/markdown-parser'
|
||||
import { SqliteStorage } from '@mtcute/sqlite'
|
||||
|
@ -97,26 +97,6 @@ export class NodeTelegramClient extends TelegramClient {
|
|||
return new Promise((res) => this._rl?.question(text, res))
|
||||
}
|
||||
|
||||
start(params: Parameters<TelegramClient['start']>[0] = {}): Promise<User> {
|
||||
if (!params.botToken) {
|
||||
if (!params.phone) params.phone = () => this.input('Phone > ')
|
||||
if (!params.code) params.code = () => this.input('Code > ')
|
||||
|
||||
if (!params.password) {
|
||||
params.password = () => this.input('2FA password > ')
|
||||
}
|
||||
}
|
||||
|
||||
return super.start(params).then((user) => {
|
||||
if (this._rl) {
|
||||
this._rl.close()
|
||||
delete this._rl
|
||||
}
|
||||
|
||||
return user
|
||||
})
|
||||
}
|
||||
|
||||
close(): Promise<void> {
|
||||
this._rl?.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue