【问题标题】:Get group media count in telethon获取电视节目中的群组媒体数量
【发布时间】:2021-05-06 13:44:58
【问题描述】:

如何使用 python 电报 api 库(telethon)在聊天、群组或频道中获取已发送媒体(照片、视频、语音...)的数量?

我检查了GetFullChannelRequest,但没有得到媒体数量。

【问题讨论】:

    标签: python telegram telethon


    【解决方案1】:

    请注意:您需要使用messages.SearchRequest。示例:

        from telethon.tl.functions.messages import SearchRequest
        from telethon.tl.types import InputMessagesFilterPhotos
        photos = client(SearchRequest(
            client.get_entity('XXXX'),    #   peer
            '',                           #   q
            InputMessagesFilterPhotos(),  #   filter
            None,                         #   min_date
            None,                         #   max_date
            0,                            #   offset_id
            0,                            #   add_offset
            0,                            #   limit
            0,                            #   max_id
            0,                            #   min_id
            0                             #   hash
            ))
        print(photos.count)
    

    【讨论】:

      猜你喜欢
      • 2022-09-27
      • 2015-08-08
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      • 2011-03-27
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多