I use WTelgramClient to remind patients about an upcoming doctor’s appointment.
I am sending a message and I need to make sure that it is read.
using var client = new WTelegram.Client(Config);
var user = await client.LoginUserIfNeeded();
var contact = await client.Contacts_ImportContacts(new[] { new InputPhoneContact { phone = phoneNumber } });
object p = await client.SendMessageAsync(contact.users[contact.users.Keys.First()], patientMessage);
It seems that this can be done via flag
has_views
. I tried the code below, but I can’t call dialogs.messages[0].flag.has_views
.
var dialogs = await client.Messages_GetAllDialogs();
Console.WriteLine(dialogs.messages[0]);
2
Answers
First, you should store the user info and the sent message info like this:
Later, you can check that the matching
Dialog.read_outbox_max_id
indicate your message was read, like this:Alternatively, if your program is running in the background, it can monitor updates in realtime, waiting for an UpdateReadHistoryOutbox that matches the targetUser.id and a max_id >= msg.id
Probably you should add a listener for events OnUpdate that is available from the client:
and check if there is any event of type: UpdateReadMessagesContents from where you can get the ids of read messages.
I hope it will help