diff --git a/Searching-messages.md b/Searching-messages.md new file mode 100644 index 0000000..2d43ee2 --- /dev/null +++ b/Searching-messages.md @@ -0,0 +1,14 @@ +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: +```python +result = client(SearchRequest( + entity, 'query', InputMessagesFilterEmpty(), None, None, 0, 0, 100 +)) +``` + +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. + +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