To improve the search functionality and make it more advanced, you can filter the search results based on additional parameters, such as date range or message type.
First, install the telethon library using pip:
CMD - pip install telethon
#NOTE Don't forget to replace API_ID, API_HASH, and PHONE_NUMBER with your actual values. You can get your API_ID and API_HASH from Telegram's developer website. To obtain your API_ID and API_HASH for the Telegram API, you need to create a new application on the Telegram website. Follow these steps:
Visit the Telegram API development tools page: https://my.telegram.org/apps Log in with your Telegram account. Click on the "API Development Tools" link. Fill out the form to create a new application. You can provide any valid name and short name for the application. Click on "Create application" at the end of the form. After the application is created, you'll see your API_ID and API_HASH on the page. Copy these values and use them in your Python script.
As always, make sure to respect Telegram's terms of service and other users' privacy when using this script or any other