mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
41 lines
8.4 KiB
HTML
41 lines
8.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>SearchRequest</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link id="style" href="../../css/docs.dark.css" rel="stylesheet">
|
|
<script>
|
|
document.getElementById("style").href = "../../css/docs."
|
|
+ (localStorage.getItem("theme") || "light")
|
|
+ ".css";
|
|
</script>
|
|
<link href="https://fonts.googleapis.com/css?family=Nunito|Source+Code+Pro"
|
|
rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<div id="main_div"><ul class="horizontal"><li><a href="../../index.html">API</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="../index.html">Methods</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="index.html">Messages</a></li><img src="../../img/arrow.svg" alt="/" /><li><a href="search.html">SearchRequest</a></li></ul><h1>SearchRequest</h1><p><strong>Only users</strong> can use this request. <a href="#examples">See code examples.</a></p><pre>---functions---
|
|
messages.search#29ee847a flags:# peer:<a href="../../types/input_peer.html">InputPeer</a> q:<a href="../../index.html#string">string</a> from_id:flags.0?<a href="../../types/input_peer.html">InputPeer</a> saved_peer_id:flags.2?<a href="../../types/input_peer.html">InputPeer</a> saved_reaction:flags.3?<a href="../../index.html#vector">Vector</a><<a href="../../types/reaction.html">Reaction</a>> top_msg_id:flags.1?<a href="../../index.html#int">int</a> filter:<a href="../../types/messages_filter.html">MessagesFilter</a> min_date:<a href="../../index.html#date">date</a> max_date:<a href="../../index.html#date">date</a> offset_id:<a href="../../index.html#int">int</a> add_offset:<a href="../../index.html#int">int</a> limit:<a href="../../index.html#int">int</a> max_id:<a href="../../index.html#int">int</a> min_id:<a href="../../index.html#int">int</a> hash:<a href="../../index.html#long">long</a> = <a href="../../types/messages/messages.html">messages.Messages</a></pre><button onclick="cp('from telethon.tl.functions.messages import SearchRequest');">Copy import to the clipboard</button><h3>Returns</h3><table><tr><td><a href="../../types/messages/messages.html">messages.Messages</a></td></tr></table><p>This type can be an instance of either:</p><table><tr><td><a href="../../constructors/messages/channel_messages.html">ChannelMessages</a></td><td><a href="../../constructors/messages/messages.html">Messages</a></td></tr><tr><td><a href="../../constructors/messages/messages_not_modified.html">MessagesNotModified</a></td><td><a href="../../constructors/messages/messages_slice.html">MessagesSlice</a></td></tr></table><h3>Parameters</h3><table><tr><td><b>peer</b></td><td style="text-align:center"><a href="../../types/input_peer.html">InputPeer</a></td><td>Anything entity-like will work if the library can find its <code>Input</code> version (e.g., usernames, <code>Peer</code>, <code>User</code> or <code>Channel</code> objects, etc.).</td></tr><tr><td><b>q</b></td><td style="text-align:center"><a href="../../index.html#string">string</a></td><td></td></tr><tr><td><b>filter</b></td><td style="text-align:center"><a href="../../types/messages_filter.html">MessagesFilter</a></td><td></td></tr><tr><td><b>min_date</b></td><td style="text-align:center"><a href="../../index.html#date">date</a></td><td></td></tr><tr><td><b>max_date</b></td><td style="text-align:center"><a href="../../index.html#date">date</a></td><td></td></tr><tr><td><b>offset_id</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>add_offset</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>limit</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>max_id</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>min_id</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td></td></tr><tr><td><b>hash</b></td><td style="text-align:center"><a href="../../index.html#long">long</a></td><td></td></tr><tr><td><b>from_id</b></td><td style="text-align:center"><a href="../../types/input_peer.html">InputPeer</a></td><td>This argument defaults to <code>None</code> and can be omitted. Anything entity-like will work if the library can find its <code>Input</code> version (e.g., usernames, <code>Peer</code>, <code>User</code> or <code>Channel</code> objects, etc.).</td></tr><tr><td><b>saved_peer_id</b></td><td style="text-align:center"><a href="../../types/input_peer.html">InputPeer</a></td><td>This argument defaults to <code>None</code> and can be omitted. Anything entity-like will work if the library can find its <code>Input</code> version (e.g., usernames, <code>Peer</code>, <code>User</code> or <code>Channel</code> objects, etc.).</td></tr><tr><td><b>saved_reaction</b></td><td style="text-align:center"><a href="../../types/reaction.html">Reaction</a></td><td>This argument defaults to <code>None</code> and can be omitted. Otherwise, a <span class="tooltip" title="Any iterable that supports len() will work too">list</span> must be supplied.</td></tr><tr><td><b>top_msg_id</b></td><td style="text-align:center"><a href="../../index.html#int">int</a></td><td>This argument defaults to <code>None</code> and can be omitted.</td></tr></table><h1>Known RPC errors</h1><p>This request can cause 9 known errors:</p><table><tr><td><code>ChatAdminRequiredError</code></td><td>Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group.</td></tr><tr><td><code>FromPeerInvalidError</code></td><td>The given from_user peer cannot be used for the parameter.</td></tr><tr><td><code>InputConstructorInvalidError</code></td><td>The provided constructor is invalid.</td></tr><tr><td><code>InputFilterInvalidError</code></td><td>The search query filter is invalid.</td></tr><tr><td><code>InputUserDeactivatedError</code></td><td>The specified user was deleted.</td></tr><tr><td><code>PeerIdInvalidError</code></td><td>An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations).</td></tr><tr><td><code>PeerIdNotSupportedError</code></td><td>The provided peer ID is not supported.</td></tr><tr><td><code>SearchQueryEmptyError</code></td><td>The search query is empty.</td></tr><tr><td><code>UserIdInvalidError</code></td><td>Invalid object ID for a user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited.</td></tr></table><p>You can import these from <code>telethon.errors</code>.</p><h1 id="examples">Example</h1><p>Please refer to the documentation of <a href="https://docs.telethon.dev/en/stable/modules/client.html#telethon.client.messages.MessageMethods.iter_messages"><code>client.iter_messages()</code></a> to learn about the parameters and see several code examples on how to use it.</p><p>The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.</p><details><pre><strong>from</strong> telethon.sync <strong>import</strong> TelegramClient
|
|
<strong>from</strong> telethon <strong>import</strong> functions, types
|
|
|
|
<strong>with</strong> TelegramClient(name, api_id, api_hash) <strong>as</strong> client:
|
|
result = client(functions.messages.SearchRequest(
|
|
peer=<em>'username'</em>,
|
|
q=<em>'some string here'</em>,
|
|
filter=types.InputMessagesFilterPhotos(),
|
|
min_date=datetime.datetime(2018, 6, 25),
|
|
max_date=datetime.datetime(2018, 6, 25),
|
|
offset_id=42,
|
|
add_offset=0,
|
|
limit=100,
|
|
max_id=0,
|
|
min_id=0,
|
|
hash=-12398745604826,
|
|
from_id=<em>'username'</em>,
|
|
saved_peer_id=<em>'username'</em>,
|
|
saved_reaction=[types.ReactionEmoji(
|
|
emoticon=<em>'some string here'</em>
|
|
)],
|
|
top_msg_id=42
|
|
))
|
|
print(result.stringify())</pre></details><textarea id="c" class="invisible"></textarea><script>function cp(t){var c=document.getElementById("c");c.value=t;c.select();try{document.execCommand("copy")}catch(e){}}</script></div><script>prependPath = "../../";</script><script src="../../js/search.js"></script></body></html> |