# AvioBull Telegram Bot — Changelog

## Complete build — 2026-10-17
- Full user side: deposits (USDT/BTC/bank + proof), withdrawals (VAT code, reserve/settle), trading (markets, live prices, market orders, positions, close), AI/Signals/Copy subscriptions, KYC document upload, notifications, support.
- Full admin side: deposit/withdrawal review + approve/reject, KYC review, user search + status, balance adjustments, VAT code generate/show/revoke, trade settlement (win/loss/draw), broadcasts, settings.
- Double-entry ledger with zero-sum invariant; audit log; rate limiting; update idempotency.
- Worker (cron): live crypto prices (Binance) + SL/TP/liquidation checks.
- Migrate/seed/provision-admin scripts. PHP syntax linter, schema validator, callback-routing checker, service-method checker.

## Stage 1 — 2026-10-17
- Framework, webhook, account registration, menu, ledger, admin recognition.

## Web installer — 2026-10-17
- Added public/install.php: browser-based setup (write config, migrate + seed, create first admin, set Telegram webhook) for hosts without terminal access. Tests the DB connection, auto-generates app key + webhook secret, locks after install.
- Added public/cron.php: web-callable worker fallback (secret-protected) for hosts without shell cron — call every minute via a free pinger.
- Added public/.htaccess restricting direct PHP access to webhook/cron/install only.
- Settings expanded (VAT expiry hours, one-time use) with input validation.

## Fix — 2026-10-17
- FIX: web installer 'Migration failed / SQL syntax error' — the migrator split SQL on every semicolon, gluing comment lines onto the next statement. Replaced with a proper splitter that strips comments and only breaks on top-level semicolons (keeps generated columns like AS (IF(...)) intact). Verified: 25 statements across 5 migrations parse cleanly.
- Migrator now tolerant of a half-applied database (skips 'already exists' for tables/columns/keys) so a retry after a failed run completes cleanly. Installer Database step gains a 'Reset database' button to drop all tables for a fresh start.
- FIX: installer 'Connect bot' step errored with 'Return value must be of type array, true returned'. Telegram setWebhook returns a boolean; the API client now accepts non-array results. The webhook was typically set correctly despite the error.

## Design update — 2026-10-17
- Redesigned welcome: described intro screen with logo, 'How it works' screen, and an explicit Register step (Confirm & create account) on /start. Users must register before using features.
- Branded main menu and section headers (portfolio card, dividers, aligned figures, richer emoji) to feel closer to the AvioBull web.
- Bundled an AvioBull logo (public/logo.png); the installer uploads it to Telegram automatically so the welcome is branded out of the box. Admins can change it anytime via Admin → Settings → Set bot logo (just send a photo).
- Telegram client now supports image uploads (multipart).
