danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.74k stars 617 forks source link

inviteToChannel (This peer is not present in the internal peer database) #1466

Closed KarimQaderi closed 5 months ago

KarimQaderi commented 5 months ago

hi

v beta 188

error This peer is not present in the internal peer database

 $res = $this->madelineProto->channels->inviteToChannel(
        channel: '@channel',
        users: [id, id],
    );
danog commented 5 months ago

This error indicates that a specified peer (user, chat, channel) was not found in the internal MadelineProto peer database.

This can be because the user(bot) has never seen the peer before in the dialog list or in a chat.

This error can also be caused by an invalid ID, extracted manually from an update, instead of using the correct $this->getID($update) function.

This error can also be caused by referring to a user/chat/channel by its bot API ID, only if the (user)bot has never seen the peer before.
In this case, resolving a user/chat/channel @username with getInfo or importing an invite link with messages.importChatInvite, or (for users) enabling the setCacheAllPeersOnStartup setting will automatically cache the peer into the database, allowing you to use the bot API ID again.

KarimQaderi commented 5 months ago

@danog

I have already collected a list of ids and usernames(more than 4000), I want to add these people to the group and I still have a problem with the message.

would you be nice enough to explain it?