Skip to content

Bot per leggere i livelli idrometrici dei fiumi dell'Emilia Romagna riportati da allertameteo.regione.emilia-romagna.it.

License

Notifications You must be signed in to change notification settings

notdodo/erfiume_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

erfiume_bot Buy Me A Coffee

Pulumi Up Deploy Bot

Alt

Introduction

@erfiume_bot is a Telegram bot that fetches the water levels of the rivers in Emilia-Romagna and Marche. Data is retrieved from the Allerta Meteo Emilia Romagna APIs and from the Protezione Civile Marche portal, then periodically stored/updated in DynamoDB. The bot can be used in both private or group chats, responding to specific station names or commands or alerting when a threshold is reached.

Basic commands:

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 or to trigger alert notifications.

Main technologies:

  • Pulumi for IaC
  • AWS Lambda for main code execution environment
  • DynamoDB for storing 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 chats
  • set up and manage alerts to notify the user of the reaching of a threshold

What it cannot do:

  • read non-command messages in groups or supergroups
  • provide inline support
  • support mentions

Data fetcher (./app/fetcher)

This Lambda function is scheduled to fetch data from the APIs on Allerta Meteo Emilia Romagna and from the Protezione Civile Marche portal, then update or create station data in DynamoDB. A station refers to a sensor installed on a bridge or along a river that monitors water levels. Using the newly fetched information, the function also sends alerts to users who are subscribed to specific threshold notifications.

The Lambda is scheduled to run once every 2 hours 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 as single Rust workspace.
  • pulumi/: IaC for the AWS infrastructure.

Disclaimer

The accuracy and reliability of the data is entirely dependent on Allerta Meteo Emilia Romagna and Protezione Civile Marche: erfiume_bot just collects and displays the available data from these sources.

About

Bot per leggere i livelli idrometrici dei fiumi dell'Emilia Romagna riportati da allertameteo.regione.emilia-romagna.it.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •