# iishko-ts TypeScript rewrite of the [iishko](https://github.com/aaronjaworski710/iishko) Telegram AI bot. Why rewrite: - Python monolith (13K lines, single file) accumulated hotfixes; no tests, sync sqlite inside asyncio - TypeScript + grammY: typed end-to-end, native async, modular from day one, graceful shutdown ## Status **Skeleton / staging.** Core loop works (start, balance, key issuance, streaming chat with quota spend). Not yet at feature parity with the Python bot — production keeps running the Python version until parity + tests are green. ## Parity roadmap - [x] Config (typed, env + config.json) - [x] SQLite (WAL, busy_timeout) — users/tokens/ledger - [x] Gateway client: OpenAI-compat, SSE streaming, native tools, fallback chain (content-policy 400 → next model) - [x] /start (referral capture), /balance, /key (KEYWAIT gate) - [x] Streaming chat with edit-throttle + quota spend - [ ] Rank/tier system (MODEL_ALIASES + tier gating via sync_rank_limits equivalent) - [ ] Games/casino/quiz modules - [ ] Webapp (aiohttp → Hono/Fastify) + pricing showcase - [ ] Admin panel commands - [ ] Data migration script (bot.db Python → TS schema) - [ ] Test suite (vitest) + CI - [ ] Prod cutover (same token can't poll from two processes — hard switch with rollback unit) ## Run ```bash npm install cp config.example.json config.json # fill bot_token + main_key npm run build && npm start # or: npm run dev ``` Env overrides: `IISHKO_BOT_TOKEN`, `IISHKO_MAIN_KEY`, `IISHKO_NEWAPI_URL`, `IISHKO_DB`, `IISHKO_ADMIN_ID`, `IISHKO_DEFAULT_MODEL`, `IISHKO_TS_CONFIG`. ## Layout ``` src/ config.ts typed config loader db.ts sqlite schema (users/tokens/ledger) gateway.ts OpenAI-compat client: stream + non-stream + native tools + fallback ctx.ts grammY context with injected deps index.ts bootstrap, session, error handler, signals modules/ start.ts | keys.ts | chat.ts | economy.ts ```