How akapj/bottelegramtiempo works
Main Components
• Bot Application: Represented primarily by “bot.py”, which contains the core logic for fetching weather data from the OpenWeatherMap API and sending messages to Telegram.
• Scheduler & Automation: Represented by the GitHub Actions workflow file in “.github/workflows/telegram.yml”. It’s responsible for triggering the bot at scheduled intervals (twice a day by default, customizable via cron expressions).
• External APIs: Include the OpenWeatherMap API (for weather data) and the Telegram Bot API (for sending messages).
• Configuration & Environment: Although there isn’t a dedicated configuration file in the tree, the README instructs the use of a “.env” file for environment variables (API keys and tokens). Also include “requirements.txt” which lists Python dependencies.
• Testing: The “test.py” file serves as a module for testing the bot’s functionality.
Relationships and Interactions
• The GitHub Actions workflow acts as a trigger, executing “bot.py” according to the scheduled cron job.
• “bot.py” reads configuration details (API keys, chat ID, etc.) from environment variables (set in the ".env" file) to authenticate and interact with external services.
• The bot makes a RESTful/HTTP call to the OpenWeatherMap API to obtain weather data.
• Upon receiving the weather data, “bot.py” formats a message and then sends it to the Telegram chat or group via the Telegram Bot API.
• Optionally, “test.py” can be used during development or CI testing to ensure the functionality.