
    i                     8   S SK JrJrJrJr  S SKJr  S SKrS SKJrJrJ	r	J
r
  S\
R                  R                  S S \	R                  " 5       \	R                  " 5       SS S SS4S\\\4   S\S	S
S\S\S\S\S\S\S\S\\\4   S\\   S\S   4S jjr " S S5      rg)    )UnionListAsyncGeneratorOptional)datetimeN)rawtypesutilsenums d   chat_idqueryfilterenums.MessagesFilteroffset	offset_idmin_datemax_datelimitmin_idmax_id	from_usermessage_thread_idreturntypes.Messagec                   #    U R                  [        R                  R                  R	                  U R                  U5      I S h  vN UUR                  5       [        R                  " U5      [        R                  " U5      UUUU	U
U(       a  U R                  U5      I S h  vN OS USS9SS9I S h  vN n[        R                  " XSS9I S h  vN $  N N4 N% N
7f)Nr   )peerqr   r   r   r   
add_offsetr   r   r   from_id
top_msg_idhash<   )sleep_threshold)replies)
invoker   	functionsmessagesSearchresolve_peervaluer
   datetime_to_timestampparse_messages)clientr   r   r   r   r   r   r   r   r   r   r   r   rs                 V/app/mltbenv/lib/python3.13/site-packages/pyrogram/methods/messages/search_messages.py	get_chunkr2      s      mm%%**733<<>00:11(;  )))444(# 	& 	
& )   	A. %%f;;;+ 4 5	. <sI   ACCAC#C $C4C5CCCCCCc                   *   \ rS rSrSSS\R
                  " 5       \R
                  " 5       SS\R                  R                  SSS4SSS\	\
\4   S\\   S	\\
   S
\\
   S\\   S\\   S\\
   S\\
   S\S   S\\
   S\	\
\4   S\\
   S\S   4S jjrSrg)SearchMessagesD   r   r   Nselfzpyrogram.Clientr   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   Nc                   #    Sn[        U
5      =(       d    Sn[        SU5      n
 [        U UUU	UUUUUUU
UUS9I Sh  vN nU(       d  gU[        U5      -  nU H  nU7v   US-  nX:  d  M    g   MO   N67f)a  Search for text and media messages inside a specific chat.

If you want to get the messages count only, see :meth:`~pyrogram.Client.search_messages_count`.

.. include:: /_includes/usable-by/users.rst

Parameters:
    chat_id (``int`` | ``str``):
        Unique identifier (int) or username (str) of the target chat.
        For your personal cloud (Saved Messages) you can simply use "me" or "self".
        For a contact that exists in your Telegram address book you can use his phone number (str).

    query (``str``, *optional*):
        Text query string.
        Required for text-only messages, optional for media messages (see the ``filter`` argument).
        When passed while searching for media messages, the query will be applied to captions.
        Defaults to "" (empty string).

    offset (``int``, *optional*):
        Sequential number of the first message to be returned.
        Defaults to 0.

    offset_id (``int``, *optional*):
        Identifier of the first message to be returned.

    min_date (:py:obj:`~datetime.datetime`, *optional*):
        Pass a date as offset to retrieve only older messages starting from that date.

    max_date (:py:obj:`~datetime.datetime`, *optional*):
        Pass a date as offset to retrieve only newer messages starting from that date.

    min_id (``int``, *optional*):
        If a positive value was provided, the method will return only messages with IDs more than min_id.

    max_id (``int``, *optional*):
        If a positive value was provided, the method will return only messages with IDs less than max_id.

    filter (:obj:`~pyrogram.enums.MessagesFilter`, *optional*):
        Pass a filter in order to search for specific kind of messages only.
        Defaults to any message (no filter).

    limit (``int``, *optional*):
        Limits the number of messages to be retrieved.
        By default, no limit is applied and all messages are returned.

    from_user (``int`` | ``str``, *optional*):
        Unique identifier (int) or username (str) of the target user you want to search for messages from.

    message_thread_id (``int``, *optional*):
        Unique identifier for the target message thread (topic) of the forum.
        For supergroups only.

Returns:
    ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.

Example:
    .. code-block:: python

        from pyrogram import enums

        # Search for text messages in chat. Get the last 120 results
        async for message in app.search_messages(chat_id, query="hello", limit=120):
            print(message.text)

        # Search for pinned messages in chat
        async for message in app.search_messages(chat_id, filter=enums.MessagesFilter.PINNED):
            print(message.text)

        # Search for messages containing "hello" sent by yourself in chat
        async for message in app.search_messages(chat, "hello", from_user="me"):
            print(message.text)
r   ir   )r/   r   r   r   r   r   r   r   r   r   r   r   r   N   )absminr2   len)r6   r   r   r   r   r   r   r   r   r   r   r   r   currenttotalr)   messages                    r1   search_messagesSearchMessages.search_messagesF   s     p E
+mC&#!!#"3 H  c(m#F#1# $- s   <A7A5,A7/A7 )__name__
__module____qualname____firstlineno__r
   zero_datetimer   MessagesFilterEMPTYr   intstrr   r   r   r?   __static_attributes__rA       r1   r4   r4   D   s'   
  " !#$',':':'<',':':'< ! !383G3G3M3M %)+/xxsCxx }x 	x
 C=x 8$x 8$x x x /0x }x c?x $C=x 
-	.x xrL   r4   )typingr   r   r   r   r   pyrogramr   r	   r
   r   rG   rH   rF   rI   rJ   r2   r4   rA   rL   r1   <module>rO      s  & 9 8   - - %*%9%9%?%?,,.,,.!%'+&<38_&< &< #	&<
 &< &< &< &< &< &< &< S#X&<  }&< 
/&<Rz zrL   