[英]read a direct message when arrival using telegram_api
i am working with an app and it needs to read direct messages from telegram when they arrive.我正在使用一个应用程序,它需要在电报到达时从电报中读取直接消息。
i searched on google but all i got was how to send a message not how to read brand new dms.我在谷歌上搜索,但我得到的只是如何发送消息,而不是如何阅读全新的 dms。 Thanks!
谢谢!
Telethon: Make sure you read the basics in the Docs to understand how to handle events. Telethon:确保您阅读了文档中的基础知识以了解如何处理事件。
I'm assuming you meant "mark as read", if not, read the docs, else read below:我假设您的意思是“标记为已读”,如果不是,请阅读文档,否则请阅读以下内容:
in the event object you get to your callback, you have multiple unique convenience methods, and all the ones available on a Message
object, one of them is event.mark_read()在 object 事件中,您获得了回调,您有多个独特的便捷方法,并且
Message
object 中所有可用的方法,其中之一是 event.mark_read()
to limit it only to send read requests to private chats;将其限制为仅向私人聊天发送阅读请求; configure handler as needed, a minimal example:
根据需要配置处理程序,一个最小的例子:
@client.on(events.NewMessage(func=lambda e: e.is_private))
async def read_it_callback(event):
await event.mark_read()
you can also use client.你也可以使用客户端。
send_read_acknowledge()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.