Comments (23)
`const { MTProto } = require('@mtproto/core');
const prompt = require('prompt');
const mtproto = new MTProto({
api_id: 105,
api_hash: '85b728',
test: false,
});
const phone = '+91808';
const code = '2222';
// const password = 'hellojs';
function sendCode(phone) {
console.log("hello");
return mtproto.call('auth.sendCode', {
api_id: 1056,
api_hash: '85b72864f343b734',
// current_number: false,
phone_number: phone,
settings: {
_: 'codeSettings',
},
})
// .catch(error=>{console.log(error)});
}
sendCode(phone)
.catch(error => {
if (error.error_message.includes('MIGRATE')) {
const [type, nextDcId] = error.error_message.split('MIGRATE');
mtproto.setDefaultDc(+nextDcId);
return sendCode(phone).catch(error=>{console.log(error)});;
}
})
.then( result => {
f1(result.phone_code_hash);
})
async function f1(phone_code_hash){
prompt.start();
await prompt.get(['username'], async function (err, result) {
if (err) { console.log(err); }
else{
// console.log(phone,phone_code_hash,result.username);
// console.log(typeof(result.username));
const { user } = await mtproto.call('auth.signIn', {
phone_number : phone,
phone_code_hash: phone_code_hash,
phone_code : result.username
}).then(result => {
console.log("Logged:", result);
console.log("Logged:", result.user);
return result;
}).catch(error => {
console.log("ff")
console.log(error);
process.exit();
});
}
});
}
`
from mtproto-core.
how should i get the code?
from mtproto-core.
`const { MTProto } = require('@mtproto/core');
const prompt = require('prompt');const mtproto = new MTProto({
api_id: 105,
api_hash: '85b728',test: false,
});const phone = '+91808';
const code = '2222';
// const password = 'hellojs';function sendCode(phone) {
console.log("hello");
return mtproto.call('auth.sendCode', {
api_id: 1056,
api_hash: '85b72864f343b734',
// current_number: false,
phone_number: phone,
settings: {
_: 'codeSettings',
},
})
// .catch(error=>{console.log(error)});
}sendCode(phone)
.catch(error => {
if (error.error_message.includes('MIGRATE')) {
const [type, nextDcId] = error.error_message.split('MIGRATE');mtproto.setDefaultDc(+nextDcId); return sendCode(phone).catch(error=>{console.log(error)});;
}
})
.then( result => {
f1(result.phone_code_hash);})
async function f1(phone_code_hash){
prompt.start();
await prompt.get(['username'], async function (err, result) {
if (err) { console.log(err); }
else{
// console.log(phone,phone_code_hash,result.username);
// console.log(typeof(result.username));const { user } = await mtproto.call('auth.signIn', { phone_number : phone, phone_code_hash: phone_code_hash, phone_code : result.username }).then(result => { console.log("Logged:", result); console.log("Logged:", result.user);
return result;
}).catch(error => {
console.log("ff")
console.log(error);
process.exit();
});}
});
}`
hello
(node:17837) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'phone_code_hash' of undefined
from mtproto-core.
https://github.com/somgupta13/Telegram-API/blob/master/som.js
from mtproto-core.
https://github.com/somgupta13/Telegram-API/blob/master/som.js
same problem
from mtproto-core.
Do you have node 12version?
from mtproto-core.
Do you have node 12version?
node v12.16.2
npm 6.14.4
from mtproto-core.
code is working for me
from mtproto-core.
code is working for me
I should specify only api_id and api_hash and phone number?
from mtproto-core.
yes
from mtproto-core.
yes
а что-то еще должно быть установлено?
from mtproto-core.
are you recieving otp?
from mtproto-core.
are you recieving otp?
what is it?
from mtproto-core.
are you recieving the otp on telegram number
from mtproto-core.
i don't get anything
are you recieving the otp on telegram number
from mtproto-core.
type your mobile number in international format
from mtproto-core.
type your mobile number in international format
it is introduced in an international format
from mtproto-core.
https://github.com/somgupta13/Telegram-API/blob/master/som.js
try this i have updated else show your code
from mtproto-core.
https://github.com/somgupta13/Telegram-API/blob/master/som.js
try this i have updated else show your code
same problem
from mtproto-core.
- What version of the library do you use?
- Show your code
- Is Telegram blocked in your country? VPN enabled (try open telegram.org)?
from mtproto-core.
@kolko123 if you don't send an info by may 11 I'll close the issue
from mtproto-core.
Version 3.1.0 keep stuck on promise
ex:
client.call('auth.signIn', {
phone_number: state.phone_number,
phone_code_hash: state.phone_code_hash,
phone_code: state.code
}).then(message => {
console.log("Logged:", message); // never happen
return message; // never happen
}).catch(error => {
console.log(error);
process.exit();
});
On telegram app says that i logged.
from mtproto-core.
This error is probably fixed in version 3.1.1. View more: https://t.me/mtproto_core/17
from mtproto-core.
Related Issues (20)
- First example doesnt work
- Facing Invalid Channel Problem
- messages.getAllChats always retrun INPUT_METHOD_INVALID_2271179966_* HOT 21
- sendReaction throws error "REACTION_INVALID"
- channels.getForumTopics always return "Cannot read properties of undefined (reading 'call')" HOT 1
- IP white list method - amazon changer & checker - local server tunnel
- auth.sendCode method never returns HOT 1
- users.getFullUser behaves differently from different login
- How to set a new password using api.call('account.updatePasswordSettings') HOT 3
- "Not found predicate with id: .." results in RangeError. HOT 1
- Can't work with invite links, always getting INVITE_HASH_EXPIRED HOT 1
- api.call() doesn't return HOT 1
- setting net module Proxy
- messages.SendMessage not working as expected HOT 6
- Not getting updates about new messages HOT 6
- I want create one flux using this lib, but i dont know if this lib can make this
- It doesn't allow me to send messages
- mtproto node.js sdk reading of undefined resolve
- How to correctly destror api instance? HOT 4
- React Native/Expo Documentation/Support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtproto-core.