56 lines
1.0 KiB
Markdown
56 lines
1.0 KiB
Markdown
|
|
# Telegram IP Bot
|
||
|
|
|
||
|
|
Bot Telegram minimalista per recuperare l'indirizzo IP pubblico del server.
|
||
|
|
|
||
|
|
## Setup
|
||
|
|
|
||
|
|
### 1. Ottieni il Token del Bot
|
||
|
|
|
||
|
|
1. Apri Telegram e cerca [@BotFather](https://t.me/botfather)
|
||
|
|
2. Crea un nuovo bot con `/newbot`
|
||
|
|
3. Copia il token fornito (formato: `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`)
|
||
|
|
|
||
|
|
### 2. Configura le Variabili d'Ambiente
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cp .env.example .env
|
||
|
|
nano .env
|
||
|
|
```
|
||
|
|
|
||
|
|
Inserisci il tuo token nel file `.env`:
|
||
|
|
```
|
||
|
|
BOT_TOKEN=il_tuo_token_qui
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3. Avvia il Bot
|
||
|
|
|
||
|
|
```bash
|
||
|
|
docker compose up -d --build
|
||
|
|
```
|
||
|
|
|
||
|
|
### 4. Usa il Bot
|
||
|
|
|
||
|
|
Apri Telegram, cerca il tuo bot e invia `/start` o `/ip`.
|
||
|
|
|
||
|
|
## Comandi
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Ferma il bot
|
||
|
|
docker compose down
|
||
|
|
|
||
|
|
# Riavvia il bot
|
||
|
|
docker compose restart
|
||
|
|
|
||
|
|
# Visualizza i log
|
||
|
|
docker compose logs -f telegram-bot
|
||
|
|
|
||
|
|
# Verifica stato
|
||
|
|
docker compose ps
|
||
|
|
```
|
||
|
|
|
||
|
|
## Note
|
||
|
|
|
||
|
|
- Il bot si riavvia automaticamente in caso di crash o reboot del sistema
|
||
|
|
- Il token è protetto: `.env` è escluso da Git
|
||
|
|
- Architettura: Python 3.11 + Docker + requests
|
||
|
|
- Dipendenza unica: `requests==2.31.0`
|