From f7e272ab8726ed6a205b46d6723cc91aa9d63be1 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 8 May 2026 12:06:17 +0300 Subject: Fix command stripping --- src/tg.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tg.ts b/src/tg.ts index 8a26429..fd62af4 100644 --- a/src/tg.ts +++ b/src/tg.ts @@ -24,7 +24,7 @@ bot.command("/stop", async (ctx) => { // --- Shopping list --- bot.command("add", async (ctx) => { - const item = ctx.message.text.replace(/^\/add\s*/, "").trim(); + const item = ctx.message.text.replace(/^\/add(@\w+)?\s*/, "").trim(); if (!item) { await ctx.reply("Käyttö: /add "); return; } addShoppingItem(item, ctx.message.from.id); await ctx.reply(`Lisätty: ${item}`); @@ -52,7 +52,7 @@ bot.action(/^del:(\d+)$/, async (ctx) => { // --- Recurring tasks --- bot.command("newtask", async (ctx) => { - const args = ctx.message.text.replace(/^\/newtask\s*/, "").trim(); + const args = ctx.message.text.replace(/^\/newtask(@\w+)?\s*/, "").trim(); const match = /^(\d+(?:pv|vk|kk|v))\s+(.+)$/.exec(args); if (!match) { await ctx.reply("Käyttö: /newtask \nEsim: /newtask 2vk Imurointi\n\nIntervallit: pv, vk, kk, v"); @@ -87,7 +87,7 @@ bot.command("tasks", async (ctx) => { }); bot.command("edittask", async (ctx) => { - const args = ctx.message.text.replace(/^\/edittask\s*/, "").trim(); + const args = ctx.message.text.replace(/^\/edittask(@\w+)?\s*/, "").trim(); const match = /^(\d+)\s+(\d+(?:pv|vk|kk|v))\s+(.+)$/.exec(args); if (!match) { await ctx.reply("Käyttö: /edittask \nEsim: /edittask 3 1kk Ikkunoiden pesu"); @@ -104,7 +104,7 @@ bot.command("edittask", async (ctx) => { }); bot.command("done", async (ctx) => { - const idStr = ctx.message.text.replace(/^\/done\s*/, "").trim(); + const idStr = ctx.message.text.replace(/^\/done(@\w+)?\s*/, "").trim(); const id = Number(idStr); if (!id) { await ctx.reply("Käyttö: /done "); return; } markTaskDone(id, today()); -- cgit v1.3