skip to Main Content

How Use Telegram API in C# With SharpTelegram
i use this
seed message to phone number have telegram in c#
i need sample use of this lib tanx



  1. You might want to take a look at this C# telegram Library instead:

    Also you might want to get started on learning their API and building your own library from scratch.

    Here are some notes to get you started:


    Login or Signup to reply.
  2. With C# telegram Library at
    TLSharpTests.cs contains examples:

        public async Task ImportContactByPhoneNumberAndSendMessage()
            // User should be already authenticated!
            var store = new FileSessionStore();
            var client = new TelegramClient(store, "session");
            await client.Connect();
            var res = await client.ImportContactByPhoneNumber(NumberToSendMessage);
            await client.SendMessage(res.Value, "Test message from TelegramClient");
    Login or Signup to reply.
  3. There is now WTelegramClient, using the latest Telegram Client API protocol (connecting as a user, not bot).

    The library is very complete but also very easy to use. Follow the README on GitHub for an easy introduction.

    To send a message to someone can be as simple as:

    using TL;
    using var client = new WTelegram.Client(); // or Client(Environment.GetEnvironmentVariable)
    await client.LoginUserIfNeeded();
    var result = await client.Contacts_ImportContacts(new[] { new InputPhoneContact { phone = "+PHONENUMBER" } });
    await client.SendMessageAsync(result.users[result.imported[0].user_id], "Hello");
    //or by username:
    //var result = await client.Contacts_ResolveUsername("USERNAME");
    //await await client.SendMessageAsync(result.User, "Hello");
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top