- New lib/telegram_answers.mjs: shared module that polls Telegram getUpdates, matches replies to needs_answer jobs, saves to answers.json, flips job to new - telegram_poller.mjs: lightweight cron script (every minute via OpenClaw) - Applier also processes replies at start of each run as safety net - sendTelegram now returns message_id, stored on job for reply matching - User replies "ACCEPT" to use AI answer, or types their own - Answers persist in answers.json and apply to ALL future jobs - Also includes: selectOptionFuzzy, multiple dialog handling, browser recovery, answers reload, per-job timeout bump to 10min Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
797 B
JavaScript
22 lines
797 B
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* telegram_poller.mjs — Polls Telegram for replies to question messages
|
|
*
|
|
* Run via OpenClaw cron: * * * * * (every minute)
|
|
* Lightweight — single HTTP call, exits immediately if no updates.
|
|
*/
|
|
import { loadEnv } from './lib/env.mjs';
|
|
loadEnv();
|
|
|
|
import { resolve, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { loadConfig } from './lib/queue.mjs';
|
|
import { processTelegramReplies } from './lib/telegram_answers.mjs';
|
|
|
|
const __dir = dirname(fileURLToPath(import.meta.url));
|
|
const settings = loadConfig(resolve(__dir, 'config/settings.json'));
|
|
const answersPath = resolve(__dir, 'config/answers.json');
|
|
|
|
const processed = await processTelegramReplies(settings, answersPath);
|
|
if (processed > 0) console.log(`Processed ${processed} answer(s)`);
|