Getting Started - roxxel/TeleSharp GitHub Wiki

Most basic client class:

public class Client
{
    private TelegramClient _client;
    public Client()
    {
        _client = new TelegramClient(new(
            "session", // SessionName (can be any ASCII string)
            "apiId" // ApiId of you application (Can be found here https://my.telegram.org/),
            "apiHash" // ApiHash of you application (Can be found here https://my.telegram.org/),
            "phoneNumber" // Your phone number,
            null // Bot token (optional, pass if you want to login as bot)
            ));
        _client.AuthorizationStateChanged += OnAuthorizationStateChanged;
    }
    public async Task StartAsync() => await _client.StartAsync();
    private async void OnAuthorizationStateChanged(object sender, Types.AuthorizationStateChangedEventArgs e)
    {
        // When telegram updates auth state this event is fired
        Console.WriteLine(e.State);
        if (e.State == Enums.AuthorizationState.Ready)
        {
            //Pass 0 to chatId if you want to send message to yourself
            // Please note that this only applies to methods on TelegramClient if you use RawClient pass actual chat id
            await _client.SendTextMessageAsync(chatId: 0, message: "I'm ready!");
        }
        await e.Respond(Console.ReadLine());
    }
}

Program.cs

var client = new Client();
await client.StartAsync();
await Task.Delay(-1);