This project automatically updates your Telegram profile picture based on the current weather conditions in a specified city. It uses the Open-Meteo API for weather data, retrieves city coordinates via the Open-Meteo geocoding API, maps weather codes to high-resolution weather icons (from Icons8), and then updates your Telegram profile picture using Telethon.
- Weather Data Retrieval: Fetches the current weather code from the Open-Meteo API.
- Icon Mapping: Maps the weather code to a high-resolution (256x256) weather icon from Icons8.
- City Geocoding: Retrieves the latitude and longitude of a given city using Open-Meteo's geocoding API.
- Telegram Profile Update: Downloads the corresponding weather icon and updates your Telegram profile picture.
- Secure Configuration: Sensitive credentials and settings are stored in a separate YAML configuration file.
.
├── config.yaml # Contains Telegram API credentials and user settings
├── geolocation.py # Retrieves city coordinates using Open-Meteo's geocoding API
├── main.py # Main script integrating all functionalities
├── weather_mapping.py # Maps weather codes to high-resolution icon URLs
└── README.md # Project documentation
- Python 3.7+
Required Libraries:
requeststelethonpyyamlnest_asyncio
Install the dependencies using pip:
pip install requests telethon pyyaml nest_asyncio-
Clone the Repository:
git clone https://github.com/yourusername/your-repo.git cd your-repo -
Create and Configure
config.yaml:Create a file named
config.yamlin the project root with the following content. Replace the placeholder values with your actual credentials:# config.yaml api_id: "your_api_id_here" api_hash: "your_api_hash_here" telegram_session_name: "your_session_name_here" telegram_phone: "+1234567890" telegram_password: "your_2fa_password_here"
Note: You can obtain your
api_idandapi_hashby registering an app at my.telegram.org.
Run the main script with Python:
python main.pyWorkflow:
- City Input: The script prompts you to enter a city name.
- Geocoding: It retrieves the city's latitude and longitude via the Open-Meteo geocoding API.
- Weather Data: The current weather code is fetched from the Open-Meteo API.
- Icon Mapping: The weather code is mapped to a high-resolution icon URL.
- Profile Update: The icon is downloaded and used to update your Telegram profile picture.
-
Connection Issues:
Ensure your network is stable and not blocking access to Telegram or the required API endpoints. -
Invalid Credentials:
Double-check the values inconfig.yamlfor correctness. -
Two-Step Verification:
If your Telegram account has two-step verification enabled, the script will prompt you for your Telegram password after you enter the authentication code. -
Dependencies:
Verify that all required Python packages (requests,telethon,pyyaml,nest_asyncio) are installed.
This project is open source and available under the MIT License.