Well ... Other answers give examples from unstudied libraries. Therefore, you should not rely on these libraries.
: telegram.link
Telegram, telegram-mtproto
1. api_id api_hash
Telegram
2. :
npm install telegram-mtproto@beta --save
3. node.js api_id api_hash, Telegram phone number:
import MTProto from 'telegram-mtproto'
const phone = {
num : '+90555555555',
code: '22222'
}
const api = {
layer : 57,
initConnection : 0x69796de9,
api_id : 111111
}
const server = {
dev: true
}
const client = MTProto({ server, api })
async function connect(){
const { phone_code_hash } = await client('auth.sendCode', {
phone_number : phone.num,
current_number: false,
api_id : 111111,
api_hash : 'fb050b8fjernf323FDFWS2332'
})
const { user } = await client('auth.signIn', {
phone_number : phone.num,
phone_code_hash: phone_code_hash,
phone_code : phone.code
})
console.log('signed as ', user);
}
connect();
4. ( ! 👨🏻💻)
const telegram = require('./init')
const getChat = async () => {
const dialogs = await telegram('messages.getDialogs', {
limit: 50,
})
const { chats } = dialogs;
const selectedChat = await selectChat(chats);
return selectedChat;
}
, :