PEER_ID_INVALID when sending message to new user

2.6k views Asked by At

How i can send message to new user via WTelegramClient?

var peer = new InputPeerUser(user.id,user.access_hash);
await _client.SendMessageAsync(peer, "hello");

it returns peer_id_invalid. Why?

1

There are 1 answers

0
Wizou On

It depends where the user id/access_hash are coming. A user access_hash is valid only on the logged-in account it was retrieved from.

Also, with WTelegramClient, you do not need to build InputPeerUser manually, just pass a User object where an InputPeerUser is expected, and that structure will be created for you implicitly.

So the solution is to fetch the User structure you want, using any API calls or Updates monitoring, and use that User on your SendMessageAsync call.

For more information, read this FAQ