# Deployment Guide

## First Deploy (on Selectel server)

### 1. Copy project to server

```bash
rsync -av --exclude='.env' --exclude='*.db' --exclude='venv/' \
  conference-bot/ user@YOUR_SERVER_IP:/home/user/conference-bot/
```

### 2. On server: setup environment

```bash
ssh user@YOUR_SERVER_IP
cd /home/user/conference-bot
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
nano .env  # insert BOT_TOKEN and ADMIN_ID
```

### 3. On server: install and start systemd service

Replace YOUR_LINUX_USER in conference-bot.service first:
```bash
sed -i 's/YOUR_LINUX_USER/user/g' conference-bot.service
sudo cp conference-bot.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable conference-bot
sudo systemctl start conference-bot
sudo systemctl status conference-bot
```

Expected status: `active (running)`

### 4. Check logs

```bash
sudo journalctl -u conference-bot -f
```

Expected lines: `DB initialized` and `Starting bot, event: <event_id> (type=conference|webinar)`

## Updating the bot

```bash
# On server:
cd /home/user/conference-bot
git pull
sudo systemctl restart conference-bot
```

## Pre-event checklist

### Conference (subscription gate)
- [ ] All speakers have added the bot as admin to their Telegram channels
- [ ] `event.json` updated with current speakers (via /set_event — alias /set_conference still works — or manual edit + restart)
- [ ] Test: send /start, go through subscription flow, check /stats
- [ ] Test: send yourself a test broadcast via /broadcast_stream

### Webinar (Google Calendar URL + Zoom rassylka)
- [ ] `event.json` has `type: "webinar"` + `datetime` with timezone + `duration_minutes`
- [ ] Test: send /start, confirm Google Calendar button opens the right event in the right TZ
- [ ] Test: /broadcast_invite_all with a tiny test message → preview shows recipient count and the calendar button
- [ ] On event day: /broadcast_zoom with the Zoom link → confirms reaches all registered users
