This project implements a bot to monitor real-time notifications related to public transportation service updates, disruptions, and schedule changes. It sends alerts on issues affecting metro and bus lines via Telegram.
- Live Notifications Monitoring: Retrieves real-time service notifications regarding disruptions, closures, and other advisories for public transport lines.
- Telegram Notifications: Automatically sends notifications via a Telegram bot to keep users informed about delays or other service issues.
- Update Logging: Saves each update to a JSON file to create a historical log and track the frequency of alerts.
main_atm.py
: Main script to run the bot.get_data.py
: Retrieves and formats current updates for the notifications.check_update.py
: Checks update frequency to avoid duplicate notifications.telegram_sender.py
: Manages sending notifications through the Telegram bot.log_update.json
: JSON file used to store the date and time of the last update.
Ensure you have the following Python libraries installed:
selenium
datetime
json
Install dependencies with:
pip install selenium
- Create a bot on Telegram using BotFather.
- Obtain the bot API token.
- Add this token to
telegram_sender.py
to allow the bot to send notifications.
The log_update.json
file is used to store the date and time of the last update. Initialize it as follows:
{
"date": null,
"hour": null,
"minute": null,
"second": null
}
When a new update is detected, the bot will automatically update this file with the current date and time.
To run the bot:
python main_atm.py
The bot will send Telegram notifications similar to the following:
⚠️ UPDATE ⚠️
Tram 12. Service interrupted between Piazza Emilia and Viale Molise (vehicle accident). Please use bus 66 as an alternative.
Expect longer wait times for the following lines:
84, 85, 94, and B12 (traffic and roadworks)
321 and 352 (private vehicle accident)
🅿️ Park-and-Ride: Maciachini, Abbiategrasso, and Bovio parking lots are currently full.
Modify check_update.py
to adjust the time interval between update checks. You can also edit the message_generator
function in telegram_sender.py
to change the format of the messages sent.
Feel free to fork this repository, open issues, or submit pull requests to improve the project. Contributions are always welcome!
This project is licensed under the MIT License.