BusV is a Telegram chat bot 🤖 that helps you catch your bus 🚍 by providing you route information and bus predictions. Start chatting with it on Telegram to find out more: @BusVbot.
This bot works best for passengers who take frequent routes and already know what bus they should take to reach their destinations.
Supporting 70+ transit agencies in North America, the real-time bus predictions are powered by NextBus.
Here are the regions that agencies operate in:
| Canada | U.S. |
|---|---|
| Ontario, Quebec | California-Northern, California-Southern, District of Columbia, Florida, Georgia, Indiana, Iowa, Kentucky, Maryland, Massachusetts, Mississippi, Nevada, New Jersey, New York, North Carolina, Oregon, Pennsylvania, Texas, Virginia, Washington |
You can take a look at the Redis instance via:
docker run -it --link busvbot-redis:redis --rm redis redis-cli -h redis -p 6379
BusVbot is built using Telegram.Bot.Framework as an ASP.NET Core app.
- Visual Studio 2017 or .NET Core 1.1
- Postgres database
- Telegram Bot API token
Make a copy of appsettings.json in project folder and name it appsettings.Development.json:
cp -v src/BusVbot/appsettings{,.Development}.jsonEdit the appsettings.Development.json file and put your bot name, API token, and Postgres connection string values there.
There are other options to provide the app with configurations. Have a look at first few lines of Startup class.
Note that
appsettings.Development.jsonis gitignored so it is safe to store the app secrets there.
Run the Postgres database. Examples here are using docker containers.
# create and start the container
docker run -d -p 5432:5432 --name busvbot-postgres -e POSTGRES_PASSWORD=password -e POSTGRES_USER=busvbot -e POSTGRES_DB=busvbot postgresSee
docker-local.shfor sample docker commands to use.
While running in Development environment, app makes sure database is seeded with data from NextBus before it starts the bot.
It might take a while to download all the data so in order to save time, use the sql dump file and its INSERT statements instead.
Create schema:
cd src/BusVbot
dotnet restore
dotnet ef database updateInsert data:
# inside docker container, as postgres user
psql -U busvbot < nextbus-dump.sqlRun the app and start chatting with the bot on Telegram.
Set the commands for bot in a chat with @BotFather.
bus - 🚍 Bus predictions
profile - 👤 View/Modify my profile
help - ❓ Help
TelegramTests project contains the Systems Integration test cases. The HTTP requests to the Telegram Bot API are mocked using(Moq) and Docker Compose is used to run containers for other dependencies.
Before running the tests, MongoDB and Redis should be up and running.
cd test/TelegramTests
# run the containers in the background
docker-compose --project-name tg up -d --force-recreate --remove-orphans
# optionally, see the logs while running the tests
# docker-compose --project-name tg logs --followTests cases can be run now from the IDE or the console.
dotnet test --verbosity normalContainers can be removed after the tests are done.
docker-compose --project-name tg rm --stop -fv
