I tried the TLSharp library, but it didn't work out.
Need to

  1. Send a message to a person (people in a group).
  2. Find out as soon as they wrote to me who wrote the text of the message.

How to implement this in a C # program? And then the examples from the network do not work for me.

  • The question has already been issued. More in detail, in a trace. article: habrahabr.ru/sandbox/103396 - Virgin Slavyanskaya
  • this is not a bot. I need a regular client for the user, not for the bot - Rakzin Roman
  • What did not suit you TLSharp? - 123_123
  • @ 123_123 so that if you take an example from the site in the line var user = result.users.lists is a mistake, it does not see users. And the fact that I do not know how to get a notification that I received a message? - Rakzin Roman

1 answer 1

Telegram has a peculiar API and TLSharp is of course damp. But writing your library will take a lot of time.

To begin, I would advise you to understand the API Telegram and the TL-scheme . Without this, the principle will be hard.

Before using the API, you need to register and get API_ID and API_HASH

Any changes to the telegram are contained in the Update objects. To receive a new message, an object intersects you.

 updateNewMessage#13abdb3 message:Message pts:int = Update; 

In TLSharpe, as I recall, they were not specially processed. But in the class TLSharp.Core.Network.MtProtoSender there is a method HandleUpdate In it you can get the Update you need.

There is an example in the documentation for sending a message.

 //get available contacts var result = await client.GetContactsAsync(); //find recipient in contacts var user = result.users.lists .Where(x => x.GetType() == typeof (TLUser)) .Cast<TLUser>() .FirstOrDefault(x => x.phone == "<recipient_phone>"); //send message await client.SendMessageAsync(new TLInputPeerUser() {user_id = user.id}, "OUR_MESSAGE"); 

If you have no contacts, you can add them.

 var userByPhoneId = await client.ImportContactByPhoneNumber("791812312323"); 

The current TL scheme can be viewed here . This is git web version.

  • What kind of language is this? and how to work with him? I looked at the atom and did not move in general, so that where to pull from it. What can I do with this scheme? If my prog on c # is for those not rummaging about it - Rakzin Roman
  • Wash them themselves have developed it. If you want to write for a telegram, you have to figure it out yourself. I can advise to read tlgrm.ru/docs#mtproto for understanding. - 123_123