V
V
vetsmen2018-09-30 21:25:32
JavaScript
vetsmen, 2018-09-30 21:25:32

How to add user to teelgram chat?

How to add a user to a telegram chat? There is a messages.addChatUser method, but it cannot add by username, it requires user_id and access_hash. Where can you get them?
I use telegram-mtproto library

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Kadun, 2018-09-30
@ZXZs

getUserID

async function getUserID() {
    const auth = await api.storage.get('user_auth')
    return auth.id || 0
  }

I didn’t find about access_hash, but there was something here.
const chatHistory = async chat => {
  const max = 400
  const limit = 100
  let offset = 0
  let full = [],
      messages = []
  do {
    const history = await telegram('messages.getHistory', {
      peer: {
        _          : 'inputPeerChannel',
        channel_id : chat.id,
        access_hash: chat.access_hash
      },
      max_id: offset,
      offset: -full.length,
      limit
    })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question