
    iw                     X    S SK JrJr  S SKrS SKJrJr  S SKJr  S SKJr   " S S5      rg)    )AsyncGeneratorOptionalN)rawenums)types)utilsc                       \ rS rSrS\R
                  R                  SSSS4SSS\SS	S
\\	   S\\	   S\\	   S\
S\S   4S jjrSrg)SearchGlobal    Nr   selfzpyrogram.Clientqueryfilterzenums.MessagesFilterchannels_onlygroups_only
users_onlylimitreturn)ztypes.MessageNc                  #    Sn[        U5      =(       d    Sn[        SU5      nSn	[        R                  R	                  5       n
Sn [
        R                  " U U R                  [        R                  R                  R                  UUR                  5       SSU	U
UUUUUS9SS9I Sh  vN SS9I Sh  vN nU(       d  gUS	   n[
        R                  " UR                  5      n	U R                  UR                  R                   5      I Sh  vN n
UR                   nU H  nU7v   US
-  nXx:  d  M    g   M   N N N07f)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.

    channels_only (``bool``, *optional*):
        Pass True to search only in channels.

    groups_only (``bool``, *optional*):
        Pass True to search only in groups.

    users_only (``bool``, *optional*):
        Pass True to search only in users.

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_idbroadcasts_onlyr   r   r   <   )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   r   r   r   currenttotaloffset_dater   r   r)   lastmessages                  T/app/mltbenv/lib/python3.13/site-packages/pyrogram/methods/messages/search_global.pysearch_globalSearchGlobal.search_global   s@    t E
'wCii..0	"11kkMM**77%||~!"!"$/$/"+(5$/#-# 8  %' "    % H* B<D55dii@K $ 1 1$)),, ??KI#1# $? 6 @s=   B'E)D;
*
E4D=5AED?"E5E=E?E )__name__
__module____qualname____firstlineno__r   MessagesFilterEMPTYstrr   boolintr   r6   __static_attributes__r8       r5   r
   r
      s     ).)=)=)C)C(,&*%)hhh 'h  ~	h
 d^h TNh h 
-	.h hrC   r
   )	typingr   r   pyrogramr   r   r   r   r
   r8   rC   r5   <module>rF      s"   & ,    i irC   