This repository holds my Capstone Project for Rust Programming Bootcamp of Summer 2023. It has been developed over the course of 1 week. I estimate it took me about 10-12 hours of work to reach this state.
Here is how I described the project when this idea first came to mind.
A Telegram bot (or a website?) that holds schedules for my uni. A pretty popular concept I think.
- Subject has name, lecturer, kind(practice, lecture, labs), which week is it happening(odd, even, both), maybe link to the meeting, maybe a link to the classroom, what group and year it's for.
- Query what subject is ongoing for a particular group on a particular date.
- Display shcedule for a particular date.
- Display shcedule for a general weekday.
- Display schedule for a particular week.
- Dsiplay schedule for a general week.
- Provide option to remember query options(group and year most notably) for ease of use.
I need this in my life.
Here is a list of features that I ended up developing for the project:
\config <group>
command allows to save user's group for further queries.\subject [slot] [date]
queries a singular subject happening at a particular point in time. Whenslot
is omitted, bot uses current time to figure out the slot. Whendate
is omitted, bot uses current date, similarly. User can omitslot
but specifydate
using\subject _ <date>
syntax.- There is good amount of feedback on invalid input to help user navigate the bot.
- It is possible to store and display meetings associated with schedule(data layout and display types allow so). Sadly, I have not populated database tables with such information, nor have I provided endpoints to do so.
This correlates with points 1, 2 and 6 from the initial proposal.
This bot is built from a Linux machine.
Most importantly, you are going to need to provide your own Telegram bot token. You can get one using Telegram's @Botfather.
Create a file called config.toml
in the root of the repository with the following structure:
token = "<your:token>"
You'll also need latest stable version of Rust compiler and cargo, as well as sqlx-cli
that can be installed with cargo install sqlx-cli
.
Setup the database with:
cargo sqlx database setup
This will create a shell SQLite database file at /tmp/test.db
. You then need to populate it with data with this command:
cargo run --bin setup -- sqlite:///tmp/test.db
You can inspect the program being run by navigating to the src/bin/setup.rs
file.
Finally, you can run the bot:
cargo run --bin schedule-bot
Or, to see some nice logs:
RUST_LOG=schedule_bot=trace cargo run --bin schedule-bot
You can now navigate to your chat with the bot in Telegram and test out some commands.