Commit 803b800
feat(channels): support WhatsApp-only mode (Telegram becomes optional)
Until now Telegram was a hard requirement. The bot would refuse to start
without TELEGRAM_BOT_TOKEN and TELEGRAM_ALLOWED_USER_ID, even when the
user only wanted to use WhatsApp. This commit lifts that constraint so
each instance can pick: Telegram only, Telegram + WhatsApp, or
WhatsApp only.
Config (src/config.ts)
- Adds telegram.enabled = (token present AND user_id valid).
- Telegram env vars are now optional. Whatever is missing simply turns
the channel off.
- Cross-channel invariant: at least one of telegram.enabled /
whatsapp.enabled must be true; otherwise loadConfig() throws with a
clear hint to run setup.sh.
Validation (src/runtime/bootstrap.ts)
- validateRuntimeEnvValues now accepts WhatsApp-only configs.
- Catches half-configured Telegram (token without user_id) so users
don't silently fall through to WhatsApp-only because of a typo.
- New tests cover: WhatsApp-only valid, both channels valid, no channel
invalid, partial Telegram invalid.
Bootstrap (src/app/start-bot-app.ts)
- Telegram bot creation, scheduled-task runtime init, webhook check and
bot.start() are all guarded by config.telegram.enabled.
- WhatsApp-only mode replaces grammy's blocking long-poll with a
Promise resolved by the shutdown handler — Baileys runs in the
background and the process stays alive on signals.
Setup (setup.sh)
- New STEP 2/12 — Messaging Channels — asks Telegram only / both /
WhatsApp only at the start of the wizard.
- STEP 3 (Telegram token) and STEP 4 (User ID) are skipped with a
visible "(skipped)" line when the user picked WhatsApp only.
- STEP 8 (WhatsApp number) is skipped when WhatsApp is off.
- Generated .env still writes empty Telegram lines so the user sees
what the alternative is and can flip it later.
- Summary block reflects each channel's enabled/disabled state.
CLI (bin/opencode-assistant)
- --doctor stops requiring TELEGRAM_BOT_TOKEN. It now reports each
channel's status independently, and only fails if neither is
configured.
- WhatsApp QR hint switched from `--logs bot` to the `--qr` shortcut.
Scheduled tasks (src/scheduled-task/runtime.ts)
- No code change: the runtime already gates registerTask() on
initialized; in WhatsApp-only mode start-bot-app.ts simply skips
initialize() and logs that /task is unavailable in this mode.
Docs
- docs/WHATSAPP_SETUP.md: documents the three modes, the WhatsApp-only
caveats (no /task, no permission/question UI), and the multi-channel
.env layout.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fc2d224 commit 803b800
7 files changed
Lines changed: 334 additions & 113 deletions
File tree
- bin
- docs
- src
- app
- runtime
- tests/runtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
| 590 | + | |
| 591 | + | |
591 | 592 | | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
597 | 599 | | |
598 | 600 | | |
599 | | - | |
600 | 601 | | |
601 | 602 | | |
602 | | - | |
| 603 | + | |
| 604 | + | |
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
606 | 608 | | |
607 | | - | |
| 609 | + | |
608 | 610 | | |
609 | 611 | | |
610 | 612 | | |
611 | 613 | | |
612 | 614 | | |
613 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
614 | 621 | | |
615 | 622 | | |
616 | 623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
4 | 14 | | |
5 | 15 | | |
6 | 16 | | |
| |||
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
16 | | - | |
| 26 | + | |
17 | 27 | | |
18 | | - | |
19 | 28 | | |
20 | 29 | | |
21 | | - | |
| 30 | + | |
22 | 31 | | |
23 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
24 | 42 | | |
25 | 43 | | |
26 | 44 | | |
| |||
31 | 49 | | |
32 | 50 | | |
33 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
34 | 57 | | |
35 | 58 | | |
36 | 59 | | |
37 | 60 | | |
38 | 61 | | |
39 | 62 | | |
40 | 63 | | |
| 64 | + | |
| 65 | + | |
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
| |||
0 commit comments