Skip to content

Architecture ​

┌──────────────┐   long polling    ┌────────────┐
│ Telegram bot │◄─────────────────►│            │
│  (buttons)   │   media uploads   │    gra     │
└──────────────┘                   │   daemon   │
┌──────────────┐  profile / feed / │  (tokio)   │
│  Instagram   │◄─────────────────►│            │
│     API      │  stories / follows└─────┬──────┘
└──────────────┘                         │ SQLite

Crates ​

CrateRole
instagramProfile, feed and story scraping and media cleaning, over wreq (BoringSSL with Chrome TLS emulation)
wreq / wreq-utilHTTP stack for the Telegram client, the following-list endpoint and CDN downloads
rusqliteSQLite storage (bundled)
tokioAsync runtime: scheduler, long polling, per-chat workers
clap, toml, serdeCLI, environment and config parsing

Modules (src/) ​

ModuleResponsibility
bot/Long polling; updates handled concurrently across chats and in order within a chat; commands, flows, inline keyboards
bot/callback.rsTyped inline-button actions and their compact callback_data format
bot/views.rsScreens as pure functions: data → text + keyboard
poller.rsScheduler: due accounts → profile + stats → new posts → new stories → download → deliver
ig.rsInstagram session, following list, size-capped downloads, cookie input parsing
tg.rsBot API client: retries on network errors, 5xx and flood control; multipart uploads; token-free errors
db.rsVersioned SQLite schema and queries with ownership checks
config.rsCLI / env / TOML merging and validation
state.rsExpiring per-chat input flows and following-list caches
render.rsHTML message builders, numbers, dates, sparklines

Poll loop ​

Every tick_secs the scheduler loads active accounts whose last_checked_at + interval_secs has passed and checks them with at most max_concurrent_checks in parallel. Each check:

  1. Profile: followers/following/posts are stored on the account; with stats enabled, a stats row is appended when the counters changed.
  2. Posts: the latest feed items newer than the account's watermark are delivered oldest first (photo, video, or albums for carousels), up to max_send_per_check. Each delivery is recorded in delivered and advances the watermark, so restarts never re-send.
  3. Stories (only with cookies): active stories not yet delivered are sent; a story fetch failure doesn't fail the check.

Media that can't be uploaded (videos disabled, over Telegram's 10 MB photo / 50 MB video limits, download or upload error) is replaced by the caption with a link and a note. If even that message fails, the check fails and is retried later. Failed checks are stamped and retried on the account's interval; the user is notified once when the account starts failing.

Credentials resolution ​

account-linked set  →  user's ⭐ default set  →  first global 🌐 set  →  anonymous

An account set to None is always checked anonymously. Profile previews when adding an account use the user's default set (or the global set); the following list only ever uses the user's own default set.

Storage ​

SQLite in WAL mode with foreign keys. db_path accepts plain paths and file: URIs. Tables: users, cookie_sets (user_id NULL = global), accounts, stats, delivered. The schema version is kept in PRAGMA user_version; databases from incompatible releases are rejected instead of being migrated.

Released under the MIT License. Not affiliated with Instagram or Meta.