search_messages_count()#
- Client.search_messages_count()#
Get the count of messages resulting from a search inside a chat.
If you want to get the actual messages, see
Usable by ✅ Users ❌ Botssearch_messages()
.- Parameters:
chat_id (
int
|str
) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”. For a contact that exists in your Telegram address book you can use his phone number (str).query (
str
, optional) – Text query string. Required for text-only messages, optional for media messages (see thefilter
argument). When passed while searching for media messages, the query will be applied to captions. Defaults to “” (empty string).filter (
MessagesFilter
, optional) – Pass a filter in order to search for specific kind of messages only: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 forum supergroups onlymin_date (
datetime
, optional) – Pass a date as offset to retrieve only older messages starting from that date.max_date (
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.saved_messages_topic_id (
int
|str
, optional) – If not None, only messages in the specified Saved Messages topic will be returned; pass None to return all messages, or for chats other than Saved Messages.
- Returns:
int
– On success, the messages count is returned.