Reputation: 47
How Use Telegram API in C# With SharpTelegram i use this https://github.com/Everbytes/SharpTL seed message to phone number have telegram in c# i need sample use of this lib tanx
Upvotes: 3
Views: 6982
Reputation: 1907
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");
Upvotes: 2
Reputation: 135
With C# telegram Library at https://github.com/sochix/TLSharp 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();
Assert.IsTrue(client.IsUserAuthorized());
var res = await client.ImportContactByPhoneNumber(NumberToSendMessage);
Assert.IsNotNull(res);
await client.SendMessage(res.Value, "Test message from TelegramClient");
}
Upvotes: 0
Reputation: 10866
You might want to take a look at this C# telegram Library instead: https://github.com/sochix/TLSharp
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: https://stackoverflow.com/a/32809138/44080
Cheers
Upvotes: 2