From 31f967c58f4c58ffacc88e141a44a10e3c8a7ef0 Mon Sep 17 00:00:00 2001 From: Eric Matala de Mazza Date: Mon, 1 May 2023 22:42:06 +0200 Subject: [PATCH] feat: add trash command --- src/app.ts | 2 ++ src/handlers.ts | 9 +++++++++ src/messages.ts | 11 +++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app.ts b/src/app.ts index 3018a4f..a2a0189 100644 --- a/src/app.ts +++ b/src/app.ts @@ -11,6 +11,7 @@ import { handleRemind, handleRoomieIsDone, handleRotate, + handleTrash, handleWelcome, } from "./handlers"; import { auth } from "./middleware"; @@ -42,6 +43,7 @@ bot.command("getall", handleGetAllDuties(prisma)); bot.command("done", handleRoomieIsDone(prisma, bot)); bot.command("remind", handleRemind(prisma, bot)); bot.command("rotate", handleRotate(prisma, bot)); +bot.command("trash", handleTrash(prisma)); bot.command("help", handleHelp); const launch = async (bot: Telegraf) => { diff --git a/src/handlers.ts b/src/handlers.ts index 4970d22..5818242 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -4,6 +4,7 @@ import { dutyIsDoneMessage, getAllDutiesMessage, getOwnDutyMessage, + getTrashReminderMessage, helpMessage, noDutiesMessage, reminderIsSentMessage, @@ -125,3 +126,11 @@ export const handleHelp = (ctx: Context) => { console.error(error); } }; + +export const handleTrash = (prisma: PrismaClient) => async (ctx: Context) => { + try { + ctx.reply(await getTrashReminderMessage()); + } catch (error) { + console.error(error); + } +}; diff --git a/src/messages.ts b/src/messages.ts index 5ff9ba8..fe80581 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -17,17 +17,20 @@ export const helpMessage = [ "/register - Registrieren (Passwort erforderlich)", "/get - Den eigenen Dienst anzeigen", "/getall - Alle Dienste anzeigen", - "/remind - Die anderen an ihre Dienste erinnern", "/done - Den eigenen Dienst als erledigt markieren", + "/remind - Die anderen an ihre Dienste erinnern", "/rotate - Dienste rotieren", + "/trash - Welcher Müll muss raus?", "/help - Hilfe anzeigen", ].join("\n"); // dynamic messages export const getTrashReminderMessage = async () => - ["Hey, du musst den Müll rausbringen 🚛 \n", ...(await getTrashItems())].join( - "\n" - ); + [ + "🚛🚛🚛\n", + ...(await getTrashItems()), + "\nmüssen an die Straße gestellt werden.", + ].join("\n"); export const getDutiesRotatedMessage = (title: string, description: string) => `Neue Woche neue Dienste 😍\n\nDu bist diese Woche dran mit ${title} (${description})`; export const getReminderMessage = (name: string, title: string) =>