Notification Channels
All outbound messages (alerts, reports, charts, trade notifications) route
through a fan-out registry in arb_bot/channels/ instead of
calling send_telegram() directly. Each enabled channel receives
every message independently; a per-channel try/except isolates
failures so one broken channel never silences another.
Channel protocol
Each channel implements three methods:
| Method | Signature | Notes |
|---|---|---|
enabled() | () → bool | Checked per-call; channel skipped if False |
send_text | (html: str) | Telegram HTML; Cliq converts via to_cliq() |
send_photo | (png: bytes, caption: str) | Cliq sends dashboard deep link instead |
send_document | (pdf: bytes, filename: str, caption: str) | Cliq sends dashboard deep link instead |
Config flags
| Flag | Default | Purpose |
|---|---|---|
TELEGRAM_ENABLED | true | Enable/disable Telegram channel |
CLIQ_ENABLED | false | Enable Zoho Cliq backup channel |
CLIQ_INCOMING_WEBHOOK_URL | — | Bot incoming webhook URL from Zoho |
CLIQ_WEBHOOK_TOKEN | — | zapikey token for webhook auth |
CLIQ_COMMAND_SECRET | — | Shared secret in X-Cliq-Secret header |
CLIQ_ALLOWED_SENDER | — | Comma-separated Zoho user IDs that may issue commands |
DASHBOARD_PUBLIC_URL | — | Used to generate deep links in photo/doc replies |
CLIQ_POLL_INTERVAL | 2.0 s | How often CliqCommandConsumer polls the queue |
Inbound commands (Cliq → bot)
Cliq pushes inbound messages to the dashboard (POST /api/cliq/command)
via a Deluge message handler. The dashboard validates the shared secret and
the sender, then enqueues the command in the cliq_inbound SQLite table.
A daemon thread (CliqCommandConsumer) polls the queue and dispatches
each command through the existing TelegramCommandHandler._dispatch()
with a CliqResponder so replies go back over the incoming webhook.
OTP login
The dashboard OTP (POST /api/auth/request-otp) calls notify()
so the one-time code is delivered to every enabled channel. If Telegram is
blocked, the OTP arrives via Cliq.
⏳ received immediately; the full reply arrives ~1–2 s later as a
separate webhook push.
See docs/cliq_setup.md for the Zoho UI setup steps and the Deluge handler snippet.