search_posts()¶
- async Client.search_posts()¶
Search for posts in public channels globally.
Usable by Users Bots- Parameters:
query (
str, optional) – Text query string to search for. Defaults to “” (empty string).hashtag (
str, optional) – Hashtag to search for. Defaults to “” (empty string).limit (
int, optional) – Limits the number of posts to be retrieved. By default, no limit is applied and all matching posts are returned.
- Returns:
Generator– A generator yieldingMessageobjects.
Example
# Search for posts mentioning "telegram" async for post in app.search_posts(query="telegram", limit=50): print(post.chat.title, post.text) # Search for posts with a hashtag async for post in app.search_posts(hashtag="news", limit=20): print(post.chat.title, post.text)