feat: add Telegram bot for manual trade commands

- Added telegram_command_bot.py with slash commands (/buySOL, /sellBTC, etc)
- Docker compose setup with DNS configuration
- Sends trades as plain text to n8n webhook (same format as TradingView)
- Improved Telegram success message formatting
- Only responds to authorized chat ID (579304651)
- Commands: /buySOL, /sellSOL, /buyBTC, /sellBTC, /buyETH, /sellETH
This commit is contained in:
mindesbunister
2025-10-27 00:23:09 +01:00
parent c2842f88c0
commit 3e2cf2eec2
24 changed files with 2573 additions and 6 deletions

115
TELEGRAM_BOT_README.md Normal file
View File

@@ -0,0 +1,115 @@
# Telegram Trading Bot - Quick Reference
## 🚀 Quick Setup (3 steps)
### 1. Import n8n workflow
- Open: http://10.0.0.48:8098
- Import: `telegram-manual-trade-FINAL.json`
- Connect last node to "Check Risk" in Money Machine
- Activate workflow
### 2. Get Telegram Bot Token
Run on your phone:
```
Open Telegram → @BotFather → /newbot → follow instructions
```
You'll get a token like: `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`
### 3. Run setup
```bash
./complete_telegram_setup.sh
```
Paste your bot token when asked.
---
## 📱 Using it on your phone
Just send messages to your Telegram chat:
```
buy sol
sell btc
buy eth
sell sol
```
The bot will:
1. ✅ Parse your message
2. ✅ Forward to n8n webhook
3. ✅ n8n sends to your trading bot
4. ✅ Trade executes with risk checks
5. ✅ You get confirmation in Telegram
---
## 🔧 Management
**View logs:**
```bash
docker logs -f telegram-trade-bot
```
**Restart bot:**
```bash
docker restart telegram-trade-bot
```
**Stop bot:**
```bash
docker-compose -f docker-compose.telegram-bot.yml down
```
**Start bot:**
```bash
docker-compose -f docker-compose.telegram-bot.yml --env-file .env.telegram-bot up -d
```
---
## 📋 Configuration Files
- `.env.telegram-bot` - Bot token and webhook URL
- `docker-compose.telegram-bot.yml` - Docker configuration
- `telegram_trade_bot.py` - Bot source code
---
## 🐛 Troubleshooting
**Bot not responding?**
```bash
docker logs telegram-trade-bot
```
**Check if bot is running:**
```bash
docker ps | grep telegram
```
**Test webhook manually:**
```bash
curl -X POST http://10.0.0.48:8098/webhook/manual-trade \
-H "Content-Type: application/json" \
-d '{"text": "buy sol"}'
```
**Check n8n workflow:**
- Is it activated?
- Is the webhook URL correct?
- Is it connected to Check Risk node?
---
## ✅ Supported Commands
From your phone, send any of these:
- `buy sol` / `buy btc` / `buy eth`
- `sell sol` / `sell btc` / `sell eth`
- `long sol` / `short btc` (same as buy/sell)
The bot extracts:
- **Symbol**: SOL, BTC, or ETH (defaults to SOL)
- **Direction**: sell/short = short position, anything else = long position
Commands are case-insensitive: `BUY SOL`, `Buy Sol`, `buy sol` all work!