diff --git a/Searching-messages.md b/Searching-messages.md index 2d43ee2..96d5ae0 100644 --- a/Searching-messages.md +++ b/Searching-messages.md @@ -1,14 +1,12 @@ -Messages are searched through the obvious [`SearchRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/search.html), but you may run into [issues](https://github.com/LonamiWebs/Telethon/issues/215). A valid example would be: +Use the `search`, `filter` or `from_id` parameters in [`client.get_messages`](http://telethon.readthedocs.io/en/latest/extra/advanced-usage/accessing-the-full-api.html): ```python -result = client(SearchRequest( - entity, 'query', InputMessagesFilterEmpty(), None, None, 0, 0, 100 -)) -``` +# 10 messages containing "hello" +hello = client.get_messages(chat, 10, search='hello') -It's important to note that the optional parameter `from_id` has been left omitted and thus defaults to `None`. Changing it to [`InputUserEmpty`](https://lonamiwebs.github.io/Telethon/constructors/input_user_empty.html), as one could think to specify "no user", won't work because this parameter is a flag, and it being unspecified has a different meaning. +# 10 messages containing photos +from telethon.tl.types import InputMessagesFilterPhotos +photo = client.get_messages(chat, 10, filter=InputMessagesFilterPhotos) -If one were to set `from_id=InputUserEmpty()`, it would filter messages from "empty" senders, which would likely match no users. - -If you get a `ChatAdminRequiredError` on a channel, it's probably because you tried setting the `from_id` filter, and as the error says, you can't do that. Leave it set to `None` and it should work. - -As with every method, make sure you use the right ID/hash combination for your `InputUser` or `InputChat`, or you'll likely run into errors like `UserIdInvalidError`. \ No newline at end of file +# What's the total count of photos shared in this chat? +print(photo.total) +``` \ No newline at end of file