diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2026-05-06 21:46:21 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2026-05-06 21:46:21 +0300 |
| commit | 713ced9c68cd70a8e56e8ce5ed27cb9bbe3e55c4 (patch) | |
| tree | 29f9997386b9f46db9f263ef63a5e01ca19db393 /README.md | |
| parent | cba8c3d49b53702a488eaff16109e29e49d94b6d (diff) | |
Add shopping list features, rework
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 73 |
1 files changed, 24 insertions, 49 deletions
@@ -1,85 +1,60 @@ # hommabot2 -Rewrite of hommabot (Python3) in TS. +Telegram bot for recurring household tasks and shopping lists. -1. Reads Google Sheets for recurring tasks -2. Determines which tasks fall in the current week -3. Broadcasts a Telegram message to all active chats -4. Updates the "last done" column for tasks that became due +## Features -## Persistence +- **Recurring tasks** — add tasks with intervals (days/weeks/months/years), get weekly Monday broadcasts of what's due +- **Shopping list** — shared list with inline delete buttons +- **Persistence** — embedded SQLite (STRICT tables), no external services needed -- Embedded SQLite (STRICT tables) auto-initialized on first run -- Single connection (read + write) +## Commands + +| Command | Description | +|---------|-------------| +| `/start` | Register chat for weekly broadcasts | +| `/stop` | Unregister chat | +| `/newtask <interval> <name>` | Add recurring task (e.g. `/newtask 2vk Imurointi`) | +| `/tasks` | Show all tasks with ✅ done / 🗑️ delete buttons | +| `/done <id>` | Mark task done | +| `/edittask <id> <interval> <name>` | Edit a task | +| `/add <item>` | Add item to shopping list | +| `/list` | Show shopping list with ❌ delete buttons | + +**Intervals:** `pv` (day), `vk` (week), `kk` (month), `v` (year). Prefix with number, e.g. `2vk` = every 2 weeks. ## Setup -1. Install dependencies (includes better-sqlite3): +1. Install dependencies: ```sh npm install ``` -2. Create/update your `.env` (minimum required): +2. Create `.env`: ```sh TELEGRAM_BOT_TOKEN=... -SHEETS_SPREADSHEET_ID=... -SHEETS_RANGE=... -G_SA_JSON_B64=... # Base64-encoded Google Service Account JSON # Optional: # SQLITE_PATH=./data/hommabot.db ``` -3. (Optional) Seed permitted Telegram user IDs (only these can /start to register chats): +3. (Optional) Seed permitted users: ```sh sqlite3 data/hommabot.db "INSERT OR IGNORE INTO permitted_users (id) VALUES (123456789);" ``` -Repeat with additional IDs as needed. - -4. (Optional) Pre-register an active chat manually (normally added via /start): - -```sh -sqlite3 data/hommabot.db "INSERT OR IGNORE INTO active_chats (id) VALUES (-1001234567890);" -``` - ## Running -Direct TypeScript execution: - ```sh npm start ``` +The bot runs as a long-lived process. Weekly task broadcasts fire every Monday at 09:00 Finland time. + ## Building ```sh npm run build ``` - -## Automating (cron example) - -Run every Monday at 08:00: - -``` -0 8 * * 1 /usr/bin/node /path/to/hommabot2/build/index.js >> /path/to/hommabot2/hommabot.log 2>&1 -``` - -## Inspecting the database - -```sh -sqlite3 data/hommabot.db ".tables" -sqlite3 data/hommabot.db "SELECT * FROM active_chats;" -sqlite3 data/hommabot.db "SELECT * FROM permitted_users;" -``` - -## Notes - -- To add new permitted users at any time, insert into `permitted_users`. -- To clear active chats: - -```sh -sqlite3 data/hommabot.db "DELETE FROM active_chats;" -``` |
