o
    -˜ŽjØ  ã                   @   sR   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„ dƒZdS )é    )ÚAsyncGeneratorÚOptionalN)ÚrawÚenums)Útypes)Úutilsc                   @   s\   e Zd Zdejjddddfdddeddd	ee d
ee dee de	dee
d  fdd„ZdS )ÚSearchGlobalÚ Nr   Úselfzpyrogram.ClientÚqueryÚfilterzenums.MessagesFilterÚchannels_onlyÚgroups_onlyÚ
users_onlyÚlimitÚreturn)ztypes.MessageNc                 C  sØ   �d}t |ƒpd}td|ƒ}d}	tj ¡ }
d}	 tj| | jtjj	j
|| ¡ dd|	|
|||||d�dd�I dH dd	�I dH }|sAdS |d
 }t |j¡}	|  |jj¡I dH }
|j}|D ]}|V  |d7 }||krj dS qZq)aT  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   T)Ú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Úmessage© r1   úd/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/messages/search_global.pyÚsearch_global   sR   €:

õ
òîÿÜzSearchGlobal.search_global)Ú__name__Ú
__module__Ú__qualname__r   ÚMessagesFilterÚEMPTYÚstrr   ÚboolÚintr   r3   r1   r1   r1   r2   r      s0    ùÿþýüûúù
ør   )	Útypingr   r   Úpyrogramr   r   r   r   r   r1   r1   r1   r2   Ú<module>   s   