
    N[i@                     X    d dl mZmZ d dlZd dlmZmZ d dlmZ d dlmZ  G d d      Zy)    )AsyncGeneratorOptionalN)rawenums)types)utilsc                   d    e Zd Zdej                  j
                  dfdddeddded	ee	d
      f
dZ
y)SearchGlobal r   selfzpyrogram.Clientqueryfilterzenums.MessagesFilterlimitreturn)ztypes.MessageNc                t  K   d}t        |      xs d}t        d|      }d}t        j                  j	                         }d}	 t        j                  | | j                  t        j                  j                  j                  ||j                         dd||||      d       d{   d       d{   }	|	sy|	d	   }
t        j                  |
j                        }| j                  |
j                  j                          d{   }|
j                   }|	D ]  }| |d
z  }||k\  s y 7 7 7 -w)a#  Search messages globally from all of your chats.

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

        .. note::

            Due to server-side limitations, you can only get up to around ~10,000 messages and each message
            retrieved will not have any *reply_to_message* field.

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

        Parameters:
            query (``str``, *optional*):
                Text query string.
                Use "@" to search for mentions.
            
            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.

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

        Example:
            .. code-block:: python

                from pyrogram import enums

                # Search for "pyrogram". Get the first 50 results
                async for message in app.search_global("pyrogram", limit=50):
                    print(message.text)

                # Search for recent photos from Global. Get the first 20 results
                async for message in app.search_global(filter=enums.MessagesFilter.PHOTO, limit=20):
                    print(message.photo)
        r   l        d   )qr   min_datemax_dateoffset_rateoffset_peer	offset_idr   <   )sleep_thresholdN)replies   )absminr   r   InputPeerEmptyr   parse_messagesinvoke	functionsmessagesr
   valuedatetime_to_timestampdateresolve_peerchatid)r   r   r   r   currenttotaloffset_dater   r   r$   lastmessages               Z/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/messages/search_global.pysearch_globalzSearchGlobal.search_global   sA    \ E
'wCii..0	"11kkMM**77%||~!"!"$/$/"+# 8 	 %' "    H$ B<D55dii@K $ 1 1$)),, ??KI# 1e#9 0 @s=   B$D8&D2
'D84D45AD8D6	$D8.D84D86D8N)__name__
__module____qualname__r   MessagesFilterEMPTYstrintr   r   r1        r0   r
   r
      s]     ).)=)=)C)C	YYY 'Y 	Y
 
.!67	8Yr:   r
   )	typingr   r   pyrogramr   r   r   r   r
   r9   r:   r0   <module>r=      s"   & ,    Z Zr:   