mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-24 10:23:44 +03:00
Created Searching messages (markdown)
parent
7c4c0cf2ab
commit
d35dcbff2d
14
Searching-messages.md
Normal file
14
Searching-messages.md
Normal file
|
@ -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`.
|
Loading…
Reference in New Issue
Block a user