Configurazione Telegram

Per controllare il tuo bot e ricevere notifiche in tempo reale, devi configurare un bot Telegram privato. Questo garantisce che solo tu abbia accesso ai tuoi dati di trading e controlli.

1. Crea un Bot tramite BotFather

BotFather è il bot Telegram ufficiale per la gestione di altri bot. Apri Telegram, avvia una chat con BotFather e segui i passaggi per creare il tuo nuovo assistente di trading.

Apri @BotFather

2. Aggiungi il Token Bot alla Configurazione

Una volta che BotFather ti dà il token API HTTP, devi aggiungerlo alla configurazione del tuo bot. Questo token agisce come una password sicura per il tuo bot.

Percorso file:

Code
byninja-trading-bot/src/telegram/config/config_telegram.py

Sostituisci il seguente campo con il tuo token:

Code
TELEGRAM_BOT_TOKEN = "your_telegram_bot_token"

3. Proteggi il Tuo Bot (Trova Chat ID)

Per la massima sicurezza, il tuo bot deve rispondere solo a TE. Raggiungiamo questo obiettivo collegandolo al tuo Chat ID personale di Telegram. Nessun altro potrà eseguire comandi.

Innanzitutto, naviga nella directory sorgente:

Code
cd byninja-trading-bot/src

Successivamente, attiva il tuo ambiente virtuale Python. Se non lo hai ancora configurato, controlla la guida Avvio Rapido.

Code
source ../env/bin/activate

Infine, esegui lo script di configurazione Telegram:

Code
python3 -c "from telegram.setup import main; main()"

Lo script di configurazione è ora in attesa che tu invii un messaggio al bot dal tuo account Telegram personale.

Code
⚠️  Telegram Bot Setup - Find Your Chat ID

🔍 Checking Telegram API connection...
TelegramBot - INFO - Telegram connected | Bot: @Bot

🎯 Finding Chat ID...
============================================================
🔍 Waiting for message from you...
IMPORTANT: First find the bot in Telegram and send it ANY message
1. Open Telegram
2. Find @Bot
3. Press START or send any message
4. Wait 10 seconds...
⏹️ To stop press Ctrl+C

🔍 Checking updates... status: 200
📭 No messages found. Send bot a message in Telegram...
🔍 Checking updates... status: 200
📭 No messages found. Send bot a message in Telegram...
🔍 Checking updates... status: 200

Una volta che invii un messaggio, il bot ti riconoscerà immediatamente e mostrerà il tuo Chat ID sicuro.

Code
✅ Found new message!
👤 From: User
📩 Text: 'hi'
🆔 Your Chat ID: 449933911
💡 Add to config.py: TELEGRAM_CHAT_ID = '449933911'

✅ Chat ID obtained successfully!
🆔 Your Chat ID: 449933911

💾 Add this to config_telegram.py:
TELEGRAM_CHAT_ID = "449933911"

🧪 Testing message sending capability...
🎉 Test message sent! Check Telegram.

Copia il tuo Chat ID univoco e aggiungilo allo stesso file di configurazione:

Code
TELEGRAM_CHAT_ID = "your_private_telegram_chat_id"

Consiglio Pro: Usa un Editor di Codice

Per un'esperienza molto migliore durante la modifica dei file di configurazione, raccomandiamo di utilizzare un editor di codice professionale come Visual Studio Code.

Download VS Code ↗