Alireza Afzal Aghaei
Alireza Afzal Aghaei

Reputation: 1235

Get group media count in telethon

How can i get the number of sent media (photos,videos,voices,...) in a chat,group or channel using python telegram api library(telethon)?

I checked GetFullChannelRequest but it didn't get the number of media.

Upvotes: 3

Views: 2255

Answers (1)

Roberto
Roberto

Reputation: 61

Just fuond out: you need to use messages.SearchRequest. Example:

    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)

Upvotes: 6

Related Questions