簡體   English   中英

如何檢測我在電報上的消息是否已使用 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() function 它給了我最后一條消息的 ID,而不是用戶最后閱讀的消息作為這里給出的評論

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM