https://github.com/notdodo/erfiume_bot
Bot per leggere i livelli idrometrici dei fiumi dell'Emilia Romagna riportati da allertameteo.regione.emilia-romagna.it.
https://github.com/notdodo/erfiume_bot
emilia-romagna livello-fiumi pulumi rust telegram
Last synced: 6 months ago
JSON representation
Bot per leggere i livelli idrometrici dei fiumi dell'Emilia Romagna riportati da allertameteo.regione.emilia-romagna.it.
- Host: GitHub
- URL: https://github.com/notdodo/erfiume_bot
- Owner: notdodo
- License: gpl-3.0
- Created: 2024-09-20T12:54:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T14:15:04.000Z (6 months ago)
- Last Synced: 2025-04-09T15:25:20.555Z (6 months ago)
- Topics: emilia-romagna, livello-fiumi, pulumi, rust, telegram
- Language: Rust
- Homepage: https://t.me/erfiume_bot
- Size: 1.56 MB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://github.com/notdodo/erfiume_bot/actions/workflows/pulumi-up.yml)
[](https://github.com/notdodo/erfiume_bot/actions/workflows/bot-deploy.yml)
[](https://github.com/notdodo/erfiume_bot/actions/workflows/fetcher-deploy.yml)
![]()
## Introduction
[`@erfiume_bot`](https://t.me/erfiume_bot) it's a Telegram bot that fetches the water levels of the rivers in Emilia Romagna. Data is retrieved from [Allerta Meteo Emilia Romagna](https://allertameteo.regione.emilia-romagna.it/) APIs and periodically stored/updated in a DynamoDB table.
The bot can be used in both private or group chats, responding to specific station names or commands.
## Basic commands:
- `/start`
- `/info`
- `/stazioni`
- `/` where `` is one the station reported on [Livello Idrometrico](https://allertameteo.regione.emilia-romagna.it/livello-idrometrico)## Architecture
The bot consists of two main components:
1. **User interaction**: the code in `./app/bot` is triggered by a Telegram webhook that starts an AWS Lambda function when a user interacts with the bot.
2. **Stations data update**: the code in `./app/fetcher` runs on a Lambda function via an EventBridge scheduler, updating the data from the stations. This data is then used by the bot to answer to messages.
### Main technologies:
- **Pulumi** for IaC
- **AWS Lambda** for main code execution environment
- **DynamoDB** for storing station data
- **EventBridge Scheduler** to trigger the syncing from Allerta Meteo
- **teloxide** to manage Telegram inputs
- **tokio** for managing asynchronous tasks in the Lambdas
- **Levenshtein Distance** for performing fuzzy search on station names from user input## Features
### Telegram Bot (`./app/bot`)
The bot responds to Telegram messages via the main Lambda function and can:
- respond to any message or command (`/`) in private chats
- react when added to a group or supergroup
- process any command (`/`) in group or supergroup chatsWhat it cannot do:
- read non-command messages in groups or supergroups
- provide [inline support](https://telegram.org/blog/inline-bots)
- support mentions### Data fetcher (`./app/fetcher`)
This Lambda function is scheduled to fetch data from the APIs on [Allerta Meteo Emilia Romagna](https://allertameteo.regione.emilia-romagna.it/) and update or create station data in a DynamoDB table. A station refers to a sensor placed on a bridge or river that monitors the water level.
The Lambda is scheduled to run once a day in "normal" mode, but in "emergency" mode, it can be set to update data every 20 minutes or less.
## Repository Structure
- **app/**: Contains the bot and fetcher code
- **pulumi/**: IaC for the AWS infrastructure## Disclaimer
The accuracy and reliability of the data is entirely dependent on [Allerta Meteo Emilia Romagna](https://allertameteo.regione.emilia-romagna.it/). `erfiume_bot` merely collects and displays the available data from that source.