# AsakaBank Telegram Bot + Admin Panel

## Talablar
- Python 3.11+
- PostgreSQL

## O'rnatish

```bash
# 1. Virtual muhit yaratish
python -m venv venv
source venv/bin/activate      # Linux/Mac
venv\Scripts\activate         # Windows

# 2. Kutubxonalarni o'rnatish
pip install -r requirements.txt

# 3. .env fayl yaratish
cp .env.example .env
# .env ni tahrirlang:
#   BOT_TOKEN  — @BotFather dan olingan token
#   STAFF_IDS  — Xodim(lar)ning Telegram ID (vergul bilan ajrating)
#               ID ni bilish uchun @userinfobot ga /start bosing
#   DATABASE_URL — PostgreSQL ulanish manzili

# 4. PostgreSQL da baza yaratish
createdb asakabank
# yoki psql ichida:  CREATE DATABASE asakabank;

# 5. Ishga tushirish (bot + admin bir vaqtda)
python run.py
```

## Ishlatish

### Mijoz (Telegram bot)
1. Botga `/start` bosadi
2. Til tanlaydi (O'zbek / Rus / Ingliz)
3. Savol yozadi

### Xodim (Admin panel)
- `http://localhost:8000` — barcha chatlar
- Filtr: **Barchasi / Yangi / Aktiv / Tugatilgan**
- Chat statuslari:
  - 🔴 **Yangi** — mijoz xabar yozdi, hali javob berilmadi
  - 🟢 **Aktiv** — xodim javob berdi, suhbat davom etmoqda
  - ⚪ **Tugatilgan** — chat yopilgan

### Bir nechta xodim
`STAFF_IDS=111111,222222,333333` — barchasi bildirishnoma oladi,  
lekin faqat bitta admin panelda javob berishi kifoya.

## Fayl strukturasi
```
asakabank_bot/
├── bot/
│   ├── bot.py        ← Telegram bot logikasi
│   ├── database.py   ← PostgreSQL so'rovlari
│   └── texts.py      ← Ko'p tilli matnlar
├── admin/
│   ├── app.py        ← FastAPI backend
│   └── templates/
│       ├── index.html ← Chat ro'yxati
│       └── chat.html  ← Chat sahifasi
├── db/
│   └── schema.sql    ← Jadvallar
├── run.py            ← Ishga tushiruvchi
├── requirements.txt
└── .env.example
```
