Added offset_id parameter in search_messages method (#78)

* Update search_messages.py

Added offset_id
This commit is contained in:
Surendra9123 2024-07-08 18:29:05 +05:30 committed by GitHub
parent 7f55351d89
commit 7f6cf43db5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,6 +17,7 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union, List, AsyncGenerator, Optional
from datetime import datetime
import pyrogram
from pyrogram import raw, types, utils, enums
@ -29,7 +30,12 @@ async def get_chunk(
query: str = "",
filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY,
offset: int = 0,
offset_id: int = 0,
min_date: datetime = utils.zero_datetime(),
max_date: datetime = utils.zero_datetime(),
limit: int = 100,
min_id: int = 0,
max_id: int = 0,
from_user: Union[int, str] = None
) -> List["types.Message"]:
r = await client.invoke(
@ -37,13 +43,13 @@ async def get_chunk(
peer=await client.resolve_peer(chat_id),
q=query,
filter=filter.value(),
min_date=0,
max_date=0,
offset_id=0,
min_date=utils.datetime_to_timestamp(min_date),
max_date= utils.datetime_to_timestamp(max_date),
offset_id=offset_id,
add_offset=offset,
limit=limit,
min_id=0,
max_id=0,
min_id=min_id,
max_id=max_id,
from_id=(
await client.resolve_peer(from_user)
if from_user
@ -64,6 +70,11 @@ class SearchMessages:
chat_id: Union[int, str],
query: str = "",
offset: int = 0,
offset_id: int = 0,
min_date: datetime = utils.zero_datetime(),
max_date: datetime = utils.zero_datetime(),
min_id: int = 0,
max_id: int = 0,
filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY,
limit: int = 0,
from_user: Union[int, str] = None
@ -90,6 +101,21 @@ class SearchMessages:
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).
@ -133,6 +159,11 @@ class SearchMessages:
query=query,
filter=filter,
offset=offset,
offset_id=offset_id,
min_date=min_date,
max_date=max_date,
min_id=min_id,
max_id=max_id,
limit=limit,
from_user=from_user
)