alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
631 stars 117 forks source link

Error when trying 'channels.inviteToChannel' #259

Open Doogiemuc opened 2 years ago

Doogiemuc commented 2 years ago

I am trying to invite a few users into my channel. I am successfully logged in. And I am the admin of my channel.

// This is the channel that I want to invite to. It's a real announcement only channel. Not a chat group
let channel = {
    _: 'inputChannel',
    channel_id: '167XXXXX',
    access_hash: '15945224XXX',
    title: 'My channel'
}
let users = [
    {
      _: 'inputUser',
      user_id: '24977XXXX',
      access_hash: '160550485622700XXX'
    },
    {
      _: 'inputUser',
      user_id: '503XXXXXXXX',
      access_hash: '150113XXXXXXXX'
    }
]

let updates = await api.call("channels.inviteToChannel", {
  channel: channel,
  users: users
})

This throws the error:

{ _: 'mt_rpc_error', error_code: 400, error_message: 'USERS_TOO_MUCH' }

But there are only 200 users in my channel???? And I am only trying to add two new ones via API.

Is the format of my inputUser correct? Is the format of my users array correct? The API expects a 'vector'? Another issue says, in Javascript that's just simply an array? What am I doing wrong?

Doogiemuc commented 2 years ago

ok, seems my code actually IS correct. Just needed to retry the next day then it worked.

.... exactly once ...

now I am stuck in FLOOD_WAIT_1760 :-( But that was expected .... :-) let's see what we can do there ....