diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-10-07 13:04:03 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-10-07 16:03:28 +0300 |
| commit | b0db0e55c0c400bc948a4934b0e4fddfbfdcca51 (patch) | |
| tree | 0d29e8015178a0eaa52e9f821ad243c5435da99f /README.md | |
| parent | fe57e4996ec79267dffd77e503ef8164eceea229 (diff) | |
Rewrite to run as a traditional script, update deps
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 81 |
1 files changed, 75 insertions, 6 deletions
@@ -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;" +``` |
