Lalit Rajput
Lalit Rajput

Reputation: 301

How can i receive telegram message in C# using Telegram API

I am using this telegram C# library .I am able to send the messages but Couldn't find a way how to receive messages in this library. Please assist me.

Thanks in advance.

Upvotes: 0

Views: 11596

Answers (3)

Pedram
Pedram

Reputation: 313

I am not sure about this api you have mentioned, but if receiving messages is not supported in that one, I suggest using this one

I been using it since almost 1 year ago, I made a Fun bot for my university group where people can teach the bot what to answer to certain messages it receives. The usage is pretty simple and it have an example you can learn from.

You can also check my bot here and see its functionality.

Upvotes: 0

steavy
steavy

Reputation: 1576

I have this functionality(and many other) implemented in my fork

You need to create TelegramClient instance, subscribe to UpdateMessage event and call Start method.

var client = new TelegramClient(null/*sessionStore*/, apiId, apiHash);
client.UpdateMessage += (sender, updates) =>
{
      switch (updates.constructor)
      {
          case Constructor.UpdatesTooLong: { break; }
          case Constructor.UpdateShortMessage: { break; }
          case Constructor.UpdateShortChatMessage: { break; }
          case Constructor.UpdateShort: { break; }
          case Constructor.UpdatesCombined: { break; }
          case Constructor.Updates: { break; }
      }
};
await client.Start();

For list of possible Update object constructors see this

Upvotes: 1

brent
brent

Reputation: 1488

It looks like that library only supports some functionality, receiving is probably not supported as it isn't mentioned in the documentation and there is no test for it.

Upvotes: 1

Related Questions