Airgram

Guides
/
/
Methods

api.searchMessages()

Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Parameters SearchMessagesParams:

NameTypeDescription
chatList Chat list in which to search messages; pass null to search in all chats regardless of their chat list. Only Main and Archive chat lists are supported
querystring Query to search for
offsetDatenumber The date of the message starting from which the results need to be fetched. Use 0 or any date in the future to get results from the last message
offsetChatIdnumber The chat identifier of the last found message, or 0 for the first request
offsetMessageIdnumber The message identifier of the last found message, or 0 for the first request
limitnumber The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
filter Additional filter for messages to search; pass null to search for all messages. Filters searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterFailedToSend and searchMessagesFilterPinned are unsupported in this function
minDatenumber If not 0, the minimum date of the messages to return
maxDatenumber If not 0, the maximum date of the messages to return
Returns ApiResponse interface:
interface ApiResponse {
  _: 'searchMessages' | 'error'
  airgram: Airgram
  request: {
    method: 'searchMessages'
    params: SearchMessagesParams
  }
  response:  | 
  setState: (nextState: Record<string, unknown>) => void
  getState: () => Record<string, unknown>
}