Search code examples
c#telegramtelethontlsharp

How to get notified that new message is sent in specified telegram channel with TLSharp?


I need to handle new messages in specified channel of tg. I think that it is should be possible to do with TLSharp (or telethon on python), but I accept any other method or library.

I guess there should be a solution using client for tg RPC Api, but I can't find it. Appreciate your help!


Solution

  • TLSharp does not allow you to process incoming updates/messages as they come by.

    This is possible with WTelegramClient (.NET library available on Nuget) with the client.OnUpdate event.

    See here for a full example showing how to handle/display update/messages.
    You can then filter these update to show only those coming from a specific channel (see peer fields)

    Note: TLSharp is no longer maintained and doesn't work correctly anymore, so I would recommend switching to WTelegramClient anyway.