From b0db0e55c0c400bc948a4934b0e4fddfbfdcca51 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 7 Oct 2025 13:04:03 +0300 Subject: Rewrite to run as a traditional script, update deps --- README.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 7419a02..5d7ddc1 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,84 @@ Rewrite of hommabot (Python3) in TS. -# Running +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 -1. Set up DB. The `sql` directory is mounted inside the `db` container as `/sql`. +## Persistence +- Embedded SQLite (STRICT tables) auto-initialized on first run +- Single connection (read + write) + +## Setup + +1. Install dependencies (includes better-sqlite3): + +```sh +npm install +``` + +2. Create/update your `.env` (minimum required): + +```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 ``` -docker-compose up -d db -docker-compose exec db psql postgresql://postgres:postgres@localhost/postgres -f /sql/001-init.sql + +3. (Optional) Seed permitted Telegram user IDs (only these can /start to register chats): + +```sh +sqlite3 data/hommabot.db "INSERT OR IGNORE INTO permitted_users (id) VALUES (123456789);" ``` -2. Set up `.env` -3. `npm run dev` +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 +``` +## 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;" +``` -- cgit v1.3