Skip to content

Commit 0b9679a

Browse files
dogwongnodegin
authored andcommitted
fix error while wait for code
1 parent 8d4a890 commit 0b9679a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tglib",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"author": "nodegin",
55
"license": "MIT",
66
"description": "TDLib (Telegram Database library) bindings for Node.js",

src/ClientBase.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,21 @@ class Client {
133133
}
134134
case 'authorizationStateWaitCode': {
135135
const payload = { '@type': 'checkAuthenticationCode' }
136-
if (!update['authorization_state']['is_registered']) {
137-
console.log(`User ${value} has not yet been registered with Telegram`)
138-
payload['first_name'] = await this.callbacks['td:getInput']({
139-
string: 'tglib.input.FirstName',
140-
})
141-
}
142136
payload['code'] = await this.callbacks['td:getInput']({
143137
string: 'tglib.input.AuthorizationCode',
144138
})
145139
this._send(payload)
146140
break
147141
}
142+
case 'authorizationStateWaitRegistration': {
143+
const payload = { '@type': 'registerUser' };
144+
console.log(`User has not yet been registered with Telegram`);
145+
payload['first_name'] = await this.callbacks['td:getInput']({
146+
string: 'tglib.input.FirstName',
147+
});
148+
this._send(payload);
149+
break
150+
}
148151
case 'authorizationStateWaitPassword': {
149152
this.authFlowPasswordHint = update['authorization_state']['password_hint']
150153
const password = await this.callbacks['td:getInput']({

0 commit comments

Comments
 (0)