05-sep: [proyecto2] bot Telegram para OpenCode en VPS (serve + bot + systemd, listo para token)
This commit is contained in:
50
vps_opencode_bot/README.md
Normal file
50
vps_opencode_bot/README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# opencode_tg — Bot de Telegram para OpenCode (VPS)
|
||||
|
||||
Bot que permite usar OpenCode desde el móvil vía Telegram. Corre en el VPS
|
||||
Contabo junto a `opencode serve` (headless). Sin librerías extra (solo
|
||||
`requests`), long-polling, whitelist por chat_id.
|
||||
|
||||
## Despliegue
|
||||
|
||||
- Código: `/opt/opencode-tg/opencode_bot.py`
|
||||
- `.env`: `/opt/opencode-tg/.env`
|
||||
- Repo activo del serve: `/etc/opencode-tg/repo.env` (`REPO_DIR=...`)
|
||||
- Servicios systemd:
|
||||
- `opencode-serve.service` → `opencode serve --hostname 127.0.0.1 --port 4097`
|
||||
dentro de `$REPO_DIR` (credenciales OPENCODE_SERVER_USERNAME/PASSWORD).
|
||||
- `opencode-tg.service` → el bot.
|
||||
|
||||
Para cambiar de repo el bot reinicia `opencode-serve` (escribe `repo.env`).
|
||||
Cada chat conserva su sesión y modelo en `estado.json`.
|
||||
|
||||
## Comandos del bot
|
||||
|
||||
```
|
||||
/start /ayuda ayuda
|
||||
/nueva [texto] sesión nueva (olvida el contexto)
|
||||
/proyecto elegir repo de /home/Github (inline)
|
||||
/modelo elegir modelo (inline)
|
||||
/estado repo, sesión y modelo actuales
|
||||
cualquier texto → lo ejecuta OpenCode en la sesión del chat
|
||||
```
|
||||
|
||||
Entrega: texto como HTML (bloques ``` en <pre>), ficheros creados/editados
|
||||
como documentos adjuntos (se leen de `state.metadata.files` del historial).
|
||||
|
||||
## PENDIENTE (único paso manual)
|
||||
|
||||
1. Crear el bot con @BotFather y copiar el token.
|
||||
2. Rellenar en `/opt/opencode-tg/.env`:
|
||||
```
|
||||
TELEGRAM_BOT_TOKEN=<token>
|
||||
TELEGRAM_CHAT_ID=<tu chat_id>
|
||||
```
|
||||
(`TELEGRAM_CHAT_ID` puede ser una lista separada por comas.)
|
||||
3. Arrancar:
|
||||
```
|
||||
systemctl enable --now opencode-tg
|
||||
```
|
||||
|
||||
API comprobada contra opencode 1.17.15: POST /session, POST /session/:id/message
|
||||
(body `parts` + `model` con `providerID`/`modelID`), GET /session/:id/message,
|
||||
GET /config/providers, GET /global/health, GET /project.
|
||||
Reference in New Issue
Block a user