https://github.com/asjordi/telegram-weather-bot
Telegram Weather Bot
https://github.com/asjordi/telegram-weather-bot
github-actions java openweathermap-api telegram telegram-bot
Last synced: about 1 month ago
JSON representation
Telegram Weather Bot
- Host: GitHub
- URL: https://github.com/asjordi/telegram-weather-bot
- Owner: ASJordi
- License: mit
- Created: 2025-01-12T22:44:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-11T12:16:24.000Z (over 1 year ago)
- Last Synced: 2025-03-11T13:26:06.654Z (over 1 year ago)
- Topics: github-actions, java, openweathermap-api, telegram, telegram-bot
- Language: Java
- Homepage:
- Size: 438 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## About :computer:
Java application that allows you to periodically check the weather for a specific city automatically via a Telegram bot. The information is retrieved from the [OpenWeatherMap API](https://openweathermap.org/api), processed using the [Jackson Databind](https://github.com/FasterXML/jackson-databind) library, and sent via a Telegram bot using the [TelegramBots](https://rubenlagus.github.io/TelegramBotsDocumentation/telegram-bots.html) library. The application runs automatically every 4 hours using a GitHub Actions workflow.
> This project is also available using Azure Functions, check it out [here](https://github.com/ASJordi/azure-telegram-weather-bot)
## Features :sparkles:
- Make and process API requests.
- Convert API responses into Java objects.
- Process weather data retrieved from the API.
- Send messages via a Telegram bot.
- Automate message delivery using GitHub Actions.
## Classes :books:
- `bot package`: Contains classes representing the Telegram bot.
- `logger package`: Contains classes for configuring the application logger.
- `request package`: Contains the class responsible for making API requests.
- `weather package`: Contains classes to process the data retrieved from the API.
- `GlobalProperties`: Class responsible for loading environment variables.
- `Main`: Main class that executes the application.
## Technologies :gear:
- Java 21
- GitHub Actions
- Maven
- Lombok
- TelegramBots
- Jackson Databind
- Java Logging
## Installation :floppy_disk:
Before starting, consider the following:
- You need an account with [OpenWeatherMap](https://openweathermap.org/api) to get an API token.
- Create a Telegram bot and get the token and chat ID using [BotFather](https://telegram.me/BotFather).
Steps to install the application:
1. Clone the repository.
2. Open the project in an IDE.
3. Install the required dependencies.
4. Set up the following environment variables:
- `OPENWEATHER_API_URL`: OpenWeatherMap API URL, default is `https://api.openweathermap.org/data/2.5/weather`.
- `OPENWEATHER_TOKEN`: API access token from OpenWeatherMap.
- `OPENWEATHER_ZIP_CODE`: City zip code, e.g., `06000,MX`.
- `OPENWEATHER_LANG`: API response language, e.g., `en`.
- `OPENWEATHER_UNITS`: Temperature unit, e.g., `metric`.
- `TELEGRAM_BOT_TOKEN`: Telegram bot token.
- `TELEGRAM_CHAT_ID`: Telegram chat ID.
5. Run the program.
> To run the application automatically using GitHub Actions, configure the environment variables in the repository settings.
## License :page_facing_up:
Distributed under the MIT License. See `LICENSE` for more information.
## Contact :email:
Jordi Ayala - [@ASJordi](https://x.com/ASJordi)
Project link: [https://github.com/ASJordi/telegram-weather-bot](https://github.com/ASJordi/telegram-weather-bot)