Cross references:
- Extension README (Markdown):
../../README.md - Bot docs bridge page (Markdown):
../../docs/telegram-bot.md - Bot docs page (GitHub Pages): https://apartsinprojects.github.io/Web2Comics/HTML/telegram-bot.html
Scope note:
- Developer docs describe architecture, prompts, storage, and testing.
- Admin-only bot commands are intentionally excluded from published command references.
- Onboarding/info:
/start,/welcome,/help,/about,/version,/user,/config,/explain,/debug - Generation inputs: text, web link, PDF, image, or voice/audio,
/invent <story>,/random - Replay:
/peek,/peek <n>,/peek<n> - Providers/models:
/vendors,/vendor <role> <name>,/vendor <name>,/models [role] [model],/test - Output controls:
/panels,/objective,/objectives, objective shortcuts,/style, style shortcuts,/new_style,/language,/mode,/consistency,/detail,/crazyness,/concurrency,/retries - Prompt/options:
/prompts,/set_prompt,/list_options,/options - Credentials/state:
/keys,/setkey,/unsetkey,/reset_config,/restart
- Entry point:
telegram/src/webhook-bot.js - Generator bridge:
telegram/src/generate.js - Shared engine:
engine/src/* - Bot data modules:
telegram/src/data/*(messages, providers, styles/objectives, options, thresholds) - Engine prompt templates:
engine/src/data/prompt-templates.js - Runtime state/config:
telegram/src/config-store.js - Persistence adapters:
telegram/src/persistence.js+ request/crash log stores
Processing model:
- Webhook handler ACKs immediately
- Update is enqueued per chat id
- One active job per chat queue preserves per-user order
Input from message.text, media attachments, or message.caption is classified as:
- command
- url
- image
- voice
- text
- empty/unsupported
Source-specific flows extract structured text before generation:
- URL flow snapshots rendered page HTML before generation
- PDF flow extracts document text from a link or uploaded file
- Image flow extracts scene/story context from a link or uploaded file
- Voice/audio flow transcribes the clip before story generation
- Resolve effective per-user config
- Apply secrets (runtime/shared/env)
- Build storyboard with text provider
- Optional consistency flow (if enabled and supported): generate one summary reference image
- Generate panel images (each prompt includes
Background+Image description;Story titleline removed; references summary style when available) - Stream panel sends to Telegram as each panel becomes ready
- Send final completion summary
Important behavior:
- Panel captions in chat use
X(Y)prefix - Image prompt explicitly forbids rendering text inside artwork (rule repeated in English/Hebrew/Russian)
- Watermark is configurable (
generation.panel_watermark, defaulttrue) - Consistency mode is configurable (
generation.consistency, defaulttrue) - Telegram sends use
protect_content=falseto keep forwarding enabled
Primary command handling is in handleCommand.
Notable UX behavior:
/objectivewithout args lists all objectives/crazyness <0..2>controls story invention temperature/optionswithout args explains valid paths/options; apply via dedicated commands (/objective,/panels,/mode,/vendor,/models, etc.)/keysshows runtime key status/vendors [role]prints available provider roles and options- URL flow sends
Detected link, parsing page: <url>with the exact parsed URL
Blacklist is persistent in config state:
- ids list
- usernames list (normalized)
Ban checks run before allowlist checks during message processing.
- Secrets are redacted from user-visible output
BOT_SECRETS_ENV_ONLY=truedisables YAML fallback for deployment/CI- Provider switching checks required keys and blocks missing-key changes
- R2 state object: user runtime config/secrets/profile + history
- R2: env-scoped images, request logs, crash logs, runtime logs, and status markers
- Capacity/retention cleanup is enforced by runtime/storage managers
Primary suites:
npm run test:telegram:localnpm run test:telegramnpm run test:telegram:r2-realnpm run test:telegram:full-stacknpx vitest run -c telegram/vitest.config.js telegram/tests/webhook-url-real.e2e.test.js(opt-in withRUN_WEBHOOK_URL_REAL=true)
Secret checks before deploy/tests:
npm run secrets:validate:deploy:cinpm run secrets:validate:tests:ci
Use:
npm run bot:deploy:auto -- --target render --env staging --branch stage1 --env-onlySee:
telegram/docs/deployment-runbook.mdtelegram/docs/testing.md