Skip to content

Commit

Permalink
Add topic support in search_messages_count
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Oct 21, 2024
1 parent 232d9c5 commit 055d125
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
18 changes: 9 additions & 9 deletions pyrogram/methods/messages/search_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ class SearchMessages:
async def search_messages(
self: "pyrogram.Client",
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,
query: Optional[str] = "",
offset: Optional[int] = 0,
offset_id: Optional[int] = 0,
min_date: Optional[datetime] = utils.zero_datetime(),
max_date: Optional[datetime] = utils.zero_datetime(),
min_id: Optional[int] = 0,
max_id: Optional[int] = 0,
filter: Optional["enums.MessagesFilter"] = enums.MessagesFilter.EMPTY,
limit: Optional[int] = 0,
from_user: Union[int, str] = None,
message_thread_id: Optional[int] = None
) -> AsyncGenerator["types.Message", None]:
Expand Down
14 changes: 10 additions & 4 deletions pyrogram/methods/messages/search_messages_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Union
from typing import Union, Optional

import pyrogram
from pyrogram import raw, enums
Expand All @@ -26,9 +26,10 @@ class SearchMessagesCount:
async def search_messages_count(
self: "pyrogram.Client",
chat_id: Union[int, str],
query: str = "",
filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY,
from_user: Union[int, str] = None
query: Optional[str] = "",
filter: Optional["enums.MessagesFilter"] = enums.MessagesFilter.EMPTY,
from_user: Optional[Union[int, str]] = None,
message_thread_id: Optional[int] = None
) -> int:
"""Get the count of messages resulting from a search inside a chat.
Expand All @@ -54,6 +55,10 @@ async def search_messages_count(
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:
``int``: On success, the messages count is returned.
"""
Expand All @@ -74,6 +79,7 @@ async def search_messages_count(
if from_user
else None
),
top_msg_id=message_thread_id,
hash=0
)
)
Expand Down

0 comments on commit 055d125

Please sign in to comment.