Telegram bot to notify when seats are available on a bus.
List of requests for the information we need
API | Description | Used by | URL | Query Parameters? | Notes |
---|---|---|---|---|---|
eligible_journeys | Get journeys for pass ID | Rides page | https://app.zeelo.co/api/travels/38u1fj13-rfd8-q99a-ap22-ao92929ifikf/elegible-journey-groups | ❌ | |
stops | Get stops | Rides page | https://app.zeelo.co/api/stops/by_id?page=1&per_page=25 | ❌ | |
journeys | Get journeys | Pass page | https://app.zeelo.co/api/travel-passes/38u1fj13-rfd8-q99a-ap22-ao92929ifikf/eligible-journey-groups | ✅ | |
capacity | Get capacity | Pass page | https://app.zeelo.co/api/journeys/capacity_between_stops | ❌ |
Parameter | Description | Example |
---|---|---|
product_id | Product ID | 38u1fj13-rfd8-q99a-ap22-ao92929ifikf |
origin_stop_id[] | Origin stop ID | 38u1fj13-rfd8-q99a-ap22-ao92929ifikf |
destination_stop_id[] | Destination stop ID | 38u1fj13-rfd8-q99a-ap22-ao92929ifikf |
tier_id[] | Tier ID | 38u1fj13-rfd8-q99a-ap22-ao92929ifikf |
Requirement | Version |
---|---|
Python | 3.11.1 |
python -m venv env
pip install -r requirements.txt
python ./bot.py
To obtain an access token for telegram, see help page, but in essence, talk to the BotFather.
The access token is used via an environment variable, or a .env
file, which is not tracked by git.
Also in the environment should be an "admin ID", where errors are sent via the error handler.
touch .env
TELEGRAM_BOT_ACCESS_TOKEN=...
ADMIN_USER_ID=...
To store each user's preferred stops and reminder preference, a persistent pickle file is used. This is not tracked by git. This uses the Persistence API from python-telegram-bot.
persistent_data = PicklePersistence(filepath="bot_data.pickle")
application = Application.builder().token(API_KEY).persistence(persistent_data).build()
ssh root@...
cd ~/python
git clone https://github.com/alifeee/bus_bot.git
cd bus_bot
sudo apt-get update
sudo apt install python3.10-venv
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
echo {} >> historical_capacities.json
scp google_credentials.json root@...:~/python/bus_bot/
scp .env root@...:~/python/bus_bot/
ssh root@...
cd ~/python/bus_bot
cp bus_bot.service /etc/systemd/system/bus_bot.service
sudo systemctl enable bus_bot.service
sudo systemctl start bus_bot.service
sudo systemctl status bus_bot.service
ssh root@...
cd ~/python/bus_bot
git pull
Then repeat steps in Run