How to get my own telegram messages in node.js without bot

I would like to have a very simple client in nodejs (example) that can receive messages from my contacts in a telegram. I just searched the Internet, but I only get bot samples. I want to receive group messages in that I do not have access to give privileges to my bot, so I would like to know if I can receive my own messages without a bot as an intermediary.

+6
source share
3 answers

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', // basically it is your phone number
  code: '22222' // your 2FA code
}

const api = {
  layer          : 57,
  initConnection : 0x69796de9,
  api_id         : 111111
}

const server = {
  dev: true //We will connect to the test server.
}           //Any empty configurations fields can just not be specified

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, // obtain your api_id from telegram
    api_hash      : 'fb050b8fjernf323FDFWS2332' // obtain api_hash from telegram
  })
  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') // take a look at the init.js from the examples repo

const getChat = async () => {
  const dialogs = await telegram('messages.getDialogs', {
    limit: 50,
  })
  const { chats } = dialogs;
  const selectedChat = await selectChat(chats);

  return selectedChat;
}

, :

+8

Telegram (-, ..) , , API / , ( ).

, API -, , ... , - ...

+1

All Articles