如何检测我在电报上的消息是否已使用 telethon 读取?

How to detect if my messages on telegram is already read using telethon?

我使用 telethon 通过电报向我的联系人发送了多条消息,但我没有使用此事件来了解它们是否被直接读取,所以我想使用其他方法检查我的消息是否被读取


@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)

我阅读了完整的文档,但找不到答案 是否可以知道消息是否已阅读或未使用其 ID 作为示例? cz 即使当我调用 get_dialogs() 函数时,它也会给我最后一条消息的 ID,而不是用户最后阅读的消息作为给定 here

的评论

获取您使用 GetPeerDialogsRequest() 发送 messageDialog,然后如果 read_outbox_max_id 属性 等于或高于 message.id, 留言已读

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')