fix(node): cli input for start() method, not run()

This commit is contained in:
teidesu 2021-07-18 22:08:50 +03:00
parent 199e0a2a7d
commit 8c62b56acc

View file

@ -89,10 +89,7 @@ export class NodeTelegramClient extends TelegramClient {
return new Promise((res) => this._rl!.question(text, res))
}
run(
params: Parameters<TelegramClient['start']>[0],
then?: (user: User) => void | Promise<void>
): void {
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 > ')
@ -100,13 +97,13 @@ export class NodeTelegramClient extends TelegramClient {
params.password = () => this.input('2FA password > ')
}
super.run(params, (user) => {
return super.start(params).then((user) => {
if (this._rl) {
this._rl.close()
delete this._rl
}
return then?.(user)
return user
})
}