I’m using TLSharp
to create a client for Telegram and i want to send messages to some telegram users.
i have their username
and userid
to use, but i can’t find a way to just use their username
to send them a message (although in telegram api you can do this but i couldn’t find a way to do it with TLSharp
), so i use their userid
to send them a message with this code:
await client.SendMessageAsync(new TLInputPeerUser() { user_id = someOneUserid }, "This is My Message");
this code works find with people that i have them in my contact list but with the others i got PEER_ID_INVALID
exception.
is there a way to add these people to contact list before sending them a message? or is there a way to just use their username
?
thanks in Advance.
2
Answers
Use this to import a list of contacts by mobile number:
Use this to resolve by username:
I know that the thread is not active anymore but for who viewing this page in future :
You need AccessHash to send message :
If you don’t know the access hash , just try to resolve the user with username or phone number. (TLUser class)
If you have the TLUser object you can use this :
Best regards.