Skip to content

immmdreza/ModernTLSharp

Repository files navigation

ModernTlSharp

A .Net Core 3.1 copy of TLSharp with extensions for easier use...

this project is a port of TLSharp

Differences

  • Changed target framework to .Net Core 3.1
  • Added Some extension methods and classes:
    • UpdateCatcher (This can help you receive updates immediately and returns TLDifference).
    • SendTextMessages (Can be useful to sent text messages to supergroups and private chats easily)
    • MakeSeen (To mark messages history readed)
    • Something more soon...

Install

Package Manager .Net Cli
Install-Package ModernTlSharp -Version 1.2.4 dotnet add package ModernTlSharp --version 1.2.4

Usage

After authorization you can call UpdateCatcher extension method and pass a callback function to handle Update (A of class of TLDifference) (here is UpdateCatched).

Also I add a MessageHandler method it easier to work with Update. you should change it depending on your need... (here we can handle texts from private and super-group chats in MessageHandler).

Update object contains every new updates that catched from telegram.

There is an example in project files (ModernTLSharp.Test)

Example

ConsoleAuthocate:

//var auth = new ModernTlSharp.TLSharp.Extensions.Authorization(TelegramClient,
//    "+12345678998");

//await auth.ConsoleAuthocate();

Authorization auth = new ModernTlSharp.TLSharp.Extensions.Authorization(TelegramClient);

await auth.ConsoleAuthocate();

UpdateCatcher:

static async Task Main()
{
    TelegramClient = new TelegramClient(API_ID, API_HASH);

    await TelegramClient.ConnectAsync();

    //var auth = new ModernTlSharp.TLSharp.Extensions.Authorization(TelegramClient,
    //    "+12345678998");

    //await auth.ConsoleAuthocate();

    Authorization auth = new ModernTlSharp.TLSharp.Extensions.Authorization(TelegramClient);

    await auth.ConsoleAuthocate();

    await TelegramClient.UpdateCatcher(UpdateCatched);
}

private static async Task UpdateCatched(Update arg)
{
    //handel updates here!
}

About

An improved copy of TLSharp for c#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages