Closed wasimjee closed 7 years ago
You should create an instance of TelegramClient
, subscribe to appropriate Update
event and then invoke Start
method. Afterwards all messages will be propagated through Update
event.
Any Sample code for creating update events please.
I'll be able to get you sample of code in the evening. But the main idea is that you subscribe to UpdateMessage
event and then if\else
on type of Updates
object. To know what could be there see descendants of Updates
class. Generally it should reflect these types from the documentation https://core.telegram.org/type/Updates
@steavy29 Thank you very much , i will be waiting for a sample.
Subscribe to event
client.UpdateMessage += UpdateMessage;
Handle update event
private void UpdateMessage(object sender, Updates update)
{
switch (update.Constructor)
{
case Constructor.updatesTooLong:
{
// need to download updates manually
break;
}
case Constructor.updateShortMessage:
{
var upd = update as UpdateShortMessageConstructor;
// upd.message
break;
}
case Constructor.updates:
{
var upd = update as UpdatesConstructor;
foreach (var updatePiece in upd.updates)
{
// handle update
}
break;
}
}
// ...
}
How can i receive a message from users