微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Telethon 检索多个固定消息

如何解决使用 Telethon 检索多个固定消息

我正在尝试使用 Telethon 从使用以下代码的组下载多条固定消息:

from telethon import TelegramClient,types

async def getPinnedMessages():
    async with TelegramClient('MySession',api_id,api_hash) as client:
        messages = await client.get_messages('MyGroupChat',ids=types.InputMessagePinned())

问题是这仅返回一条消息,即使有多个固定消息。关于我在这里缺少什么的任何建议?谢谢。

解决方法

您需要使用InputMessagesFilterPinned

for message in client.iter_messages(chat,filter=types.InputMessagesFilterPinned()):
    ...  # use message

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。