A Telegram bot to get you real-time information about subway arrivals, departures, and alerts in the New York City subway system.
- Find it on Telegram as NYC Subway Train Tracker Bot
- Real-time train status and alerts
- Information about station stops for each subway line
- Provision of service and transfer information
- Possibility of adding favourite station and train direction for quick tracking
- Clone this git repository.
git clone https://github.com/f3d3/NYCMTA-telegram-bot
- Change Directory
cd NYCMTA-telegram-bot
- Install requirements with pip3
pip3 install -r requirements.txt
-
Add values in config.py.
-
Create client_secrets.json file.
-
Add values in settings.yaml.
client_id
- Copy it from client_secrets.json fileclient_secret
- Copy it from client_secrets.json file
Create a service file, e.g. /etc/systemd/system/bot.service
[Unit]
Description=Telegram Bot Service
Requires=network.target
After=network.target
StartLimitIntervalSec=0
[Service]
ExecStart=/bin/bash -c 'cd /path-to-folder/NYCMTA-telegram-bot/ && /usr/bin/python3 /path-to-folder/NYCMTA-telegram-bot/bot.py'
Type=simple
User=<user>
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Reload the systemctl daemon. Then, enable the service so that it boots on reboot and start it
sudo systemctl daemon-reload
sudo systemctl enable bot.service
sudo systemctl start bot.service
Use the command below to run the script by getting it to ignore the hangup signal and keep running. Output will be put in nohup.out
.
nohup python3 bot.py &
If you do not want an ever-growing nohup.out
file, you need to redirect the script's output as
nohup python3 bot.py > /dev/null 2>&1 &
- Copyright (©) 2022 by Federico Moretto
- Licensed under the terms of the GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007