Closed trizau closed 3 years ago
you can pass firstName and lastName params to start and it will use that to register a new account.
you can pass firstName and lastName params to start and it will use that to register a new account.
Thanks, it was my fault
Hello, I have same promblem, please show how you passed name parameters. My code:
await client.start({
phoneNumber: '+'+resp.number.toString(),
//phoneCode: async () => await sms.getCode(resp.id),
phoneCode: async () => await input.text('code:'),
firstName: 'Testname',
lastName: 'Testlastname',
onError: (err) => console.log(err),
});
After entering code facing error
CastError: Found wrong type for lastName. expected string but received undefined.If you think this is a mistake please report it.
at VirtualClass.assertType (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/api.js:353:43)
at VirtualClass.validate (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/api.js:299:30)
at VirtualClass.getBytes (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/api.js:360:26)
at new RequestState (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/network/RequestState.js:9:29)
at MTProtoSender.send (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/network/MTProtoSender.js:197:23)
at Object.invoke (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/users.js:27:44)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.signInUser (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:150:35)
at async _authFlow (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:338:11)
at async Object.start (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:41:5)
TypeError: Cannot read properties of undefined (reading 'constructor')
at serializeBytes (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/generationHelpers.js:238:60)
at argToBytes (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/api.js:105:20)
at VirtualClass.getBytes (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/tl/api.js:412:42)
at new RequestState (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/network/RequestState.js:9:29)
at MTProtoSender.send (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/network/MTProtoSender.js:197:23)
at Object.invoke (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/users.js:27:44)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.signInUser (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:150:35)
at async _authFlow (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:338:11)
at async Object.start (/home/navalny/PROJ/node/telegram_autoreger/node_modules/telegram/client/auth.js:41:5)
CastError: Found wrong type for lastName. expected string but received undefined.If you think this is a mistake please report it.
I used firstAndLastNames to set the username like this
await client.start({
phoneNumber: this.phone,
password: async () => {
// ...
},
phoneCode: () => {// if need verify code
// ...
},
onError: (err: Error) => {
// ...
},
firstAndLastNames: async () => {
return ['firstName','lastName']
}
});
I use these codes:
If the mobile phone number has not been registered, the following problems will be reported:
At this time, I must use
client.disconnect()
, otherwise it will continue to loop and cause memory leaks