Magello's Slack bot that reminds everyone to time report on the last workday of the month.
--operation=check_last_workdayruns as a scheduled job every weekday and posts a reminder to#allmanton the last workday of the month (messages inconfig.yaml). Messages are picked per part (beginning, middle, end). On an occasion (easter,valborg,midsommar,semester,kraftskiva,halloween, seesrc/occasion.rs) its messages are always used. Otherwise the month's (1,12) are used 60 % of the time andgeneralthe rest. Unknown keys fail at startup.--operation=apiserves Slack:@joel-botmentions:tid(next time report day),pricing,skribenter, or nothing for an introduction./joel(/time-report): when you next need to time report, only visible to you./gg: how long until the workday ends.
Both operations need the bot token in JOEL_BOT_SLACK_TOKEN.
The project uses the latest stable Rust (see rust-toolchain.toml); run
rustup update if the build says your toolchain is too old.
Simply build with cargo:
cargo build
...
Compiling joel-bot v2.0.0 (/path/to/joel-bot)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.35scargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo testSome tests call the live holiday API (sholiday.faboul.se). holidays::test::live_validation
checks the local holiday fallback (src/holidays.rs) against the API day by day; it also
runs weekly in GitHub Actions.
Put JOEL_BOT_SLACK_TOKEN in a .env file (loaded with dotenvy), then:
cargo run -- --operation=api
cargo run -- --operation=check_last_workdayNOTE: This environment was set up using GitHub Copilot.
This Rust project supports developing using Dev Containers so you don't need Rust locally.
- In Windows you will need WSL2 as Dev Containers works best with UN*X based environment
- Linux and MacOS environments does not need this requirement.
- A Docker environment
- Any Docker-compatible environment like e.g., Docker for Desktop (Windows/Linux), Rancher Desktop (all environments) or native Docker (Linux) works.
- Visual Studio Code with the Remote Development extension
- Or a IDE that supports devcontainers like e.g. GitHub Codespaces
- Clone this repo to your local development environment.
- Open the folder in Visual Studio Code.
- Open the Visual Studio Code command palette (
F1/SHIFT+CTRL+P/SHIFT+⌘+P) and then selectDev containers: Reopen in Container. - Create a
.envfile in the root folder containing the value forJOEL_BOT_SLACK_TOKEN- DO NOT COMMIT THIS (The
.envfile is excluded in.gitignoreso it should not be an issue.)
- DO NOT COMMIT THIS (The
And that's it, you can now rebuild/debug joel-bot.
In the event you change dependencies or environment variables, run the Rebuild Container command in the command palette to update the Dev Container.