Skip to content

Commit

Permalink
Add commands for tomorrow's meal plan (#40)
Browse files Browse the repository at this point in the history
The bot sends tomorrow's meal plan for the commands /t and /tomorrow.

Closes #38
See pull request #40
  • Loading branch information
ikelax authored Jan 7, 2025
1 parent aa7798e commit 3b0a4ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 10 additions & 8 deletions MANUAL_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Because the unit tests do not cover the Telegram based functionality,
the following manual tests should be done if (large) changes to the
codebase are made.

| Action | Expected result |
| ------------------------------------------------------------------ | -------------------------------------------------------------------- |
| Make an inline query `@mensa_sbot` and click on one of the results | Replies with the meals for the chosen day. |
| View the available days in an inline query. | They are the same as on [Mensaar](https://mensaar.de/#/menu/sb). |
| Send `/start`. | Replies with the welcome message. |
| Send `/days`, `/d`, `/m`, `/mealplans`, `/meals` or `/menus`. | Replies with a list of inline buttons with the days in the meal plan |
| Click on an inline button. | Replies with the meals for the chosen day. |
| View the available days in list of inline buttons. | They are the same as on [Mensaar](https://mensaar.de/#/menu/sb). |
| Action | Expected result |
| ------------------------------------------------------------------ | --------------------------------------------------------------------- |
| Make an inline query `@mensa_sbot` and click on one of the results | Replies with the meals for the chosen day. |
| View the available days in an inline query. | They are the same as on [Mensaar](https://mensaar.de/#/menu/sb). |
| Send `/start`. | Replies with the welcome message. |
| Send `/days`, `/d`, `/m`, `/mealplans`, `/meals` or `/menus`. | Replies with a list of inline buttons with the days in the meal plan. |
| Click on an inline button. | Replies with the meals for the chosen day. |
| View the available days in list of inline buttons. | They are the same as on [Mensaar](https://mensaar.de/#/menu/sb). |
| Send `/t` or `/tomorrow`. | Replies with tomorrow's meal plan. |
| Send a message. | Replies with today's meal plan. |
8 changes: 8 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
sortMealplans,
} from "./mealplans.js";
import { formatDate } from "./formatDate.js";
import { addDays } from "date-fns";

export { getMensaBot };

Expand Down Expand Up @@ -63,6 +64,13 @@ function getMensaBot(token) {
bot.command(["days", "d", "m", "mealplans", "meals", "menus"], (ctx) =>
replyWithListOfMealplanDates(ctx),
);
bot.command(["t", "tomorrow"], (ctx) =>
replyWithMealplanOnDate(
ctx,
addDays(Date.now(), 1),
"Morgen gibt es kein Essen in der Mensa\\!",
),
);
bot.on("message", (ctx) =>
replyWithMealplanOnDate(
ctx,
Expand Down

0 comments on commit 3b0a4ce

Please sign in to comment.