Reputation: 86
I sent multiple messages to my contacts on telegram using telethon but I didn't use this events to know if they are read directly so I want to check if my messages are read or not using other method
@client.on(events.MessageRead)
async def handler(event):
# Log when someone reads your messages
print('Someone has read all your messages until', event.max_id)
I read the full documentation and I can't find an answer is there anyway to know if the message is read or not using its id as example? cz even when I called get_dialogs() function it gives me the ID of last message and not the last read message by user as the comment given here
Upvotes: 2
Views: 1982
Reputation: 1069
Get the Dialog
where you sent the message
using GetPeerDialogsRequest()
, then if the read_outbox_max_id
property is equal or higher than the message.id
, the message has been read.
chat = 'INSERT_CHAT'
msg_id = (await client.send_message(chat, 'YOUR_TEXT')).id
# get the Dialog where you sent the message
result = await client(functions.messages.GetPeerDialogsRequest(
peers=[chat]
))
# check if the message has been read
if result.dialogs[0].read_outbox_max_id >= msg_id:
print('the message has been read')
else:
print('the message has not been read yet')
Upvotes: 4