2 Searching messages
Lonami edited this page 2018-06-25 09:32:24 +02:00

Use the search, filter or from_id parameters in client.get_messages:

# 10 messages containing "hello"
hello = client.get_messages(chat, 10, search='hello')

# 10 messages containing photos
from telethon.tl.types import InputMessagesFilterPhotos
photo = client.get_messages(chat, 10, filter=InputMessagesFilterPhotos)

# What's the total count of photos shared in this chat?
print(photo.total)