Type Alias grammers_client::client::messages::SearchIter

source ·
pub type SearchIter = IterBuffer<Search, Message>;

Aliased Type§

struct SearchIter { /* private fields */ }

Implementations§

source§

impl SearchIter

source

pub fn offset_id(self, offset: i32) -> Self

source

pub fn query(self, query: &str) -> Self

Changes the query of the search. Telegram servers perform a somewhat fuzzy search over this query (so a word in singular may also return messages with the word in plural, for example).

source

pub fn sent_by_self(self) -> Self

Restricts results to messages sent by the logged-in user

source

pub fn min_date(self, date_time: &DateTime<FixedOffset>) -> Self

Returns only messages with date bigger than date_time.

use chrono::DateTime;

// Search messages sent after Jan 1st, 2021
let min_date = DateTime::parse_from_rfc3339("2021-01-01T00:00:00-00:00").unwrap();

let mut messages = client.search_messages(&chat).min_date(&min_date);
source

pub fn max_date(self, date_time: &DateTime<FixedOffset>) -> Self

Returns only messages with date smaller than date_time

use chrono::DateTime;

// Search messages sent before Dec, 25th 2022
let max_date = DateTime::parse_from_rfc3339("2022-12-25T00:00:00-00:00").unwrap();

let mut messages = client.search_messages(&chat).max_date(&max_date);
source

pub fn filter(self, filter: MessagesFilter) -> Self

Changes the media filter. Only messages with this type of media will be fetched.

source

pub async fn total(&mut self) -> Result<usize, InvocationError>

Determines how many messages there are in total.

This only performs a network call if next has not been called before.

source

pub async fn next(&mut self) -> Result<Option<Message>, InvocationError>

Return the next Message from the internal buffer, filling the buffer previously if it’s empty.

Returns None if the limit is reached or there are no messages left.